Boundary communication using IOMemory* and IOMemoryDescriptor*. Comments awaited.
Boundary communication using IOMemory* and IOMemoryDescriptor*. Comments awaited.
- Subject: Boundary communication using IOMemory* and IOMemoryDescriptor*. Comments awaited.
- From: "rohit dhamija" <email@hidden>
- Date: Mon, 12 Jun 2006 21:41:41 +0530
Hi,
Developing kernel extension for USB bulk and control type transfer for Mac OS X 10.3.9 , 10.4 ppc and Intel Mac.
Some time back I posted a query for issues coming in cross-communication of user-level with kernel level. Below is one of the way I found out for cross communication. Please send your comments for the same:
// Shared structure
typedef union __IOCTL_COMMAND
{
P_CMD_HEAD pApiCmd; // Pointer to Command head
_RSP_HEAD ApiRsp; // Response head buffer
} _IOCTL_COMMAND , *P_IOCTL_COMMAND;
// structure involved in data transfers.
typedef struct
{
unsigned long deviceIndex; //the index required by GetDeviceInfo
unsigned long iBufferSz; //The command Sz
unsigned long oBufferSz; //the expected output Buffer size
_IOCTL_COMMAND IOCmd;
} _COMMAND_EXCHANGE, *P_COMMAND_EXCHANGE;
//////////////////////
// IOUSerClient
IOReturn myDriverUserClient::_CommonAPICmd(_COMMAND_EXCHANGE* inpkt,
_COMMAND_EXCHANGE* outpkt)
{
P_CMD_HEAD pCmd = NULL;
// take a pointer to memory descriptor
IOMemoryDescriptor *memDescOut = NULL;
IOMemoryMap* memMap = NULL;
// Allocate the memory descriptor needed
memDescOut = IOMemoryDescriptor::withAddress(
(vm_address_t)inpkt->IOCmd.pApiCmd,
inputSize,
kIODirectionOut,
stask);
if ( memDescOut == NULL )
{
return kIOReturnNoResources;
}
// Map the buffer into the kernel memory
memMap = memDescOut->map(kernel_task, kIOMapAnywhere, kIOMapAnywhere,0, inputSize);
//check mapping
if(memMap == NULL){
memDescOut->release();
return kIOReturnNoResources;
}
pCmd = (P_CMD_HEAD)memMap->getVirtualAddress();
if( (pCmd == NULL) || (pRsp == NULL))
{
memDescOut->release();
return kIOReturnNoResources;
}
memMap->unmap();
memMap->release();
if(memDescOut)
memDescOut->release();
break;
}
return status;
}
Thanks and Regards,
Rohit
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden