From owner-freebsd-arch Wed Jan 10 19:23:22 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mobile.wemm.org (c1315225-a.plstn1.sfba.home.com [65.0.135.147]) by hub.freebsd.org (Postfix) with ESMTP id F28EB37B400; Wed, 10 Jan 2001 19:23:04 -0800 (PST) Received: from netplex.com.au (localhost [127.0.0.1]) by mobile.wemm.org (8.11.1/8.11.1) with ESMTP id f0B3N4Q64114; Wed, 10 Jan 2001 19:23:04 -0800 (PST) (envelope-from peter@netplex.com.au) Message-Id: <200101110323.f0B3N4Q64114@mobile.wemm.org> X-Mailer: exmh version 2.2 06/23/2000 with nmh-1.0.4 To: Mike Smith Cc: Jonathan Lemon , Peter Jeremy , Sergey Babkin , freebsd-arch@FreeBSD.ORG Subject: Re: cvs commit: src/sys/gnu/i386/isa dgb.c dgm.c dgmreg.h dgreg.h In-Reply-To: <200101110116.f0B1G8f00436@mass.osd.bsdi.com> Date: Wed, 10 Jan 2001 19:23:04 -0800 From: Peter Wemm Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Mike Smith wrote: > > > > 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)) > > > > > > This should be taken care of by the bus_space() macros; which is > > > already done by most drivers in the tree. (Many drivers can run > > > in either PIO or memory mapped mode) > > > > But the bus_space_() stuff doesn't handle changing register windows etc. > > eg: if you have a 64K memory space and can read/write it directly when > > memory mapped, but when on ISA it is all crammed into 16 lots of 4K windows > > then bus_space_() cannot save you from this. > > > > ie: > > if (IS_PCI(board_type)) { > > value = *mem[reg]; > > } else { > > if (board->window != window(reg)) > > board->window = window(reg); > > value = inb(base + (reg % winsize)); > > } > > Typically, if you have half a clue, you will separate the ISA-aware parts > of the driver from the PCI-aware parts and use a set of function vectors. > Makes for much cleaner code. 8) Yes, that is what Peter Jeremy said in the original email.. It can be done but doesn't come for free. I was merely responding to the suggestion to use the bus_space_ macros with a reason why they cannot be used in this scenario to hide the different access methods. Yes, bus_space can be used in the backend functions, but not at the top level driver. Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message