mmap (2) vs. xx_mmap (9E)

mmap (2) vs. xx_mmap (9E)

Post by Endre Bakk » Sat, 02 Dec 2000 04:00:00



What is the relation between the address returned by the mmap (9E) in
the driver, and the address returned by mmap (2) in the user
application?

The reason that I ask is that I have two programs that try to access two
different cards (TrueTime PCI-SG and Adlink PCI-8554 Counter card) by
using mmap (2).  The mmap (2) call returns the same address for both
devices, even though I can see that different addresses are returned by
the xx_mmap (9E) call in the two drivers.

When I access the address returned by mmap (2) for the truetime device,
it works, while the other program results in a Bus error and core dump
when I try to access the address returned by mmap (2) for the counter
device. And I repeat: These two addresses are identical...

Anybody?

- Endre

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

mmap (2) vs. xx_mmap (9E)

Post by Michael Ric » Sun, 03 Dec 2000 10:28:40


The address returned by mmap(2) is a _virtual_ address.  So it is not
surprising that two different applications accessing two different devices
get the same virtual address.  Having not seen your call to mmap, I'm
assuming that you let the system pick the address to which the memory is
mapped.  Given this assumption, if you mmap both devices from the same
application, mmap should (better) return different addresses for each
device.

The bus error indicates that you may be trying to access the device on a
bad/illegal address boundary.  Some devices require access on
8/16/32/64/page byte  boundaries.  Check the documentation for the device.


Quote:> What is the relation between the address returned by the mmap (9E) in
> the driver, and the address returned by mmap (2) in the user
> application?

> The reason that I ask is that I have two programs that try to access two
> different cards (TrueTime PCI-SG and Adlink PCI-8554 Counter card) by
> using mmap (2).  The mmap (2) call returns the same address for both
> devices, even though I can see that different addresses are returned by
> the xx_mmap (9E) call in the two drivers.

> When I access the address returned by mmap (2) for the truetime device,
> it works, while the other program results in a Bus error and core dump
> when I try to access the address returned by mmap (2) for the counter
> device. And I repeat: These two addresses are identical...

> Anybody?

> - Endre

> Sent via Deja.com http://www.deja.com/
> Before you buy.


 
 
 

mmap (2) vs. xx_mmap (9E)

Post by Endre Bakk » Fri, 08 Dec 2000 04:00:00




Quote:> The bus error indicates that you may be trying to access the device on
a
> bad/illegal address boundary.  Some devices require access on
> 8/16/32/64/page byte  boundaries.  Check the documentation for the

device.

I don't think this is the case since this is a very small card with
only 32 consecutive address (32 bits) in the PCI I/O address space.

The frustrating part is that I'm perfectly able to access the registers
in the driver by using ddi_mem_put8 and ddi_mem_get8. But when I try
to access the registers through a mapping in the user application
(read/write), I get the Bus error and core dump.  So I guess the error
is connected to how I export the mapping.

The calls I use:
In xx_attach:
ddi_regs_map_setup(devi, REG_SET2, &softc->counters_ramP,
                   0, COUNTERS_MAP_SIZE, &nosw_attr,
                   &softc->ram_handle)
I am now able to access the registers by ddi_mem_put8 and ddi_mem_get8.

Then in xx_mmap(9E), I return hat_getkpfnum(softc->counters_ramP)
(after checking offset and all that).

In the user application, I map the memory with:
unsigned char * base_addr;
membase = mmap ((caddr_t) 0,  COUNTERS_MEMORY_SIZE,
                (PROT_READ | PROT_WRITE),
                MAP_SHARED, fd, (off_t)0);
base_addr = (unsigned char *)membase;
/* Read */
value = *base_addr; /* This results in a bus error */

Anybody spot any problems here?

- Endre

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. mmap(2): devmap(9E) vs. segmap(9E)

I'm writing a PCI device driver on Solaris 7, and I need to implement
memory mapping. After pouring through all the man pages and Writing
Device Drivers that seemed relevant, I still can't make heads or tail
between devmap(9E) and segmap(9E). Does segmap have more functionality?
Does segmap call devmap, or vice versa? Does one decode an offset, and
the other do the actual mapping?

2. /kernel: Out of mbuf clusters - increase maxusers!

3. mmap /dev/port: byte vs. word vs. dword accesses?

4. PPP - Need to call ISP twice?

5. malloc vs. mmap vs. shmat/shmget

6. MkLinux - does it work for you?

7. speed - read() vs lseek() vs mmap()

8. Linux prompt with $PWD

9. Linux vs OS2 vs NT vs Win95 vs Multics vs PDP11 vs BSD geeks

10. mmap() vs read() performance on Solaris

11. Q: mmap() files in linux vs.data in memory

12. Perfomance: tar vs ftp vs rsync vs cp vs ?

13. MMAP vs. shared memory, which is faster?