Question

Now i am developing my own driver.I develop in i/o kitDriver template.I build my code it is executed successfully but the problem in terminal. I developed the code in below manner in header file

#include <IOKit/IOService.h>

class com_osxkernel_driver_IOKIT : public IOService
{
  OSDeclareDefaultStructors(com_osxkernel_driver_IOKIT)
public:
  virtual bool    init (OSDictionary* dictionary = NULL);
  virtual void    free (void);
  virtual IOService*      probe (IOService* provider, SInt32* score);
  virtual bool    start (IOService* provider);
  virtual void    stop (IOService* provider);
}; 

in .cpp

#include "IOKIT.h"
#include <IOKit/IOLib.h>

#define super IOService

OSDefineMetaClassAndStructors(com_osxkernel_driver_IOKIT, IOService)

bool com_osxkernel_driver_IOKIT::init (OSDictionary* dict)
{
  bool res = super::init(dict);
  IOLog("IOKI::init\n");
  return res;
}


void com_osxkernel_driver_IOKIT::free(void)
{
  IOLog("IOKIT::free\n");
  super::free();
}


IOService* com_osxkernel_driver_IOKIT::probe (IOService* provider, SInt32* score)
{
  IOService *res = super::probe(provider, score);
  IOLog("IOKIT::probe\n");
  return res;
}


bool com_osxkernel_driver_IOKIT::start(IOService*provider)
{
  bool res = super::start(provider);
  IOLog("IOKIT::start\n");
  return res;
}

void com_osxkernel_driver_IOKIT::stop(IOService*provider)
{
  IOLog("IOKIT::stop\n");
  super::stop(provider);
}

Then i build the above code successfully after that IOKIT-info.plist

IOKitPersonalities dictionary the below five contents i added

Key                                           Type                            Value



CFBundleIdentifier                  String  com.osxkernel.${PRODUCT_NAME:rfc1034identifier}                          

IOClass                             String      com_osxkernel_driver_IOKIT

IOMatchCategory                     String       com_osxkernel_driver_IOKIT

IOProviderClass                     String       IOResources

IOResourceMatch                     String        IOKit

after that

in OSBundleLibraries dictionary i added two entries

Key                            Type                                   value


com.apple.kpi.iokit          String                                  11.3.0                          

com.apple.kpi.libkern        string                                  11.3.0

After that i again build it successfully

coming to terminal loading i follow the below steps

before terminal i find kext file path and copy that bundle into /system/library/extension/

then go to terminal

to execute below manner

ensiss-Mac-mini:~ ensis$ sudo su
Password:
sh-3.2# chown -R 775 /System/Library/Extensions/IOKIT.kext 
sh-3.2# sudo kextload /System/Library/Extensions/IOKIT.kext 
/System/Library/Extensions/IOKIT.kext failed to load - (libkern/kext) validation failure 
(plist/executable); check the system/kernel logs for errors or try kextutil(8).
sh-3.2# 

hey guys please help me ,and one of the important thing is whenever i execute kext files develop by generic driver it is execute in terminal very successfully.

And also i am beginner this kernel programming

Était-ce utile?

La solution

First of all: I very much do not recommend you copy in-development kexts into /Library/Extensions or /System/Library/Extensions - this is a very bad idea and can cause your system to become unbootable. Copying to /Library/Extensions or /System/Library/Extensions can load your kext completely automatically, which is normally not what you want during development (especially not if it crashes your system - on rebooting, it will reload the kext and crash the system again, etc.).

Delete your kext from there and do something like this instead:

sudo cp -r /path/to/your/IOKIT.kext /tmp/

This should also solve any permissions problems - no need to run chmod/chown. Then, as the error message from kextload suggests, use kextutil instead. Don't use kextload, kextutil is better in every way.

sudo kextutil /tmp/IOKIT.kext

For additional output, you can use the -v flag:

sudo kextutil -v /tmp/IOKIT.kext

This should hopefully give you a more useful error message that you can then act upon.

Some types of kext essentially do require loading on boot, or at least for most kinds of testing. It's often still helpful to sanity-check that the kext loads without crashing when loaded manually before installing it. (Examples are: IOFramebuffer kexts, or anything which is required for booting the system itself, such as storage drivers which are required to find the operating system volume, or network drivers which are required for netboot.)

I'd also recommend against using su, and instead using sudo on each command that requires it. It remembers your password for a while anyway.

To see the kernel log, either run

# 10.12+:
log stream
# 10.8-10.11:
tail -f /var/log/system.log
# 10.7 and earlier:
tail -f /var/log/kernel.log

in a second Terminal.app window (or via a ssh session from another system), or launch Console.app and select "All Messages" (10.7 & older: kernel.log) on the left.

Update: I've added mentions of /Library/Extensions which is now the correct place to install third-party kexts. Only use /System/Library/Extensions on 10.8 or older. I've also updated the kernel log viewing.

Autres conseils

Please check the doc: https://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KEXTConcept/KEXTConceptDebugger/debug_tutorial.html

$ sudo cp -R MyDriver.kext /tmp

$ sudo chown -R root:wheel MyDriver.kext

It works fine for me after following the doc from Apple.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top