1

现在我正在尝试编写一个既不使用 DMA 也不使用 PCI 并模拟 SCSI 目标的 IOUserSCSIParallelInterfaceController 驱动程序。

我意识到通过 UserProcessParallelTask​​ 方法给出的 SCSIUserParallelTask​​ 结构中的 fBufferIOVMAddr (https://developer.apple.com/documentation/scsicontrollerdriverkit/scsiuserparalleltask/3555105-fbufferiovmaddr)表示物理地址,它不能用作驱动程序中的内存地址内存空间。

我需要我的驱动程序向缓冲区写入一些内容并从缓冲区中读取一些内容,因为我想通过我的驱动程序代码进行 SCSI 通信。

有没有办法从 DriverKit 驱动程序访问物理地址中的内存?

4

1 回答 1

0
#if ARCMSR_DEBUG_UserGetDataBuffer
    if(pCCB->arcmsr_request.Cdb[0]==0xA0)/*SCSI_CMD_REPORT_LUN*/
    {
        IOBufferMemoryDescriptor *osdatabuffer = nullptr;
        uint64_t address, len, length=pCCB->request_transfer_count; /* parallelTask.fRequestedTransferCount */

        /*
        ******************************************************************************************************************************************
        **
        ** virtual kern_return_t UserGetDataBuffer(SCSIDeviceIdentifier fTargetID, uint64_t fControllerTaskIdentifier, IOBufferMemoryDescriptor **osdatabuffer);
        **
        ******************************************************************************************************************************************
        */
        if((UserGetDataBuffer(fTargetID, pCCB->fControllerTaskIdentifier, &osdatabuffer) != kIOReturnSuccess) || (osdatabuffer == NULL))
        {
            arcmsr_debug_print("ArcMSRUserSpaceDriver %d: ************************************************************************************ \n",ivars->adapter_index);
            arcmsr_debug_print("ArcMSRUserSpaceDriver %d: ** Get task data buffer error, ftargetID=%d fControllerTaskIdentifier=%d             \n",ivars->adapter_index,(int)fTargetID,(int)pCCB->fControllerTaskIdentifier);
            arcmsr_debug_print("ArcMSRUserSpaceDriver %d: ************************************************************************************ \n",ivars->adapter_index);            
            goto command_completion;
        }
        if((osdatabuffer->Map(0, 0, 0, 0, &address, &len) != kIOReturnSuccess) || (length != len))
        {
            arcmsr_debug_print("ArcMSRUserSpaceDriver %d: ************************************************************************************ \n",ivars->adapter_index);
            arcmsr_debug_print("ArcMSRUserSpaceDriver %d: ** Map task data buffer error, ftargetID=%d fControllerTaskIdentifier=%d             \n",ivars->adapter_index,(int)fTargetID,(int)pCCB->fControllerTaskIdentifier);
            arcmsr_debug_print("ArcMSRUserSpaceDriver %d: ************************************************************************************ \n",ivars->adapter_index);            
            goto command_completion;
        }
        /*
        *******************************************************************************************************************
        ** The LUN LIST LENGTH field shall contain the length in bytes of the LUN list that is available to be transferred.
        ** The LUN list length is the number of logical unit numbers in the logical unit inventory multiplied by eight.
        *******************************************************************************************************************
        */
        memset((void *)(address+3),8,1);     /* report_lun_data */
        memset((void *)(address+8),0,8);     /* first lun       */
        response.fBytesTransferred = 16;
    }
#endif
于 2021-11-04T03:08:52.597 回答