| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Dear All,
My machine configuration: Mac OS X 10.4.9 , G4
I need to map my kernel's virtual memory at user level, but not able to achieve it. Below are the steps performed:
I am using IOConnectMapMemory call to get the kernel memory at the user level. But at user space I am only able to get the first address of that memory segment (which is mapped using getVirtualAddress() in the driver). At kernel level I have full access of this memory But I am not able to map it properly at the user level.
USER LEVEL:
At user level I am using following code :
/* code snippet */
vm_address_t address = nil;
io_connect_t dataPort= 0;
kernResult = IOServiceOpen(serviceObject, mach_task_self(), 0, &dataPort);
// Release the io_service_t now that we're done with it.
IOObjectRelease(serviceObject);
if (kernResult != KERN_SUCCESS)
{
//printf("IOServiceOpen returned %d\n", kernResult);
return 0;
}
// IOConnectMapMemory will call clientMemoryForType() inside your user client class.
printf("\nsize initially = %d\n",size);
kernResult = IOConnectMapMemory(dataPort, kIODefaultMemoryType, mach_task_self(), &address, &size, kIOMapAnywhere);
this call IOConnectMapMemory is successful.
KERNEL LEVEL:
In the User Client of driver I have implemented clientMemoryForType method in the following way:
IOReturn
drv_user::clientMemoryForType(UInt32 type, IOOptionBits * options, IOMemoryDescriptor ** memory)
{
IOReturn result = kIOReturnSuccess;
fMemoryToShare = IOMemoryDescriptor::withAddress( (vm_address_t)deviceRegisters, //virtual address of the first byte in memory
sizeof(SDA_reg),
kIODirectionOut,
fTask);
if ( fMemoryToShare == NULL )
{
IOLog("\nError! memDescOut is null\n");
return kIOReturnNoResources;
}
fMemoryToShare->retain();
*memory = fMemoryToShare;
IOLog("\nSuccess!, nclientMemoryForType complete... \n");
return result;
}
Where
typedef struct SDA_reg {
UInt8 reg[0x10000];
UInt8 reg1;
UInt8 reg2;
} SDA_reg;
SDA_reg * deviceRegisters;
deviceRegisters = (SDA_reg *)fRegisterMap->getVirtualAddress();//Getting virtual address in the start method of Driver
Can anybody suggest any solution or can tell about wether my approach is wrong or some function parameter is incorrect.
Any relevant code snippet will also be of great help.
Thanks in Advance,
Amber
_______________________________________________ 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/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.