On Sep 22, 2011, at 06:46 AM, Segher Boessenkool <segher@...> wrote:
ioreg -w0 -l -p IOUSB is what you mean I think. Kids today and
their GUI toys!
Can't be sure who actually knows how to use a command line interface these days.
The root hubs sims have no PortNum property set.
Good. That makes the solution simple.
>>>> From what I understand a hub can only have up to 7 ports. If
>>>> that is correct I can just set any value over 7 to 0.
I think the maximum is 32 but I cannot find it in the spec right now.
>> Will Darwin never use a number <= 7 for a root hub? It looks to me
>> like the top byte is the pci devfn (with dev,fn swapped on my
>> but not on yours) :-)
> I don't have enough data to say for sure :-/. I'm just guessing
> based on how apple generates locationIDs. I found an instance of a
> hub having 8 port though so 1-8 are valid port numbers. I need to
> dig through the USB spec.
But we already found they changed the locationid generation algo at
least once :-(
It's not meant to convey any information anyway, it's just an ID.
The locationID appears to be meant to convey the location within the USB topology (which is why it could work for us). The only thing Apple appears to have changed (from PPC->Intel) is how they generate the locationIDs of the root hub simulations. Everything else about the algorithm appears to be the same.
But, given that it is possible that the port number is either the most significant 4 (seen this) or 8 (haven't seen this yet) non-zero bits of the locationID we cannot just use the locationID :-/ . I will post an updated patch that uses the PortNum property of the device and the locationID property of the parent to determine the topology.
>> Maybe it is better to check whether the low 24 bits are zero; but I
>> bet there is some proper way to ask the OS as well.
> I think checking that the low 24 bits are 0 is sufficient to detect
> a root hub. If not we can read the PortNum property from the
> IORegistry. If that property does't exist it is a root hub
> simulation (I coded this as well).
That sounds better. You need to read that property anyway, and if it
doesn't exist you need to handle _that_ anyway :-)
Yeah, definitely safer. Just more code and not as clever ;).