Hi ,
I'm trying to write some driver code for a memory mapped device (PCI bus).

        struct xxx_softc *sc = device_get_softc(dev);
        struct resource *res;

 /*
  * Map control/status registers.
  */
        command = pci_read_config(dev, PCIR_COMMAND, 4);
        command |= (PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
        pci_write_config(dev, PCIR_COMMAND, command, 4);
        command = pci_read_config(dev, PCIR_COMMAND, 4);

        if (!(command & PCIM_CMD_MEMEN)) {
                printf("xxx%d: failed to enable memory mapping!\n", unit);
                error = ENXIO;
                goto fail;
        }
        else
                printf("xxx%d: memory mapping enabled\n", unit);

        mem_rid = 0x10;
        res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
                                 0ul, ~0ul, size, RF_ACTIVE);

I've been able to probe the device correctly, get the IRQ resource allocated
correctly etc, I don't get any errors in this mapping enable and alloc code
either. But when I try accessing the device I don't get the correct results
(can't get to the eeprom, and can't access correct values from the register
offsets.

        u_int32_t s = bus_space_read_4(sc->btag, sc->bhandle, REGISTER_OFFSET);

The device is basically a Cardbus card attached to the freebsd 4.3 PCI bus
through a Cardbus/PCI extender card.

I don't know exactly why it couldn't be working here. Is it the problem with
the mapping, or is it with the device, or with the freeBSD mechanism? I'm a
newbie so please excuse me if I'm posting this at the wrong forum and let me
know the right place to go to.

Thanks in advance
A


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to