[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
[rtl] How to Access memory Mapped PCI cards from rtlinux
I've been accessing a Gage CS8500 waveform digitizer from "normal" linux
root priv'ed programs for a while now by using mmap. It works very
nicely.
I've been working on accessing it from our rtlinux interrupt handler the
last few days and it too is working very nicely. The key element to
mapping PCI space into kernel space is the vremap() function. You must
call call it, or else things will crash.
Here's that part of my init procedure:
int init_module(void)
{
int rv,i;
char *p;
dig_ram = (char *)GAGE_8500_BA2; // digitizer ram address
vdig_ram = (char *)NULL; // returned by vremap
dig_ram_sz = GAGE_8500_RAM_SIZE; // dig ram size
dig_cpic = GAGE_8500_BA3; // dig I/O address
//*******************************************************
// call vremap to enable access to PCI card ram buffer
// It crashes the system hard if you don't call vremap
// Can't talk to the pci ram until after this is done
//*******************************************************
vdig_ram = vremap( dig_ram, dig_ram_sz );
... ...
Once this is done, you simply use vdig_ram as a pointer into the newly
mapped space. After you're done, you need to call:
vfree( vdig_ram);
in your cleanup procedure, or a vremap "memory leak" of sorts will occur
on the returned mapped pointers. I don't know if they are a limited
resource, but I suspect so.
As it stands right now, I've mapped in the PCI card's memory, mapped in
3mb at the top of linux, and have it all playing together nicely.
Some of the source code is at
http://aol11.wff.nasa.gov/sra/src/
The source for the beginnings of this PCI driver are there in sra_irq.c
and several PIC assembly programs which cooperate with the Linux code.
Kind regards,
C. Wayne Wright
--- [rtl] ---
For more information on Real-Time Linux see:
http://rtlinux.cs.nmt.edu/