Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jan 2001 10:55:52 -0500
From:      "David E. Cross" <crossd@intrepid.cs.rpi.edu>
To:        hackers@freebsd.org
Subject:   Device Driver Question  (bus_set_resource)
Message-ID:  <200101171555.KAA03762@cs.rpi.edu>

next in thread | raw e-mail | index | archive | help
I am writing a simple, I/O only device driver (no lectures about /dev/io
please ;).  It has not PnP abilities, and I have run into the following
problem with bus_set_resource():  

static int das1400adc_isa_probe(device_t dev)
{
        struct das1400adc_softc *sc = device_get_softc(dev);
        int unit = device_get_unit(dev);
        int pnperror;

        sc->dev=dev;
        sc->unit=unit;
        sc->port0=DAS1400ADC_PORT;
        sc->port1=sc->port0+11;
        sc->port2=sc->port0+0x406;
        sc->irq0=0;
        sc->port0_rid=0;
        sc->port1_rid=0;
        sc->port2_rid=0;
        sc->low=sc->high=0;
        
        pnperror=ISA_PNP_PROBE(device_get_parent(dev), dev, das1400adc_pnp_ids);
        if (pnperror != ENXIO)
                return pnperror;

        if (bus_set_resource(dev, SYS_RES_IOPORT, /*rid*/sc->port0_rid,
                sc->port0, 3) < 0)
                return ENXIO;
/*      if (bus_set_resource(dev, SYS_RES_IOPORT, sc->port1_rid,
                sc->port1, 1) < 0)
                return ENXIO;
        if (bus_set_resource(dev, SYS_RES_IOPORT, sc->port2_rid,
                sc->port2, 1) < 0)
                return ENXIO;
*/
        device_set_desc(dev, "CIO-DAS1400-ADC");
        return 0;     /* all is good */
}

static int das1400adc_isa_attach(device_t dev)
{
        struct das1400adc_softc *sc = device_get_softc(dev);

        sc->port0_r = bus_alloc_resource(dev, SYS_RES_IOPORT, 
                        &sc->port0_rid, /*start*/0, /*end*/ ~0, /*count*/ 0,
                        RF_ACTIVE);

/*      sc->port1_r = bus_alloc_resource(dev, SYS_RES_IOPORT,
                        &sc->port1_rid, 0, ~0, 0,
                        RF_ACTIVE);

        sc->port2_r = bus_alloc_resource(dev, SYS_RES_IOPORT,
                        &sc->port2_rid, 0, ~0, 0,
                        RF_ACTIVE);
*/
        if (sc->port0_r == NULL )
/* || sc->port1_r == NULL )
                sc->port2_r == NULL)
*/
                return ENXIO;

        sc->md_dev=make_dev(&das1400adc_cdevsw, 0, 0, 0, 0600, "adc0");
        sc->open_count=0;
        return 0;       
}




Given that code, I get the following attach messages from the kernel:

"das1400adc2: <CIO-DAS1400-ADC> at port 0x310-0x312 irq 5 drq 1,5 on isa0"
Uhm... I set neither the IRQ nor the drq... where does it get these from, and
how can I get it to "do the right thing"?  Also, If I uncomment the settings
for the additional ranges "really weird things" start to happen.  An example
of 'weirdness' is that exact same code, when kldload-ed will attach a totally
different device. 

Oh yeah, this is under 4.2-STABLE from 20010103.

--
David Cross                               | email: crossd@cs.rpi.edu 
Lab Director                              | Rm: 308 Lally Hall
Rensselaer Polytechnic Institute,         | Ph: 518.276.2860            
Department of Computer Science            | Fax: 518.276.4033
I speak only for myself.                  | WinNT:Linux::Linux:FreeBSD


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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