enumarating USB device

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Post by naiksidd_85 »

hi,

I read the wiki for enumarating the PCI but in vain.
I am not able find how exactly it needs to be done.
What i am looking forward to is to just detect the presence of USB host controller.

I have checked with the code that reads the SMBIOS tables, it does detect USB device. This means that BIOS enumerates PCI bus, now I am trying to check actually how do i do it.

If any one has any idea pls help me out. :(
Learning a lot these days THANKS to OSdev users
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

What on the PCI page is it that you don't understand?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Post by naiksidd_85 »

i tried reading the the address 0xcf8 to 0xcfc and beyond but the values there are zero...
Learning a lot these days THANKS to OSdev users
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Well then

outs to 0xCF8 lets you choose a device and a register on that device (see the table on that page) You'll have to choose the device and register of your liking, then read 0xCFC to get the contents of that register.

Code: Select all

dword value;
for (int i = 0; i < 32; i++)
{
    out32 (0xCF8, (i << 11) | 0x80000000);
    value = in32(0xCFC);
    if (value != 0xffffffff && value != 0)
    {
        printf("Device found in slot %i: %x\r\n", i, value);
    }
}
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Post by naiksidd_85 »

hey thanks now am able to read the values
Learning a lot these days THANKS to OSdev users
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Post by CmpXchg »

naiksidd_85 wrote:I have checked with the code that reads the SMBIOS tables, it does detect USB device. This means that BIOS enumerates PCI bus, ... .
How exactly do you do this?
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Post by naiksidd_85 »

I just scan for the string _SM_ in memory range f0000 to fffff on 16 bit boundry.

on encountering the anchor string jump to offset 18h where we have the 4 byte address of location of the SMBIOS structures.
just read the structures and you get all the information of the hardware connected to your machine.
Learning a lot these days THANKS to OSdev users
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

I don't know if you care, but the SMBIOS is for 'maintenance purposes'. To quote Brendan in a previous thread:
SMBIOS is designed for hardware maintenance purposes - e.g. creating a catalogue of hardware on your LAN so you can keep track of it all for spare parts, upgrades, insurance, etc. ACPI, MPS, PCI, PnP, etc are designed for software to use for hardware detection and configuration. I wouldn't use SMBIOS for hardware detection and configuration, and I wouldn't use ACPI, MPS, PCI, PnP, etc for hardware maintenance purposes.
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Post by naiksidd_85 »

you did not get my point I tried SMBIOS just to see if the PCI enumaration takes place at bios level.
If Bios can enumerate PCI the will be a small footprint of the code that we execute in real mode this is just my way of information gathering surely there are better ways of doing it ..
Learning a lot these days THANKS to OSdev users
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Post by CmpXchg »

naiksidd_85 wrote:you did not get my point I tried SMBIOS just to see if the PCI enumaration takes place at bios level...
Naturally it takes place at bios level, and bios does it extremely well.

I'm now thinking if I should use ports 0CF8h-0CFFh for PCI enumaration, or should I call BIOS for it? This call is available even in protected mode (it's INT 1Ah, if I'm not much mistaken).
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Post by naiksidd_85 »

I might be wrong but isnt 1Ah used for system timer and clock services???
:?:
Learning a lot these days THANKS to OSdev users
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Post by CmpXchg »

naiksidd_85 wrote:I might be wrong but isnt 1Ah used for system timer and clock services???
:?:
Oh yes. The timing functions are AH=00h-0Fh while PCIBIOS covers AX=0B101h-0B10Fh and also AX=0B181h-0B18Fh. The latter seem to be 32-bit, so they are probably available in protected mode. I should try to test it from under DOS...
Every Man Must Learn David DeAngelo's Stuff, Period.
http://www.doubleyourdating.com/Catalog
User avatar
naiksidd_85
Member
Member
Posts: 76
Joined: Thu Jan 17, 2008 1:15 am

Re: enumarating USB device

Post by naiksidd_85 »

sorry for going off topic is past few posts also i was away from the PC as I was suffering from conjunctivitis and was not able to sit for long hours..
starting the work again ...
am still not able to read the BARS properly. need to do a lot more reading hopefully i may get some thing out of it. [-o<
Learning a lot these days THANKS to OSdev users
Post Reply