From owner-freebsd-arch Wed Nov 13 10:58:39 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 67F0137B401 for ; Wed, 13 Nov 2002 10:58:38 -0800 (PST) Received: from scrooge.etek.chalmers.se (scrooge.etek.chalmers.se [129.16.32.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id B4B5743E91 for ; Wed, 13 Nov 2002 10:58:35 -0800 (PST) (envelope-from b@etek.chalmers.se) Received: from scrooge.etek.chalmers.se (b@localhost [127.0.0.1]) by scrooge.etek.chalmers.se (8.12.3/8.12.3) with ESMTP id gADIwR9E027614 for ; Wed, 13 Nov 2002 19:58:27 +0100 (CET) (envelope-from b@etek.chalmers.se) Received: from localhost (b@localhost) by scrooge.etek.chalmers.se (8.12.3/8.12.3/Submit) with ESMTP id gADIwQHi027611 for ; Wed, 13 Nov 2002 19:58:27 +0100 (CET) X-Authentication-Warning: scrooge.etek.chalmers.se: b owned process doing -bs Date: Wed, 13 Nov 2002 19:58:26 +0100 (CET) From: Magnus B{ckstr|m To: arch@freebsd.org Subject: Proposal: buslib(9) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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