From owner-freebsd-arch Fri Jan 5 14: 2:58 2001 From owner-freebsd-arch@FreeBSD.ORG Fri Jan 5 14:02:56 2001 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mailgate.originative.co.uk (mailgate.originative.co.uk [62.232.68.68]) by hub.freebsd.org (Postfix) with ESMTP id 547E937B400 for ; Fri, 5 Jan 2001 14:02:55 -0800 (PST) Received: from originative.co.uk (tiddler.originative.co.uk [62.232.68.83]) by mailgate.originative.co.uk (Postfix) with ESMTP id 331B61D140; Fri, 5 Jan 2001 22:02:43 +0000 (GMT) Sender: paul@originative.co.uk Message-ID: <3A564532.ADE40E6E@originative.co.uk> Date: Fri, 05 Jan 2001 22:05:38 +0000 From: Paul Richards X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: "Justin T. Gibbs" Cc: freebsd-arch@freebsd.org Subject: Re: Inheritance in new-bus. References: <200101050528.f055SGU00338@caspian.scsiguy.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "Justin T. Gibbs" wrote: > > I've finished a first pass at making cardbus a "sub-class" of pci. > Patches for this have been distributed to a few developers and will > appear hear as soon as I finish the "play by play" for the formal > post to -arch. In doing this work, I ran into several small issues > that I have not resolved to my satisfaction. My hope is that this > forum will have some ideas. > > Method Inheritance > ================== > In my patches, cardbus.c is now 518 lines long. Most of this is > copyright and the method table. Like most "sub-classes", cardbus > need only specialize a few methods of pci. In a true object oriented > environment, you would overload the method and perhaps even call into > the parents implementation of that method as part of implementing > the new method. In new-bus, method tables are constructed by hand. > This means that the cardbus code must fill in the appropriate pci > method in its own table in the case of no-override. When the pci > method table is changed, chances are high that the cardbus method > table will require a similar update. One could imagine devclasses > with the concept of a parent and having kobj handle the magic for > you. This would be difficult to implemement in the case of multiple > parents. Cardbus, for example, will be a subclass of "card services" > at some point. If the method tables were broken down in terms of > distinct interfaces, single inheritance *per interface* would probably > be sufficient. I looked at implementing kobj inheritance while I was working on my talk. My original thinking was that the upcalls could be done away with if a child device inherited its methods from its parent bus, filling in the child's kobj method table with the parent bus' methods. However, when I discussed it with Doug at the conference he didn't see things being related in that way and having spent some time pondering that I can see what he meant. For instance, an ethernet driver may be a child of a PCI device and at the moment it performs upcalls to the PCI card to carry out various functions, but method inheritance based on the device hierarchy wouldn't be correct since an ethernet kobj is in no way a child of a PCI kobj, they're only related because of their physical association. Cardbus on the other hand is related to PCI and so it would make sense to inherit from PCI. So I think that adding inheritance to kobj would be good thing, so that cardbus can inherit from PCI, but it wouldn't be right if inheritance was based on devclasses or on any other aspect of the device hierarchy, particularly since kobj is meant to be a generic OO mechanism rather than a part of newbus. I don't know which particular take on inheritance you've implemented, I wouldn't mind getting a look at the patches :-) Paul. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message