From owner-freebsd-current@FreeBSD.ORG Wed Nov 9 21:23:34 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 055DB16A41F for ; Wed, 9 Nov 2005 21:23:34 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E15643D48 for ; Wed, 9 Nov 2005 21:23:33 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from localhost (localhost [127.0.0.1]) by pi.codefab.com (Postfix) with ESMTP id 98B295F89; Wed, 9 Nov 2005 16:23:32 -0500 (EST) Received: from pi.codefab.com ([127.0.0.1]) by localhost (pi.codefab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 57326-04; Wed, 9 Nov 2005 16:23:31 -0500 (EST) Received: from [199.103.21.238] (pan.codefab.com [199.103.21.238]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by pi.codefab.com (Postfix) with ESMTP id 4AAFC5F7C; Wed, 9 Nov 2005 16:23:31 -0500 (EST) In-Reply-To: <437246C5.2030607@elischer.org> References: <20051108232855.2d1b7df5.lists@yazzy.org> <437145DF.2040508@samsco.org> <20051109093552.3082c51b.lists@yazzy.org> <437246C5.2030607@elischer.org> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1A496451-166E-46F1-8363-19F117156FEE@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Wed, 9 Nov 2005 16:23:28 -0500 To: Julian Elischer X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: amavisd-new at codefab.com Cc: Marcin Jessa , current@freebsd.org Subject: Re: Generic Kernel API X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2005 21:23:34 -0000 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 , 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/