PCI devmap_devmem_setup, bus-error when reading past 1a000

PCI devmap_devmem_setup, bus-error when reading past 1a000

Post by thinkpeac » Fri, 08 Apr 2005 05:45:52

I have a driver which I created from the PCIbase sample driver for a
working PCI board that I'm porting from Windows
(PCIbase sample: http://www.bolthole.com/solaris/drivers/)

I'm trying to map a memory register on the PCI device into user memory
using devmap(), devmap_devmem_setup() and and mmap().

In the user mode test program, it is able to read 32-bit words from the
mapped memory, but reports a bus error when it gets to address offset
1A000.  This is unexpected since the size of the mapped memory is

In the attach() function of the driver I scan the PCI registers and
record the correct register number and size in the softsate variable.
This all works OK and the driver records the following information.

softstate->hisc_regindex is 2
softstate->hist_memsize = 0x80000;

Below is my driver's devmap function:

int hisc_devmap(dev_t dev, devmap_cookie_t handle, offset_t off, size_t
    size_t *maplen, uint_t model)
        struct hisc_softstate *softstate;
        int    error, rnumber;
        off_t regsize;

        /* Set up data access attribute structure */
        struct ddi_device_acc_attr xx_acc_attr = {
        softstate = ddi_get_soft_state(hisc_glob_soft_handle,
        if (softstate == NULL)
                return (-1);

        /* round up len to a multiple of a page size */
           len = ptob(btopr(len));
        if (off + len > softstate->hisc_memsize)
                return (-1);

        /* Set up the device mapping */
        error = devmap_devmem_setup(handle, softstate->dip, NULL,
                        off, len, PROT_ALL, DEVMAP_DEFAULTS, &xx_acc_attr);

        /* acknowledge the entire range */
        *maplen = len;
        return (error);


And below is the user mode test code snipit:

        hiscRegs = (struct hisc_regs *) mmap(   (caddr_t) 0, len, (PROT_READ |
                                        MAP_SHARED, hiscDevice, 0 );
        if( hiscRegs == MAP_FAILED ){
                printf( "nmap failed: %d\n", errno );
                return 0;

        printf( "hiscDevice maped to address %lX\n", hiscRegs );

        BYTE* pHardware = (BYTE *) hiscRegs;

        DWORD i;
        for( int j=0; j<0x40000; j += 0x400 ){
                printf( "%lX} \n", pHardware + j );
                i = *((DWORD *)(pHardware + j));

Below is the output of the test code:

Bus Error (core dumped)

I also tried mapping and reading the memory within the driver in kernel
mode, and it would hang the system for any offset past 1a000.

Thanks in advance,


1. Q: Reading past error on Tape device

Has anyone had any luck reading past an I/O error on a 9 track tape device
(tg)?  I have tried dd but I do not believe it supports seeking on a tape
device.  Others here have tried using mt with limited results.

Any suggestions or utility recommendations would be appreciated.


Benjamin Bielak Jr.
(Running on: Sequent DYNIX/ptx(R) V2.1.2)

2. Root Security

3. reading past DAT errors during restore

4. bookmark alias

5. Panic: Need program to read past error in tar-tape!

6. curses problem on RS6000

7. SCSI tapes, reading past logical end-of-tape (error recovering)

8. is iproute2-2.4.7-now-ss020116-try safe to use?

9. Linux-2.4.2-ac27 - read on /proc/bus/pci/devices never finishes after rmmod aic7xxx

10. PCI bus vs. S-bus

11. VL-Bus Vs. PCI bus

12. HELP: Netscape 4.05-6 Bus Error (please read!)

13. ddi_get32() causes Bus Error in my PCI device driver