Dear All,
I am developing a KEXT for PCI device for Mac OS X 10.4.9 (ppc and
intel) and stuck up while mapping device memory at user level. I
searched all the older archives for this but could no where get the
hint. Also, couldnot find any relevant sample for this. I hope you
would please help me out in this matter.
Below is the piece of code that I wrote at kernel level. To allow
user client to map hardware registers into my application, I am
using IOConnectMapMemory. This API returns success, and I get an
address corresponding to the same. But when i see the memory
contents corresponding to it, it shows all values as AAAAAAAAA,
AAAAAAA, i.e. it seems nothing is mapped.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * */
#define super IOUserClient
OSDefineMetaClassAndStructors(MyDriver_drv_user, IOUserClient)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * */
extern IODeviceMemory *physicalMem;
IOReturn MyDriver_drv_user::clientMemoryForType(UInt32 type,
IOOptionBits * options, IOMemoryDescriptor ** memory)
{
physicalMem->map( fTask, kIOMapAnywhere, kIOMapAnywhere, 0, 0); if
(!physicalMem) return -1;
physicalMem->retain();
*memory = physicalMem;
return kIOReturnSuccess;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * */
#define super IOService
OSDefineMetaClassAndStructors(MyDriver_drv, IOService)
IOMemoryMap * fRegisterMap = NULL;
IODeviceMemory *physicalMem = NULL;
IOPCIDevice * fPCIDevice = NULL;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * */
bool MyDriver_drv::start(IOService * provider)
{
if (!super::start(provider))
return false;
fPCIDevice = (IOPCIDevice *) provider;
if(!fPCIDevice)
return false;
fPCIDevice->setMemoryEnable( true );
fPCIDevice->setIOEnable( true );
fRegisterMap = fPCIDevice->mapDeviceMemoryWithRegister
(kIOPCIConfigBaseAddress2);
if(fRegisterMap)
{
physicalMem = IODeviceMemory::withRange(fRegisterMap-
>getPhysicalAddress(),fRegisterMap->getLength());
physicalMem->initWithPhysicalAddress(fRegisterMap-
>getPhysicalAddress(),fRegisterMap->getLength(), kIODirectionOutIn));
}
registerService();
return true;
}
Please let me know the fault with above piece of code and if
possible, let me know the link of any sample application (if at all
it exists)
Thanks and Regards,
Rohit Dhamija
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-drivers mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-drivers/dean.reece%
40apple.com
This email sent to email@hidden