Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

User - Kernel communication solution requires your review!!



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,
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.