Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Nov 2002 19:58:26 +0100 (CET)
From:      Magnus B{ckstr|m <b@etek.chalmers.se>
To:        arch@freebsd.org
Subject:   Proposal: buslib(9)
Message-ID:  <Pine.BSF.4.44.0211131948540.27243-100000@scrooge.etek.chalmers.se>

next in thread | raw e-mail | index | archive | help

Archers,

In response to a JKH task posted by Poul-Henning Kamp, here is my
proposal for a small "bus library".  The intent of the library is to
factor out some commonly occuring code idioms in device drivers.

The problem as stated splits into two parts: One is the allocation and
deallocation of bus resources that every driver performs regardless
of bus type, the other is the bus-specific hopscotch that PCI drivers
do (set the power mode and register access modes, and make up a text
description the device, etc.)  The two parts are practically orthogonal,
and I chose to tackle them one at a time.  So, enter buslib(9) :-)

Check http://www.etek.chalmers.se/~b/buslib/ for preliminary man pages
and patches.

To summarise, using buslib:

    pci/if_xl.c  + pci/if_xlreg.h  shrank by 42 lines
    pci/if_sis.c + pci/if_sisreg.h shrank by 25 lines
    dev/fxp/*                      shrank by 9 lines

Ocular inspection of other drivers lead me to believe these figures
are typical.

Binary code shrinks slightly as well, by some hundred bytes per driver.
xl(4) and fxp(4) survived conversion and work fine, sis(4) compiles but
I have no hardware to test it on.

Converting a driver to use buslib is approximately a 20-minute job.

This is my first attempt at contributing code to FreeBSD; thus comments,
advice, and criticism of (almost) any nature are highly welcome.

Magnus


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.44.0211131948540.27243-100000>