3

I would like to know what is going on during sleep and wakeup process on OSx Kernel.

Does a Kernel extension receive a new address space and start all over again its initialization process or the kernel simply puts the extension back in the same address space?

Does internal kernel extensions (IOKit drivers for example) also behave the same? Perhaps they are loaded into a different location in the memory?

Basically the question is: will my driver, which obtained an interface to a IOService, will be able to use its address after sleep without a problem.

mrdvlpr
  • 526
  • 4
  • 20

1 Answers1

1

On sleep, memory is "frozen", and on resume, it's restored to its original state. So unless you actively participate in power management, your kext won't notice anything has changed. If you're dealing directly with hardware, you will HAVE to care about power management, though, as your device will have power-cycled and will need to be reinitialised.

pmdj
  • 22,018
  • 3
  • 52
  • 103
  • So hardware devices, like keyboard, are perhaps reloaded and my device driver instance pointer might be incorrect? – mrdvlpr Nov 20 '13 at 07:36
  • 1
    The instance would usually stay the same for most kinds of devices, but you shouldn't be holding regular pointers to device driver instances anyway. If your service depends on a device, your service object should be `attach()`ed to the device's IOService, so that if it goes away for whatever reason, it will participate correctly in the `terminate()` sequence. Note that if you're using IOKit matching to create your service on top of a device instance, your service is already being attached when it successfully matches a driver instance, so no need to do it manually in that case. – pmdj Nov 20 '13 at 08:11
  • If that doesn't answer your question, I suggest starting a new question which gives specifics about precisely what you are currently doing and what case you are trying to handle. – pmdj Nov 20 '13 at 08:22