I had earlier reported that the following code failed to read any bytes...I am not sure why it may have failed before, but I'm guessing it was user (i.e. my) error and this does actually work as expected with my kext.
What I am attempting to do now is to see if I can loop over all 8gb of physical memory
for ( x = 0; x < 1024 * 1024 * 1024 * 8; x++ ) { descriptor = IOMemoryDescriptor::withPhysicalAddress( x, 10, kIODirectionOut ); descriptor->prepare( kIODirectionOut ); descriptor->readBytes( 0, buffer, 10 ); descriptor->complete(); descriptor->release(); }
But, as soon as as get past ~2.3gb, it I get a kernel panic.
Looking at the panic log, I noticed one of six IA32_MCA_STATUS variables had a valid error number. Below that, the report provides detail about the error, including the relevant code "0x1136". I found this system manual:
Look at Section 15-9, Interpreting the MCA Error Codes. The error code is a complex code, and the second nibble is 1, so the code is a cache hierarchy code, which is interpreted as:
000F 0001 RRRR TTLL
The RRRR is 0011, TT = 01 and LL =10, which translates to a Data Read request type, Transaction Type of Data, and the Level is Level 2.
Also, I looked at the backtrace and see that the panic occurs in the copypv function.
So, it appears it might be a cache coherency or lock issue.
If anyone has any insights into this issue, I would be interested.
Thank you.
I was interested in learning how to use an IOMemoryDescriptor and wrote the follow code:
IOMemoryDescriptor* descriptor;
descriptor = IOMemoryDescriptor::withPhysicalAddress( 5000, 5010, kIODirectionOut );
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" ); } }
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?
|