Question

I am writing a customised mass storage kernel extension for Mac, subclassed from the IOSCSIPeripheralDeviceType05 logical unit driver. I have got as far as compiling a .kext file, which passes kextutil -n -t ..., but I cannot load it for testing.

I have a non-zero IOKitDebug field in the .plist, and the GetDeviceConfiguration looks like this:

IOReturn
com_MyCompany_driver_MyDriver::GetDeviceConfiguration( void )
{
    IOLog( "MyDriver overriding GetConfiguration\n" );

    return super::GetDeviceConfiguration();
}

However when I copy it into /System/Library/Extensions/ and execute it with kextutil /System/Library/Extension/MyDriver.kext, nothing happens, and nothing appears in /var/log/system.log.

How do I load this .kext to be able to debug it?

Was it helpful?

Solution

First, don't put extensions in /SLE while developing them. That's asking for trouble, as it can cause the extension to be loaded automatically. This could cause the system to become unbootable. Just copy to, e.g. /tmp/ and use kextutil to load it from there.

Second, put some debug output in com_MyCompany_driver_MyDriver::init() as that's the first thing that'll get called.

Third, your problem is likely the device matching. If the device is already matched by an existing driver at the time of loading your kext, yours won't be considered. If you can't hot-plug the device and you can't unload the existing driver before loading yours, you may need to install the kext in SLE to be loaded on boot after all. If you're still having matching trouble, post some details of the device you're trying to match (ioreg/IORegistryExplorer output) and the matching dictionary from your info.plist.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top