Help with mmap PCI please

Neal Becker (neal@ctd.comsat.com)
27 Feb 1998 16:16:17 -0500


I am trying to write a user-level "device driver" which is using mmap
to access a device on the PCI bus. The device is an MPEG Encoder chip
we are working with.

I am trying to write to the device, which should appear memory-mapped
on the PCI bus.

cat /proc/pci
PCI devices found:
Bus 0, device 15, function 0:
Multimedia controller: Unknown vendor Unknown device (rev 1).
Vendor id=123f. Device id=e4.
Medium devsel. IRQ 11. Master Capable. Latency=64. Min Gnt=16.Max Lat=1.
Prefetchable 32 bit memory at 0xfb000000.

I assume that this means that the base address on the PCI bus for my
device has been configured to 0xfb000000.

I did this:

if((poe_mem = valloc(POE_SIZE )) == NULL) {
printf("Loader: allocation error \n");
return(FAIL);
}

/* Map the POE memory into the user memory space */

if((poe_mem = mmap(poe_mem,
POE_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_FIXED,
mem_fd,
poe_base_adr))
== -1) {
lderr_hdlr("poe_mem_map: mmap error \n");
return(FAIL);
}

where poe_base_adr = 0xfb000000, which is what I read from /proc/pci
above as the base address of the device.

Now I try to access the device using e.g.,

poe_mem[0] = xxx.

It doesn't seem to work (locks the machine).

Any ideas greatly appreciated.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu