From owner-freebsd-current@FreeBSD.ORG Wed Nov 24 20:47:03 2004 Return-Path: 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 62C1716A4CE for ; Wed, 24 Nov 2004 20:47:03 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id D1FD943D46 for ; Wed, 24 Nov 2004 20:47:02 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from [192.168.254.11] (junior-wifi.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.12.11/8.12.10) with ESMTP id iAOKnx84065160; Wed, 24 Nov 2004 13:50:00 -0700 (MST) (envelope-from scottl@freebsd.org) Message-ID: <41A4F367.9010002@freebsd.org> Date: Wed, 24 Nov 2004 13:47:35 -0700 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.2) Gecko/20040929 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Charles Swiger References: <200411231226.38172.jkim@niksun.com> <200411231343.22760.jhb@FreeBSD.org> <20041124002603.GD20881@squash.dsto.defence.gov.au> <41A416E7.4030107@mac.com> <20041124184124.GA5166@funkthat.com> <88534D8A-3E57-11D9-BD47-003065ABFD92@mac.com> In-Reply-To: <88534D8A-3E57-11D9-BD47-003065ABFD92@mac.com> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=0.0 required=3.8 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on pooker.samsco.org cc: John-Mark Gurney cc: freebsd-current@freebsd.org Subject: Re: Transparent bridges (a. k. a. HUB-to-PCI bridges)? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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, 24 Nov 2004 20:47:03 -0000 Charles Swiger wrote: > On Nov 24, 2004, at 1:41 PM, John-Mark Gurney wrote: > >>> True OOP involves encapsulation, polymorphism, and inheritence, and >>> requires language support which is not really available in pure C. That >>> being said, careful programming in C lets you create several >>> closely-related structs for different types of "objects" which can >>> all be >>> utilized by a common set of functions. >> >> >> You should read up on KOBJ's which is how device_t's are implemented >> in FreeBSD... kobj's are a loop more OOP that you think... > > > OK. I've taken a look at sys/kobj.h and sys/kern/subr_kobj.c, is there > something else I should read? > > My take on it, for what it is worth, is that KOBJs implement the class > versus instance paradigm, have a dynamic runtime & method dispatch > rather similar to the implementation of Objective-C or virtual C++ > methods. Yes, this is a lot more object-oriented than what I said about > being disciplined using C struct's. :-) Right, it's mainly about inheriting and overriding methods from the parent class. There was some work at one time to implement the concept of super(), but that unfortunately didn't go anywhere. It's still quite useful though, especially in the PCI bridge/bus area where there would otherwise be a whole lot of duplicated code. > > Things that one still doesn't have is encapsulation in the sense of data > hiding; what Java calls protected or private ivar's. Object memory > management for instances via reference counting or GC would also be > nice, although I even saw a hint of that in kobj_delete(), as well as a > bit of the alloc/init & delete/free seperation. > The IOKit in Mac OSX uses a stripped-down version of C++ to get real inheritence, polymorphism and public/private/protected data types. It's quite interesting to write a devce driver in this framework; for say a PCI SCSI adapter, you subclass PCI for one class and subclass SCSI for another, then implement the device-specific glue in-between. Scott