SCSIControllerDriverKit

RSS for tag

Develop drivers for SCSI protocol-based devices.

Posts under SCSIControllerDriverKit tag

50 Posts

Post

Replies

Boosts

Views

Activity

Is SCSIPeripheralsDriverKit on board?
I've try to develop a dext to send SCSI commands to some storage products, but when I try to implements SCSIPeripheralsDriverKit/IOUserSCSIPeripheralDeviceType00 interface, I... just don't know how to do it, I tried to convert kext way to Driverkit way, but I always block by error warnings. After I google a lots of solutions, I was wondering is this feature working? or Is there any samples or guideline?
0
0
854
Jun ’23
How to access dmaaddress (Physical Address) in DriverKit?
I am trying to use IOUserBlockStorageDevice in DriverKit to simulate a fake device (Implementing a Ram Disk). Currently I'm confused on how to use the dmaaddress in the following interface virtual kern_return_t DoAsyncReadWrite (bool isRead, uint32_t requestID, uint64_t dmaAddr, uint64_t size, uint64_t lba, uint64_t numOfBlocks, IOUserStorageOptions options) = 0; According to https://github.com/briancabbott/macOS-system-projects/blob/19310aa5c7b7507408261a22a2e8f46f9d478a88/Resources/Code/apple-oss-distributions/IOStorageFamily/IOUserBlockStorageDevice_kext.cpp Before calling "DoAsyncReadWrite", kernel allocate a segment of physical memory by using "IODMAcommand::genIOVMSegments". This segment's physical address is pass to DoAsyncReadWrite as parameter "dmaAddr". To implement a correct ram disk, we need to "transform" this physical address to virtual so that we can "Read" or "Write" on this physical address. I tried to use "IOMemoryDescriptor" to access this dmaAddr. In IOKit, I belive I can use interface such as "withPhysicalAddress" to access the memory. However, such interface is not exist while using driverkit, all interface that I can use in DriverKit IOMemoryDescriptor is : -kern_return_t GetLength(uint64_t * returnLength) LOCALONLY; // apparently not this one -virtual kern_return_t CreateMapping( uint64_t options, uint64_t address, uint64_t offset, uint64_t length, uint64_t alignment, IOMemoryMap ** map); // Maybe this one with kIOMemoryFixedAddress option? // But I get Segment Fault while calling this with CreateMapping( kIOMemoryFixedAddress , dmaaddr, 0, size, 0, &map); // Or getting error return while calling CreateMapping with same paramters after IOBufferMemoryDescriptor::Create // Also, output iomemorymap is not used here, which is quiet strange. static kern_return_t CreateSubMemoryDescriptor(uint64_t memoryDescriptorCreateOptions, uint64_t offset, uint64_t length, IOMemoryDescriptor * ofDescriptor, IOMemoryDescriptor ** memory) attribute((availability(driverkit,introduced=20.0))); // Seems not this, it create “sub“ memory descriptor static kern_return_t CreateWithMemoryDescriptors(uint64_t memoryDescriptorCreateOptions, uint32_t withDescriptorsCount, IOMemoryDescriptor * const withDescriptors[32], IOMemoryDescriptor ** memory) attribute((availability(driverkit,introduced=20.0))); // Seems not this, it don’t take any dmaaddr as parameter. and a private function kern_return_t Map( uint64_t options, uint64_t address, uint64_t length, uint64_t alignment, uint64_t * returnAddress, uint64_t * returnLength) LOCALONLY; // Maybe this one? But the header file don’t show any description on this function and we are not sure what parameters should we pass. // Currently I've test Map( kIOMemoryFixedAddress , dmaaddr, size, 0, &returnAddress, &returnLength) but get error return. It seems that I've made some mistake on using IOMemoryDescriptor? How to correct access a dmaaddress? I've also tried class "IODMACommand", but also get unexpected behavior. Another question is how to read / write buffer after I create correct mapping. While implementing kext, IOMemoryDescriptor can use "readBytes" or "writeBytes" to read or write memory that IOMemoryDescriptor maps to. However, DriverKit don’t have interface of "readBytes" or "writeBytes". Maybe I can directly access buffer by casting the IOMemoryDescriptor::Map "returnAddress" to void? (I haven't tried it yet cause "Map" always failed now QQ) Thanks for everyone's help.
2
1
2.8k
Feb ’23
Sending SCSI commands to USB mass storage device
Our device is USB Mass stroage device. We want to send a specific SCSI command to a USB drive in Mac OS X. Have any demo app that uses IOUserSCSIPeripheralDeviceType00 in SCSIPeripheralsDriverKit? We want to use below SCSI command, but have no demo program. https://developer.apple.com/documentation/scsiperipheralsdriverkit/3946437-inquiry https://developer.apple.com/documentation/scsiperipheralsdriverkit/iouserscsiperipheraldevicetype00/3946461-usersendcdb
0
2
1.1k
Nov ’22
SCSIControllerDriverKit: Process gets stuck on UserCreateTargetForID.
Context: We are working on migration of the driver, which is currently represented as a kernel extension, to the DriverKit framework. The driver works with Thunderbolt RAID storage devices. When connected through the Thunderbolt interface to the host, the device itself presents in the OS as a PCI device. The main function of our driver (.kext) is to create a "virtual" SCSI device in the OS for each virtual RAID array. So that the OS can work with these SCSI drives as usual disk storage.  We use https://developer.apple.com/documentation/scsicontrollerdriverkit to migrate this functionality in the dext version of the driver. Current issue: When a device is connected - the dext driver cannot create a SCSI drive in the OS. Technically our dext tries to create a SCSI drive using the UserCreateTargetForID method. On this step the OS sends the first SCSI command “Test Unit Ready ''to the device to check if it is a SCSI device. We process this command in an additional thread  separated from the main process of the dext (as it is recommended in the DriverKit documentation). We can see in the logs that the device receives this command and responses but when our dext sends this response to the OS the process is stuck in the waiting mode. How can we understand why it happens and fix it? More details: We are migrating functionality of an already existing “.kext” driver. We checked logs of the kext driver of this step: 15:06:17.902539+0700 Target device try to create for idx:0 15:06:17.902704+0700 Send command 0 for target 0 len 0 15:06:18.161777+0700 Complete command: 0 for target: 0 Len: 0 status: 0 flags: 0 15:06:18.161884+0700 Send command 18 for target 0 len 6 15:06:18.161956+0700 Complete command: 18 for target: 0 Len: 6 status: 0 flags: 0 15:06:18.162010+0700 Send command 18 for target 0 len 44 15:06:18.172972+0700 Complete command: 18 for target: 0 Len: 44 status: 0 flags: 0 15:06:18.275501+0700 Send command 18 for target 0 len 36 15:06:18.275584+0700 Complete command: 18 for target: 0 Len: 36 status: 0 flags: 0 15:06:18.276257+0700 Target device created for idx:0 We can see a successful message “Target device created for idx:0” In the the dext logs of the same step: We do not see the “Send command 18 for target 0 len 6” as we have in the kext logs  no log of the successful result “Target device created for idx:0” 15:54:10.903466+0700 Try to create target for 0 UUID 432421434863538456 15:54:10.903633+0700 UserDoesHBAPerformAutoSense 15:54:10.903763+0700 UserInitializeTargetForID 15:54:10.903876+0700 UserDoesHBASupportMultiPathing 15:54:10.904200+0700 UserProcessParallelTask start. 15:54:10.904298+0700 Sent command : 0 len 0 for target 0 15:54:11.163003+0700 Disable interrupts. 15:54:11.163077+0700 Complete cmd : 0 for target: 0 len: 0  status: 0 flags: 0 15:54:11.163085+0700 Enable interrupts. Will appreciate any help
3
1
1.6k
Nov ’22
Where is SCSIControllerDriverKit now?
Hi there! There was a presentation of the SCSI support in DriverKit on 2020 WWDC: https://developer.apple.com/videos/play/wwdc2020/10210/ Currently, the Xcode 12.4 (latest) has nothing regarding SCSI in DriverKit folders. Documentation says it is still in beta: https://developer.apple.com/documentation/scsicontrollerdriverkit So I've downloaded xcode 12.5 beta, where the driverkit 20.4 beta resides (according to https://developer.apple.com/support/xcode/) And what we have there? Just Kernel.framework/Versions/A/Headers/DriverKit/IOReturn.h 65:#define sub_iokit_scsi err_sub(16) And nothing more! So, the question is: do we have any way to use SCSI devices now on BigSur? Could I develop something for it with DriverKit, or should I use kext-approach for now, and wait for SCSI DriverKit support to be released indeed?
4
0
2.6k
Oct ’22
Does PCIDriverKit support PCI Device PNP?
I am woriking on SCSIControllerDriverKit IOUserSCSIParallelInterfaceController When I hot-plug my PCIe SCSI controller, the controller works normally, but when I hot remove the PCIe SCSI controller, the driverkit crashes. Thread 3 Crashed:: Dispatch queue: MyUserSpaceDriver-Default UserSpaceDriver-PCIe-hotremove.rtf.txt UserSpaceDriver-PCIe-hotremove.ips.txt
2
0
1.3k
Jan ’22
Does UserCreateTargetForID work for IOUserSCSIParallelInterfaceController?
I am working on SCSIControllerDriverKit UserSpaceDriver-UserCreateTargetForID.ips.txt I UserSpaceDriver-UserCreateTargetForID.rtf.txt OUserSCSIParallelInterfaceController My dext had follow this site description: https://developer.apple.com/documentation/scsicontrollerdriverkit/iouserscsiparallelinterfacecontroller/3567474-usercreatetargetforid But when the program calls: UserCreateTargetForID(scsi_target,targetOSDictionary) got panic.
0
0
1.3k
Dec ’21
Is SCSIPeripheralsDriverKit on board?
I've try to develop a dext to send SCSI commands to some storage products, but when I try to implements SCSIPeripheralsDriverKit/IOUserSCSIPeripheralDeviceType00 interface, I... just don't know how to do it, I tried to convert kext way to Driverkit way, but I always block by error warnings. After I google a lots of solutions, I was wondering is this feature working? or Is there any samples or guideline?
Replies
0
Boosts
0
Views
854
Activity
Jun ’23
How to access dmaaddress (Physical Address) in DriverKit?
I am trying to use IOUserBlockStorageDevice in DriverKit to simulate a fake device (Implementing a Ram Disk). Currently I'm confused on how to use the dmaaddress in the following interface virtual kern_return_t DoAsyncReadWrite (bool isRead, uint32_t requestID, uint64_t dmaAddr, uint64_t size, uint64_t lba, uint64_t numOfBlocks, IOUserStorageOptions options) = 0; According to https://github.com/briancabbott/macOS-system-projects/blob/19310aa5c7b7507408261a22a2e8f46f9d478a88/Resources/Code/apple-oss-distributions/IOStorageFamily/IOUserBlockStorageDevice_kext.cpp Before calling "DoAsyncReadWrite", kernel allocate a segment of physical memory by using "IODMAcommand::genIOVMSegments". This segment's physical address is pass to DoAsyncReadWrite as parameter "dmaAddr". To implement a correct ram disk, we need to "transform" this physical address to virtual so that we can "Read" or "Write" on this physical address. I tried to use "IOMemoryDescriptor" to access this dmaAddr. In IOKit, I belive I can use interface such as "withPhysicalAddress" to access the memory. However, such interface is not exist while using driverkit, all interface that I can use in DriverKit IOMemoryDescriptor is : -kern_return_t GetLength(uint64_t * returnLength) LOCALONLY; // apparently not this one -virtual kern_return_t CreateMapping( uint64_t options, uint64_t address, uint64_t offset, uint64_t length, uint64_t alignment, IOMemoryMap ** map); // Maybe this one with kIOMemoryFixedAddress option? // But I get Segment Fault while calling this with CreateMapping( kIOMemoryFixedAddress , dmaaddr, 0, size, 0, &map); // Or getting error return while calling CreateMapping with same paramters after IOBufferMemoryDescriptor::Create // Also, output iomemorymap is not used here, which is quiet strange. static kern_return_t CreateSubMemoryDescriptor(uint64_t memoryDescriptorCreateOptions, uint64_t offset, uint64_t length, IOMemoryDescriptor * ofDescriptor, IOMemoryDescriptor ** memory) attribute((availability(driverkit,introduced=20.0))); // Seems not this, it create “sub“ memory descriptor static kern_return_t CreateWithMemoryDescriptors(uint64_t memoryDescriptorCreateOptions, uint32_t withDescriptorsCount, IOMemoryDescriptor * const withDescriptors[32], IOMemoryDescriptor ** memory) attribute((availability(driverkit,introduced=20.0))); // Seems not this, it don’t take any dmaaddr as parameter. and a private function kern_return_t Map( uint64_t options, uint64_t address, uint64_t length, uint64_t alignment, uint64_t * returnAddress, uint64_t * returnLength) LOCALONLY; // Maybe this one? But the header file don’t show any description on this function and we are not sure what parameters should we pass. // Currently I've test Map( kIOMemoryFixedAddress , dmaaddr, size, 0, &returnAddress, &returnLength) but get error return. It seems that I've made some mistake on using IOMemoryDescriptor? How to correct access a dmaaddress? I've also tried class "IODMACommand", but also get unexpected behavior. Another question is how to read / write buffer after I create correct mapping. While implementing kext, IOMemoryDescriptor can use "readBytes" or "writeBytes" to read or write memory that IOMemoryDescriptor maps to. However, DriverKit don’t have interface of "readBytes" or "writeBytes". Maybe I can directly access buffer by casting the IOMemoryDescriptor::Map "returnAddress" to void? (I haven't tried it yet cause "Map" always failed now QQ) Thanks for everyone's help.
Replies
2
Boosts
1
Views
2.8k
Activity
Feb ’23
Sending SCSI commands to USB mass storage device
Our device is USB Mass stroage device. We want to send a specific SCSI command to a USB drive in Mac OS X. Have any demo app that uses IOUserSCSIPeripheralDeviceType00 in SCSIPeripheralsDriverKit? We want to use below SCSI command, but have no demo program. https://developer.apple.com/documentation/scsiperipheralsdriverkit/3946437-inquiry https://developer.apple.com/documentation/scsiperipheralsdriverkit/iouserscsiperipheraldevicetype00/3946461-usersendcdb
Replies
0
Boosts
2
Views
1.1k
Activity
Nov ’22
SCSIControllerDriverKit: Process gets stuck on UserCreateTargetForID.
Context: We are working on migration of the driver, which is currently represented as a kernel extension, to the DriverKit framework. The driver works with Thunderbolt RAID storage devices. When connected through the Thunderbolt interface to the host, the device itself presents in the OS as a PCI device. The main function of our driver (.kext) is to create a "virtual" SCSI device in the OS for each virtual RAID array. So that the OS can work with these SCSI drives as usual disk storage.  We use https://developer.apple.com/documentation/scsicontrollerdriverkit to migrate this functionality in the dext version of the driver. Current issue: When a device is connected - the dext driver cannot create a SCSI drive in the OS. Technically our dext tries to create a SCSI drive using the UserCreateTargetForID method. On this step the OS sends the first SCSI command “Test Unit Ready ''to the device to check if it is a SCSI device. We process this command in an additional thread  separated from the main process of the dext (as it is recommended in the DriverKit documentation). We can see in the logs that the device receives this command and responses but when our dext sends this response to the OS the process is stuck in the waiting mode. How can we understand why it happens and fix it? More details: We are migrating functionality of an already existing “.kext” driver. We checked logs of the kext driver of this step: 15:06:17.902539+0700 Target device try to create for idx:0 15:06:17.902704+0700 Send command 0 for target 0 len 0 15:06:18.161777+0700 Complete command: 0 for target: 0 Len: 0 status: 0 flags: 0 15:06:18.161884+0700 Send command 18 for target 0 len 6 15:06:18.161956+0700 Complete command: 18 for target: 0 Len: 6 status: 0 flags: 0 15:06:18.162010+0700 Send command 18 for target 0 len 44 15:06:18.172972+0700 Complete command: 18 for target: 0 Len: 44 status: 0 flags: 0 15:06:18.275501+0700 Send command 18 for target 0 len 36 15:06:18.275584+0700 Complete command: 18 for target: 0 Len: 36 status: 0 flags: 0 15:06:18.276257+0700 Target device created for idx:0 We can see a successful message “Target device created for idx:0” In the the dext logs of the same step: We do not see the “Send command 18 for target 0 len 6” as we have in the kext logs  no log of the successful result “Target device created for idx:0” 15:54:10.903466+0700 Try to create target for 0 UUID 432421434863538456 15:54:10.903633+0700 UserDoesHBAPerformAutoSense 15:54:10.903763+0700 UserInitializeTargetForID 15:54:10.903876+0700 UserDoesHBASupportMultiPathing 15:54:10.904200+0700 UserProcessParallelTask start. 15:54:10.904298+0700 Sent command : 0 len 0 for target 0 15:54:11.163003+0700 Disable interrupts. 15:54:11.163077+0700 Complete cmd : 0 for target: 0 len: 0  status: 0 flags: 0 15:54:11.163085+0700 Enable interrupts. Will appreciate any help
Replies
3
Boosts
1
Views
1.6k
Activity
Nov ’22
Where is SCSIControllerDriverKit now?
Hi there! There was a presentation of the SCSI support in DriverKit on 2020 WWDC: https://developer.apple.com/videos/play/wwdc2020/10210/ Currently, the Xcode 12.4 (latest) has nothing regarding SCSI in DriverKit folders. Documentation says it is still in beta: https://developer.apple.com/documentation/scsicontrollerdriverkit So I've downloaded xcode 12.5 beta, where the driverkit 20.4 beta resides (according to https://developer.apple.com/support/xcode/) And what we have there? Just Kernel.framework/Versions/A/Headers/DriverKit/IOReturn.h 65:#define sub_iokit_scsi err_sub(16) And nothing more! So, the question is: do we have any way to use SCSI devices now on BigSur? Could I develop something for it with DriverKit, or should I use kext-approach for now, and wait for SCSI DriverKit support to be released indeed?
Replies
4
Boosts
0
Views
2.6k
Activity
Oct ’22
Does PCIDriverKit support PCI Device PNP?
I am woriking on SCSIControllerDriverKit IOUserSCSIParallelInterfaceController When I hot-plug my PCIe SCSI controller, the controller works normally, but when I hot remove the PCIe SCSI controller, the driverkit crashes. Thread 3 Crashed:: Dispatch queue: MyUserSpaceDriver-Default UserSpaceDriver-PCIe-hotremove.rtf.txt UserSpaceDriver-PCIe-hotremove.ips.txt
Replies
2
Boosts
0
Views
1.3k
Activity
Jan ’22
Does UserCreateTargetForID work for IOUserSCSIParallelInterfaceController?
I am working on SCSIControllerDriverKit UserSpaceDriver-UserCreateTargetForID.ips.txt I UserSpaceDriver-UserCreateTargetForID.rtf.txt OUserSCSIParallelInterfaceController My dext had follow this site description: https://developer.apple.com/documentation/scsicontrollerdriverkit/iouserscsiparallelinterfacecontroller/3567474-usercreatetargetforid But when the program calls: UserCreateTargetForID(scsi_target,targetOSDictionary) got panic.
Replies
0
Boosts
0
Views
1.3k
Activity
Dec ’21