Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jan 2001 15:04:57 +0100
From:      Eivind Eklund <eivind@FreeBSD.ORG>
To:        Peter Jeremy <peter.jeremy@alcatel.com.au>
Cc:        Brian Somers <brian@Awfulhak.org>, Sergey Babkin <babkin@FreeBSD.ORG>, 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>
In-Reply-To: <20010111064126.A10214@pc0640.alcatel.com.au>; from peter.jeremy@alcatel.com.au on Thu, Jan 11, 2001 at 06:41:26AM %2B1100
References:  <babkin@FreeBSD.org> <200101052146.f05LkDi49430@hak.lan.Awfulhak.org> <20010111064126.A10214@pc0640.alcatel.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010119150457.A18464>