Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Apr 2007 00:37:07 +1000
From:      Alan Garfield <alan@fromorbit.com>
To:        Craig Boston <craig@tobuj.gank.org>
Cc:        hackers@freebsd.org
Subject:   Re: Resources and ACPI
Message-ID:  <1176302227.5057.12.camel@hiro.auspc.com.au>
In-Reply-To: <20070411140214.GA60020@nowhere>
References:  <200704110951.l3B9p4hT024402@sana.init-main.com> <461CCB3D.1090402@fromorbit.com>  <20070411140214.GA60020@nowhere>

next in thread | previous in thread | raw e-mail | index | archive | help
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.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1176302227.5057.12.camel>