From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 11 14:37:09 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 DFA6B16A404 for ; Wed, 11 Apr 2007 14:37:09 +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 AA89813C48A for ; Wed, 11 Apr 2007 14:37:09 +0000 (UTC) (envelope-from alan@fromorbit.com) Received: from [192.168.1.99] (c220-239-255-86.rivrw3.nsw.optusnet.com.au [220.239.255.86]) by thing1.auspcmarket.com.au (Postfix) with ESMTP id 368C35C19; Thu, 12 Apr 2007 00:37:08 +1000 (EST) From: Alan Garfield To: Craig Boston In-Reply-To: <20070411140214.GA60020@nowhere> References: <200704110951.l3B9p4hT024402@sana.init-main.com> <461CCB3D.1090402@fromorbit.com> <20070411140214.GA60020@nowhere> Content-Type: text/plain Date: Thu, 12 Apr 2007 00:37:07 +1000 Message-Id: <1176302227.5057.12.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: Wed, 11 Apr 2007 14:37:10 -0000 On Wed, 2007-04-11 at 09:02 -0500, Craig Boston wrote: > 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). Ok now I'm thoroughly confused! :) I've got a very machine specific device (eg. it's built into the PRS controller on the motherboard) so I don't think I have to worry about machine independence. At the moment I've got the io ports and irq's being hardcoded into the driver, which seems icky to me. The acpi bus when the device is attached outputs all the appropriate resources so _something_ knows what they are. All I want is a way to access them and to know what they are. Do I use bus_space_* to do this? Or is it simply the rid I pass to bus_alloc_resource_any that gets my io ports and irq's? At the moment I'm doing :- ---- // Allocate io resources for(i = 0; i < IO_MAX; i++) { if(sc->io[i] == NULL) { sc->io_rid[i] = i; sc->io[i] = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->io_rid[i], jnet_io_ports[i].addr, jnet_io_ports[i].addr, 1, RF_ACTIVE); if(sc->io[i] == NULL) { device_printf(dev, "can't allocate io port %x - %s\n", jnet_io_ports[i].addr, jnet_io_ports[i].desc); return (ENOSPC); } sc->io_allocated[i] = 0; } } // Allocate irq resource if(sc->irq == NULL) { sc->irq_rid = 0; sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid, JNET_IRQ, JNET_IRQ, 1, RF_ACTIVE); if(sc->irq == NULL) { device_printf(dev, "can't allocate irq %02i\n", JNET_IRQ); return (ENOSPC); } sc->irq_allocated = 0; } ---- How do I know which io port/irq I get when I use bus_alloc_resource_any? I should be able to get to the resources the acpi bus lists in dmesg without hard-coding them in the driver surely. I know I'm probably missing something completely obvious! Many thanks in advance. Alan.