Basic Kernel Extension Programming questions
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com User-agent: Roundcube Webmail/0.5.4 IOMemoryDescriptor* descriptor; if ( descriptor ) { IOLog("MyBufferMethod prepare kIODirectionOutIn \n" ); IOReturn ioErr = descriptor->prepare( kIODirectionOut ); if ( ioErr == kIOReturnSuccess ) { IOLog("MyBufferMethod reading\n" ); char buffer[ 200 ]; IOByteCount count = descriptor->readBytes( 0, buffer, 10 ); if ( count > 0 ) IOLog("MyBufferMethod done...count > 0\n" ); else IOLog("MyBufferMethod done...count <= 0" ); } } Thank you. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... (1) In Apple's Kernel Extension Programming Topics book there is a tutorial titled "Creating a Device Driver with Xcode." I went through this tutorial and was able to use kextload to load the device driver and can see it in the list after executing kextstat. However, I was unable to get any code to actually execute. I was then able to locate the SimpleUserClient sample code and have been able to play around with it successfully. The primary difference between the tutorial and the sample project is that in the sample project there is an extra layer in the kext - the SimpleUserClient.cpp/h which appear to provide an interface between the actual driver code and the SimpleUserClientTool. So, what I am wondering is if the tutorial is missing this extra layer which would have allowed some of it code to be executed or if I should have been able to see output from any of the IOLog calls...? (2) I was interested in learning how to use an IOMemoryDescriptor and wrote the follow code: descriptor = IOMemoryDescriptor::withPhysicalAddress( 5000, 5010, kIODirectionOut ); It, of course, fails to read any bytes...I see the message "MyBufferMethod done...count <= 0". My questions is that if I simply wanted to read the bytes contained at an arbitrary location within physical memory, how can I do that? It seems like this approach should work, so I believe I am missing something obvious. Or, do I need to look into using something like /dev/mem to access the bytes stored within physical memory? (3) One can create an IOMemoryDescriptor with withAddressRange or withPhysicalAddress. If one passes kernel_task for the task_t argument, does this effectively do the same thing as creating the IOMemoryDescriptor using withPhysicalAddress? This email sent to site_archiver@lists.apple.com
participants (1)
-
mailist@ericgorr.net