ProjectOSX

Welcome Guest!

Returning User? Login here.

Want membership privileges? Register here.

 
Start a new topic Add Reply
> Nubs And I/o Space Helpers, Nubs and I/O Space helpers
iostres
post Jul 24 2011, 05:17 PM
Post #1
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
Slice
post 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.
Пожалуйста, прочитайте ЧаВо!
i3-2120 GA-H61M-S1, Radeon HD6670, ALC887(VoodooHDA 2.8.6), OS⌘10.9.4, OS⌘ 10.7.5 Clover FakeSMC_plugins_3.3.1 Realtek LAN v3.1.2
iostres
post Jul 25 2011, 10:18 AM
Post #3
QUOTE (Slice @ Jul 25 2011, 07:47 AM) *
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.


Thanks for the answer. I also disassembled AppleSMC and noticed it does not use in/out. :-(.

Add Reply Start a new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: