How to access vendorID and ProductID in an USB Interface FD?
How to access vendorID and ProductID in an USB Interface FD?
I wonder how I would be able to able to access vendorID and productID of the device from inside an Interface FD ? The entry point of my FD is RunInterface() which receives a Startup message with an Interface descriptor without information of the vendor and product IDs. I've looked toward USBIntGetConfiguration() but I'm not sure it's the way to go.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: How to access vendorID and ProductID in an USB Interface
The supported way would be to use expansion.library calls. But expansion.lib only works on PCI devices AFAIK, it might not deal with all USB controllers.
Here is a way of finding out if a given vendor/device exists (not quite what you wanted but it might help).
ExpansionBase = IExec->OpenLibrary ("expansion.library", 53L);
IExpansion = (struct ExpansionIFace *)(IExec->GetInterface ((struct Library *)ExpansionBase, "main", 1, NULL));
IPCI = (struct PCIIFace *)(IExec->GetInterface ((struct Library *)ExpansionBase, "pci", 1, NULL));
pcidev = IPCI->FindDeviceTags (FDT_VendorID, VendorID,
FDT_DeviceID, DeviceID,
// FDT_Index, N,
TAG_DONE);
pcidev is non-NULL if the search was successful. You can also add a counter N in the tags, to return the Nth entry.
Having pcidev, you can read the Config registers; the first two 16-bit words are the Vendor and DeviceID. If you already have pcidev (or some equivalent), you may be able to look up the config registers using that. The worst that can happen is that it will crash or give a machine check exception.
Here is a way of finding out if a given vendor/device exists (not quite what you wanted but it might help).
ExpansionBase = IExec->OpenLibrary ("expansion.library", 53L);
IExpansion = (struct ExpansionIFace *)(IExec->GetInterface ((struct Library *)ExpansionBase, "main", 1, NULL));
IPCI = (struct PCIIFace *)(IExec->GetInterface ((struct Library *)ExpansionBase, "pci", 1, NULL));
pcidev = IPCI->FindDeviceTags (FDT_VendorID, VendorID,
FDT_DeviceID, DeviceID,
// FDT_Index, N,
TAG_DONE);
pcidev is non-NULL if the search was successful. You can also add a counter N in the tags, to return the Nth entry.
Having pcidev, you can read the Config registers; the first two 16-bit words are the Vendor and DeviceID. If you already have pcidev (or some equivalent), you may be able to look up the config registers using that. The worst that can happen is that it will crash or give a machine check exception.
cheers
tony
tony
Re: How to access vendorID and ProductID in an USB Interface
@Tony thank you for the answer but that's not exactly what I'm looking for.
In fact I'm trying to write an usbfd that will be automatically instanciated by the USB stack when products from a given vendor is plugged in. As such I wrote an fdclass according to that: try to load my driver in interface mode for the given vendor (try to look the overview from usbfd autodoc). Normally the USB stack can provide access to all those information however it seems that in interface mode I can only access to my own interface informations not the whole device information.
That's bad because I wanted to be able to support several product of this vendor in the same driver (only a few subtle differences exists in those different products which can be dealt with using simple switch at strategic places) but for this I need access to the vendor and product ID's...
EDIT: I don't think expansion.library would be of any use here, but I'll give it a look anyway, we never know...
In fact I'm trying to write an usbfd that will be automatically instanciated by the USB stack when products from a given vendor is plugged in. As such I wrote an fdclass according to that: try to load my driver in interface mode for the given vendor (try to look the overview from usbfd autodoc). Normally the USB stack can provide access to all those information however it seems that in interface mode I can only access to my own interface informations not the whole device information.
That's bad because I wanted to be able to support several product of this vendor in the same driver (only a few subtle differences exists in those different products which can be dealt with using simple switch at strategic places) but for this I need access to the vendor and product ID's...
EDIT: I don't think expansion.library would be of any use here, but I'll give it a look anyway, we never know...
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: How to access vendorID and ProductID in an USB Interface
Do you have the latest USB documentation?
The latest I have is dated 11th Aout 2011.
The latest I have is dated 11th Aout 2011.
cheers
tony
tony
Re: How to access vendorID and ProductID in an USB Interface
I think I do, but can't confirm. I have at least the one included in the SDK, haven't check if, as a betatester, I had an update or not. Anyway, are you asking this because you saw an answer to my problem?
Oh and I tried and experimented that GetConfiguration() method as I anticipated it unfortunately does not give me access to device and vendor IDs, only information about the current interface. :/
Oh and I tried and experimented that GetConfiguration() method as I anticipated it unfortunately does not give me access to device and vendor IDs, only information about the current interface. :/
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
- LyleHaze
- AmigaOS Core Developer
- Posts: 525
- Joined: Sat Jun 18, 2011 4:06 pm
- Location: North Florida, near the Big Bend
Re: How to access vendorID and ProductID in an USB Interface
Abalaban,
I can help.
I have a short prog here that will probably show what you're looking for.
This is NOT a "proper" program, it's just a short hack for sniffing around for unclaimed USB interfaces.
This is also my first attempt at using the "hidden" tags to prevent ugly code dumps. Wish me luck.
I hope it helps,
Lyle
I can help.
I have a short prog here that will probably show what you're looking for.
This is NOT a "proper" program, it's just a short hack for sniffing around for unclaimed USB interfaces.
This is also my first attempt at using the "hidden" tags to prevent ugly code dumps. Wish me luck.
Hidden Text - Click to Show :
Lyle
Re: How to access vendorID and ProductID in an USB Interface
Thank you, it seems to be what I was looking for! That's a strange workaround, but anyway it does what I want, so...
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
- LyleHaze
- AmigaOS Core Developer
- Posts: 525
- Joined: Sat Jun 18, 2011 4:06 pm
- Location: North Florida, near the Big Bend
Re: How to access vendorID and ProductID in an USB Interface
My code was cleaned up and brought up to date by Tjitte 'OldFart' de Wolff.
It's much better than it was.. Still for the same purpose, to find and detail unclaimed USB interfaces.
Thank You, Mr. de Wolff!
His revised program is here:
It's much better than it was.. Still for the same purpose, to find and detail unclaimed USB interfaces.
Thank You, Mr. de Wolff!
His revised program is here:
USBSniff.c :