flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Usb device enumeration

Author
Thread Post new topic Reply to topic
Gilles



Joined: 25 Oct 2004
Posts: 24
Gilles 08 Mar 2006, 08:48
I'm trying to dectect all installed usb devices at boot time (before loading any operating system)
But I thing my problem is a misunderstanding of the USB protocol that's why I would like some clarification.
Here's what I've done so far:
Reading to learn:
- USB specefication (difficult to understand everything ;-( )
- UHCI specification
- usb.c usb_uhci.c ... from LINUX usb core system
- pcusb.cc (usb emulation) from BOCHS (latest version)

Code written
- Host controller detection: PCI, UHCI
- IO base and Irq detection
- Disable legacy mode
- Allocating of the frame memory
- Installing a dummy interrupt (want clarification on what is only needed for device
enumeration ! ! !)
- Global reset
- Host controller reset and enable shedule (frame base and frame num are set)
- Also creating a virtual root hub

My questions are: Question
- Do I have to make "get_device_descriptor" with device id = 0 (and assigning a non zero ID)
until the function failed ?
- How do the uhci acknowleged the host for new attached device ? (I couldn't find it after reading
the emulation made in pcusb.cc from bochs)


I would appriciate any help !
Post 08 Mar 2006, 08:48
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 08 Mar 2006, 09:32
I see that in one step you are disabling legacy mode. Wouldn't it be simpler if you collected all legacy mode USB-devices and THEN disable it. There will be less work to do. Is there something I missed and you can't detect all devices in legacy mode?

Otherwise you're probably a lot further that others on this board if you made it in assembly, but good luck anyway.
Post 08 Mar 2006, 09:32
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 08 Mar 2006, 17:10
Gilles wrote:
I'm trying to dectect all installed usb devices at boot time (before loading any operating system)
But I thing my problem is a misunderstanding of the USB protocol that's why I would like some clarification.
Here's what I've done so far:
Reading to learn:
- USB specefication (difficult to understand everything ;-( )
- UHCI specification
- usb.c usb_uhci.c ... from LINUX usb core system
- pcusb.cc (usb emulation) from BOCHS (latest version)


Good but youa also have to read OHCI and more important EHCI (usb 2.0) specifications.

Quote:

Code written
- Host controller detection: PCI, UHCI
- IO base and Irq detection
- Disable legacy mode
- Allocating of the frame memory
- Installing a dummy interrupt (want clarification on what is only needed for device
enumeration ! ! !)


IRQ is missused in USB but required ...

Quote:

- Global reset
- Host controller reset and enable shedule (frame base and frame num are set)
- Also creating a virtual root hub


Good, Solar OS (unreleased version yet) is also doing "kind of" this but in protected mode.

Quote:

My questions are: Question
- Do I have to make "get_device_descriptor" with device id = 0 (and assigning a non zero ID)
until the function failed ?


Yes you do ... "pooling" is the essence of USB Very Happy. Kind of a steep backwards in humman evolution.

Quote:

- How do the uhci acknowleged the host for new attached device ? (I couldn't find it after reading
the emulation made in pcusb.cc from bochs)
I would appriciate any help !


Try on a real PC and you will notice some bits changing in the controller status when a new device is attached. However you still have to change the descriptors and pool a "discovery protoocol" since the status information is not enough to make a decission what device and where it is attached.

_________________
"Any intelligent fool can make things bigger,
more complex, and more violent.
It takes a touch of genius -- and a lot of courage --
to move in the opposite direction."


Last edited by bogdanontanu on 08 Mar 2006, 20:50; edited 1 time in total
Post 08 Mar 2006, 17:10
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 08 Mar 2006, 19:14
The programmer who was working on Dex4u USB emulation is call "tonyMac" topic here:
http://dex.7.forumer.com/viewtopic.php?t=20&start=0
Maybe he could help.
But from a OS Dev point of view, i have found it much better to use BIOS USB driver (if your PC has it ), in Dex4u we can boot form USB pen drives, read/write to USB floppy's, card reads, unload from digital camera, etc, using a special driver that users the BIOS USB driver, also usb keyboard work too.

Note we can do the above from pmode.
Post 08 Mar 2006, 19:14
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 08 Mar 2006, 20:49
Quote:

Note we can do the above from pmode.

By returning to real mode for a brief moment? Very Happy
Post 08 Mar 2006, 20:49
View user's profile Send private message Visit poster's website Reply with quote
Gilles



Joined: 25 Oct 2004
Posts: 24
Gilles 09 Mar 2006, 08:54
Thanks a lot for all of your responses ,I'm going to test it right now and continue my learning.
Post 09 Mar 2006, 08:54
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 09 Mar 2006, 19:56
Yes boganontanu, that rights Smile , i have 2 driver for floppy and 2 for Hdd, so you can choses between a BIOS (switching back and forth) or pmode.
There little difference in speed between the 2 drivers, but using BIOS USB by this method is sloooooow Sad .
Post 09 Mar 2006, 19:56
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.