Re: Generic Kernel API

From: Charles Swiger <cswiger_at_mac.com>
Date: Wed, 9 Nov 2005 16:23:28 -0500
On Nov 9, 2005, at 1:58 PM, Julian Elischer wrote:
> Marcin Jessa wrote:
[ ... ]
>> My idea is to create an API for binary vendor drivers to make it
>> easier for hardware vendors to create FreeBSD drivers the same way
>> they can do for Windows or Mac OS X.
>
> well, you could port the Darwin driver interface in the form of a  
> shim, or
> extend "project evil" to cover more kinds of drivers..

An interesting thought, although the IOKit uses an embedded C++  
subset rather than plain C [1].  For those who aren't familiar with  
it, the Darwin kernel API for drivers, variously called the IOKit or  
DriverKit, is documented here:

http://developer.apple.com/documentation/DeviceDrivers/

...and the "Fundamentals" document is an interesting read:

"First, neither the Mac OS 9 driver model nor the FreeBSD driver  
model offers a set of features rich enough to meet the needs of Mac  
OS X. The Mac OS X kernel is significantly more advanced than its Mac  
OS precursors; it handles memory protection, preemptive multitasking,  
multiprocessing, and other features not present in previous versions  
of Mac OS. Although FreeBSD is capable of handling these features,  
the BSD model does not offer other features expected in a modern  
operating system, including automatic configuration, driver stacking,  
power management, and dynamic loading of devices."

In truth, FreeBSD does have reasonable support for PnP autoconfig and  
dynamic loading of device drivers, and FreeBSD does have a decent C- 
based object system with introspection in <sys/kobj.h>, although that  
doesn't seem to be fully taken advantage of in places where it could  
be, except perhaps in the sound and UART drivers.  Most other FreeBSD  
drivers are "flat" and have a fair amount of code duplication, rather  
than using OO inheritance so that your fxp or dc driver inherits from  
a common NIC abstraction (Apple's IONetworkController ->  
IOEthernetController -> _device_).

Apple has found that using inheritance is a big win for them: "In  
addition, code reusability decreases the memory footprint of drivers;  
drivers ported from Mac OS 9, for example, have been up to 75%  
smaller in Mac OS X."  Of course, it's easier to say such things then  
to write the code, but Apple has achieved pretty good results from  
the IOKit.

-- 
-Chuck

[1]: http://www.caravan.net/ec2plus/
Received on Wed Nov 09 2005 - 20:23:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:47 UTC