Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: kextload/unload and multiple devices
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kextload/unload and multiple devices



Hi Dean -

Thanks for the info. I was inquiring about this mainly for testing. Conceivably one could have a scenario where there are say 2 instances of our PCIe card installed, and then a PCIe to ExpressCard adapter device, with our ExpressCard device installed, all matched to the same driver. Then at some point the ExpressCard device could be removed. Similarly it could be reinserted at some later time. I wanted to be able to test this case in an environment where I didn't actually have the ExpressCard adapter.

In reality it looks like this scenario is unlikely anyway; in testing some PCIe to ExpressCard adapters, at least on the Mac Pro it appears that hot unplug/replug isn't supported, and in laptops you only have one slot.

Thanks,
Jim

At 2:21 PM -0800 2/13/07, Dean Reece wrote:
On Feb 13, 2007, at 12:49 AM, Jim Wintermyre wrote:
Our driver supports multiple physical instance of our PCI/PCIe device. Normally, kextload loads the driver for every instance of our device; similarly, kextunload unloads every instance of the driver.

Is there any way to kextload the driver for only a specific physical device instance, i.e. load it for card A but not for card B? Similarly, is there any way to kextunload only a specific instance of the driver?

When a kext is loaded, all IOService objects that are currently unmatched will be evaluated to see if the new driver can drive them. An instance of your class will be created for each matching nub. When you kextunload a kext, the kernel will "terminate" all instance of classes that the kext owns - the actual unload occurs only once the class instance counts go down to 0.


There is no way to say "this kext should only be matched on this nub". The kext itself can be smart enough to fail any matches it doesn't want, but there is no way to restrict the matching process from outside the kext. Also, if a kext declines to match, I don't think it'll get a second chance on that nub till the next reboot (though I haven't looked at those matching rules in a long time).

As for unloading, an in-kernel function can send "terminate" messages to individual drivers, independent of a kextunload, but there isn't a programmatic way to do that from user-space that I'm aware of.

Are you trying to use this for debugging, or do you want to do this in a production environment?
- Dean

_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-drivers mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >kextload/unload and multiple devices (From: Jim Wintermyre <email@hidden>)
 >Re: kextload/unload and multiple devices (From: Dean Reece <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.