Re: Transparent bridges (a. k. a. HUB-to-PCI bridges)?

From: Scott Long <scottl_at_freebsd.org>
Date: Wed, 24 Nov 2004 13:47:35 -0700
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
Received on Wed Nov 24 2004 - 19:47:03 UTC

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