From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 12 03:03:12 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D63CF16A401 for ; Thu, 12 Apr 2007 03:03:12 +0000 (UTC) (envelope-from alan@fromorbit.com) Received: from thing1.auspcmarket.com.au (mail.fromorbit.com [203.31.169.65]) by mx1.freebsd.org (Postfix) with ESMTP id 9C26413C465 for ; Thu, 12 Apr 2007 03:03:12 +0000 (UTC) (envelope-from alan@fromorbit.com) Received: from [192.168.1.99] (unknown [192.168.1.99]) by thing1.auspcmarket.com.au (Postfix) with ESMTP id 416365C76; Thu, 12 Apr 2007 13:03:07 +1000 (EST) From: Alan Garfield To: Craig Boston In-Reply-To: <20070411164050.GD60020@nowhere> References: <200704110951.l3B9p4hT024402@sana.init-main.com> <461CCB3D.1090402@fromorbit.com> <20070411140214.GA60020@nowhere> <1176302227.5057.12.camel@hiro.auspc.com.au> <20070411153703.GC60020@nowhere> <1176308551.5949.7.camel@hiro.auspc.com.au> <20070411164050.GD60020@nowhere> Content-Type: text/plain Date: Thu, 12 Apr 2007 13:03:07 +1000 Message-Id: <1176346987.4175.2.camel@hiro.auspc.com.au> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) Content-Transfer-Encoding: 7bit Cc: hackers@freebsd.org Subject: Re: Resources and ACPI X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2007 03:03:12 -0000 On Wed, 2007-04-11 at 11:40 -0500, Craig Boston wrote: > Looking back at the thread I see that you're porting a Linux driver, > that explains a lot of the confusion. It's been a while since I've > worked with the Linux kernel in depth, but I seem to remember that a lot > of drivers (especially machine-specific ones) would get the resource > directly, e.g. IO port base address, and then do stuff like > > outb(base_addr + offset, value); > value = inb(base_addr + offset); > > or write to mapped memory directly by constructing a pointer to the > address. Indeed mapped memory is how this is driver is written. > While doing this is possible in FreeBSD, it's discouraged as the > bus_space API tends to make for cleaner code and is also more portable. > On architectures with peculiar alignment requirements, or other > restrictions (DMA buffers having to be below a particular address comes > to mind, or bounce buffers for PAE), the OS will take care of most of > the nitty gritty details for you and allow the driver to contain > higher-level code. Yes bus_space seems much nicer, and very useful I'm sure for platform independence. Cheers, Alan.