From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 11 09:51:33 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 B979216A400 for ; Wed, 11 Apr 2007 09:51:33 +0000 (UTC) (envelope-from takawata@init-main.com) Received: from sana.init-main.com (104.194.138.210.bn.2iij.net [210.138.194.104]) by mx1.freebsd.org (Postfix) with ESMTP id 5714C13C465 for ; Wed, 11 Apr 2007 09:51:33 +0000 (UTC) (envelope-from takawata@init-main.com) Received: from ns.init-main.com (localhost [127.0.0.1]) by sana.init-main.com (8.13.8/8.13.8) with ESMTP id l3B9p4hT024402; Wed, 11 Apr 2007 18:51:04 +0900 (JST) (envelope-from takawata@ns.init-main.com) Message-Id: <200704110951.l3B9p4hT024402@sana.init-main.com> To: Alan Garfield From: takawata@jp.freebsd.org In-reply-to: Your message of "Wed, 11 Apr 2007 19:05:33 +1000." <1176282333.4134.4.camel@hiro.auspc.com.au> Date: Wed, 11 Apr 2007 18:51:04 +0900 Sender: takawata@init-main.com 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 09:51:33 -0000 In message <1176282333.4134.4.camel@hiro.auspc.com.au>, wrote: >Hi all, > >When you have say :- > >---- >static int >jnet_probe(device_t >dev) > >{ > static char *jnet_ids[] = { "NWS8001", >NULL }; > > > if (acpi_disabled("jnet") >|| > > ACPI_ID_PROBE(device_get_parent(dev), dev, >jnet_ids) == NULL) > return (ENXIO); > > // Woo we found it, set the description s we know what we >are. > device_set_desc(dev, "JNet Ethernet System >Interface"); > > return (BUS_PROBE_DEFAULT); >} >---- > >and when the device is kldload'ed you get :- > >---- >jnet0: port 0xa8,0xae-0xaf irq 19 on >acpi0 >---- > >are these resources automagically allocated for me? Or do I have to >allocate them myself? You have to allocate the resource. >I've got my driver mostly working but at the moment I've hard-coded in >the resources and I'm thinking this isn't correct given the acpi bus >knows what resources I'm expecting and lists them helpfully in the dmesg >output. > >If the resources are allocated how do I access/see them? sc->sc_rid1 = 0; sc->sc_res1 = bus_alloc_resource_any(self, SYS_RES_IOPORT, &sc->sc_rid, RF_ACTIVE); sc->sc_rid2 = 0; sc->sc_res2 = bus_alloc_resource_any(self, SYS_RES_IOPORT, &sc->sc_rid, RF_ACTIVE); value_af = bus_space_read_8(rman_get_bustag(sc->sc_res2), rman_get_bushandle(sc->sc_res2), 1); >I've been all through device_t and bus.h this and acpi.h that, and I >cannot find a good example of getting resources from the acpi bus. It is almost same as ISA-PnP aware device driver for devices that requires I/O port resources.