From owner-freebsd-arch Fri Jan 19 6: 5:55 2001 Delivered-To: freebsd-arch@freebsd.org Received: from vega.dmnshq.net (vega.dmnshq.net [194.19.34.94]) by hub.freebsd.org (Postfix) with ESMTP id AAF8737B400; Fri, 19 Jan 2001 06:05:36 -0800 (PST) Received: (from eivind@localhost) by vega.dmnshq.net (8.11.1/8.9.3) id f0JE4wY25435; Fri, 19 Jan 2001 15:04:58 +0100 (CET) (envelope-from eivind) Date: Fri, 19 Jan 2001 15:04:57 +0100 From: Eivind Eklund To: Peter Jeremy Cc: Brian Somers , Sergey Babkin , freebsd-arch@FreeBSD.ORG Subject: Re: cvs commit: src/sys/gnu/i386/isa dgb.c dgm.c dgmreg.h dgreg.h Message-ID: <20010119150457.A18464@thinksec.com> References: <200101052146.f05LkDi49430@hak.lan.Awfulhak.org> <20010111064126.A10214@pc0640.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010111064126.A10214@pc0640.alcatel.com.au>; from peter.jeremy@alcatel.com.au on Thu, Jan 11, 2001 at 06:41:26AM +1100 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Jan 11, 2001 at 06:41:26AM +1100, Peter Jeremy wrote: > On Fri, Jan 05, 2001 at 09:46:13PM +0000, Brian Somers wrote: > >I have the a driver that will replace dgb and dgm and support a bunch > >of other digiboards. Now all I need is the time to add back the > >{E,}ISA probe routines. > > There are come significant differences between the [E]ISA aand PCI > DigiBoards: > - The [E]ISA cards use I/O ports whilst the PCI boards use > memory-mapped registers. > - The PCI cards have a flat 4MB window. The [E]ISA cards access > on-board memory via a 8KB or 32KB window. > > This means that the code does a lot of checking to see if the card > is PCI or not, resulting in expressions like: > ((IS_PCI(board_type)) ? *mem[reg] : inb(base + reg)) > > The Linux driver (maintained by Digi) uses (the equivalent of) virtual > functions for all card accesses. > > Both these approaches add run-time overheads and can adversely affect > code legibility. The technique I've used for similar cases is to do the access through macros, putting the main source in a separate file, and having one "main source" that use the macros, and is included in two separate files that define separate macros. Ie, something like dgb_pci.c: #define GETDATA(mem, base, reg) (*mem[reg]) #include "dbg_main.c" dgb_eisa.c: #define GETDATA(mem, base, reg) inb(base + reg) #include "dgb_main.c" ... with dgb_main.c just using GETDATA() for accesses. (This is just based on the above problem description, not any knowledge of the DigiBoard. And GETDATA is probably not the right name.) Eivind. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message