Question

I have a driver for a USB-attached custom SCSI device which implements some vendor-specific commands. Each USB device hosts more than one SCSI LUN. This is working quite happily, but there is a problem with grouping SCSI LUNs according to device, as from the IOSCSILogicalUnitNub level down (which my driver inherits from), there are no identifying features which link the LUNs together (there are SCSI Logical Unit Numbers, but these collide for every new device; they all have a unit 0x0).

I'd like to do something like link them all according to the USB locationID field (or any other unique key), but I don't know how to get at the parent USB devices given only the io_service_t of the matching SCSI drivers. This would also be better to be done on the application side, rather than in the driver, as the application needs to keep track of which service has which LUNs and was opened by which instance of the handler.

The hierarchy in the IO Registry is:

MyUSB-SCSI Device@fd130000
 |-IOUSBCompositeDriver
 |-Mass Storage Class Interface@0     (has location ID 0xfd130000)
   |-IOUSBMassStorageClass
     |-IOSCSILogicalUnitNub@0         (has SCSI LUN number, unique in this device, but not globally)
     | |-com_Company_driver_MyDriver  (my driver)
     |   |-IOBlockStorageServices
     |     |-Manuf Device Media       (these are strings from the device firmware)
     |       |-IOMediaBSDClient
     |
     |-IOSCSILogicalUnitNub@0
       |-com_Company_driver_MyDriver
         |-IOBlockStorageServices
           |-Manuf Device Media
             |-IOMediaBSDClient
Was it helpful?

Solution

If your device's io_service_t is in the variable _device, then the code would look like:

CFTypeRef _thing_you_want = IORegistryEntrySearchCFProperty(_device, kIOServicePlane, CFSTR("locationID"), NULL, kIORegistryIterateParents);

Go here for more info:

http://developer.apple.com/library/mac/#documentation/devicedrivers/conceptual/AccessingHardware/AH_IOKitLib_API/AH_IOKitLib_API.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top