Hi!
I am writing my first Nub and need to map memory to it for I/O (accesible via inb & outb). I did the following (as shown in FakeSMC source):
IODeviceMemory::InitElement rangeList[1];
rangeList[0].start = 0x700;
rangeList[0].length = 0xff;
array = IODeviceMemory::arrayFromList(rangeList, 1);
if(!array) {
IOLog("failed to create Device memory array\n");
return false;
}
myNode->setDeviceMemory(array);
array->release();
myNode->attachToParent(provider, gIOServicePlane);
myNode->registerService();
I also created other class which inherits from IOACPIPlatformDevice and implemented following I/O helpers:
public:
virtual void ioWrite32( UInt16 offset, UInt32 value, IOMemoryMap * map = 0 ) { IOLog("helper called\n"); }
virtual void ioWrite16( UInt16 offset, UInt16 value, IOMemoryMap * map = 0 ) { IOLog("helper called\n"); }
virtual void ioWrite8( UInt16 offset, UInt8 value, IOMemoryMap * map = 0 ) { IOLog("helper called\n"); }
virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 ) { IOLog("helper called\n"); return 0;}
virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 ) { IOLog("helper called\n"); return 0;}
virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 ) { IOLog("helper called\n"); return 0;}
from other kext I do this:
asm volatile("xor $0, %%eax;"
"movl %1,%%edx;"
"inb %%dx,%%al;"
"movb %%al, %0"
: "=r" (out)
: "r" (in)
: "%eax", "%edx");
And get some unexpected values (one would expect to get 0 as that is return statement in helpers). Also "helper called" message is not seen /var/log/system.log so I conclude that my helpers are not called at all. Do I have to do some additional steps to register handlers or memory space?
Please help,
iostres
| Start a new topic Add Reply |
Jul 24 2011, 05:17 PM
Post #1
Jul 25 2011, 07:47 AM
Post #2
FakeSMC uses a C++ trick with subclassing of IOACPIPlatformDevice. It rewrite the method ioRead8() to fake reading of IOSpace.
So AppleSMC uses method ioRead8(0x300) will perform call to FakeSMC instead of reading hardware.
NB. inb, outb always work with hardware no matter what you writed around.
So AppleSMC uses method ioRead8(0x300) will perform call to FakeSMC instead of reading hardware.
NB. inb, outb always work with hardware no matter what you writed around.
Jul 25 2011, 10:18 AM
Post #3
FakeSMC uses a C++ trick with subclassing of IOACPIPlatformDevice. It rewrite the method ioRead8() to fake reading of IOSpace.
So AppleSMC uses method ioRead8(0x300) will perform call to FakeSMC instead of reading hardware.
NB. inb, outb always work with hardware no matter what you writed around.
So AppleSMC uses method ioRead8(0x300) will perform call to FakeSMC instead of reading hardware.
NB. inb, outb always work with hardware no matter what you writed around.
Thanks for the answer. I also disassembled AppleSMC and noticed it does not use in/out. :-(.
| Add Reply Start a new topic |
0 Members:






