From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 11 14:19:05 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 48F6C16A402 for ; Wed, 11 Apr 2007 14:19:05 +0000 (UTC) (envelope-from craig@tobuj.gank.org) Received: from ion.gank.org (ion.gank.org [69.55.238.164]) by mx1.freebsd.org (Postfix) with ESMTP id 399A113C455 for ; Wed, 11 Apr 2007 14:19:05 +0000 (UTC) (envelope-from craig@tobuj.gank.org) Received: by ion.gank.org (Postfix, from userid 1001) id AC03211143; Wed, 11 Apr 2007 09:02:16 -0500 (CDT) Date: Wed, 11 Apr 2007 09:02:14 -0500 From: Craig Boston To: Alan Garfield Message-ID: <20070411140214.GA60020@nowhere> Mail-Followup-To: Craig Boston , Alan Garfield , takawata@jp.freebsd.org, hackers@freebsd.org References: <200704110951.l3B9p4hT024402@sana.init-main.com> <461CCB3D.1090402@fromorbit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <461CCB3D.1090402@fromorbit.com> User-Agent: Mutt/1.4.2.2i 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: Wed, 11 Apr 2007 14:19:05 -0000 On Wed, Apr 11, 2007 at 09:49:17PM +1000, Alan Garfield wrote: > I've done an acpidump and indeed the are _CRS and _PRS ResourceTemplates > that describe the io and irq requirements perfectly. How do I access > this data? ACPI seems to have very little documentation and nothing else > seems to get resource lists (except fdc_acpi.c and uart_bus_acpi.c which > don't seem to be complete. ACPI_EVALUATE_OBJECT?!?) In general, you're not supposed to. Use bus_alloc_resource and the bus_space_* functions. busdma was introduced in order to make it possible to write device drivers without having to worry about the specifics of resource allocation / access on any given platform. If it seems like magic, that's because it is. :) For PnP busses like PCI, ISAPnP, and ISA-ACPI/LPC-ACPI, the OS takes care of figuring out what resources to use and allocates them. You only need to specify the type (Memory, IO Port, IRQ) that you want and it takes care of whatever needs to be done for the particular architecture and bus your device is attached to. This means that your driver will work regardless if the resources are specified by ACPI, or if in the future if some mad scientist attaches the hardware to the PCI bus on a SPARC64 instead (with only minimal driver changes). Craig