Map memory from PCI device under QNX RTP

Hi Guys/Gals;
Some of you may remember that I was asking info about reading and
writing to PCI cards under QNX RTP. Well with the info I received from this
group I am successfully reading and writing to our in house PCI card. So I
thought that I would repay the favor…The biggest difficulty that I ran
into was how to map memory from our device. I looked through the online docs
under MMAP and found that under QNX RTP it is recommended that you use
mmap_device_memory. I found that there were a few options missing from the
function prototype information, the MAP_PHYS and MAP_SHARED flags seem to be
missing. After much digging on the online help I decided to search under PCI
and then look at hardware IO, that’s where I found the info. This wasted a
couple of hours of time so I thought that I would pass it along to the
group. Anyway this is what my mmap_device_ memory call looks like:

aperture1=mmap_device_memory(NULL,0x800000,
PROT_READ | PROT_WRITE | PROT_NOCACHE, MAP_SHARED | MAP_PHYS,
info.CpuBaseAddress[2]);

Chris Fought <cfought@systran.com> wrote:

Hi Guys/Gals;
Some of you may remember that I was asking info about reading and
writing to PCI cards under QNX RTP. Well with the info I received from this
group I am successfully reading and writing to our in house PCI card. So I
thought that I would repay the favor…The biggest difficulty that I ran
into was how to map memory from our device. I looked through the online docs
under MMAP and found that under QNX RTP it is recommended that you use
mmap_device_memory. I found that there were a few options missing from the
function prototype information, the MAP_PHYS and MAP_SHARED flags seem to be
missing. After much digging on the online help I decided to search under PCI
and then look at hardware IO, that’s where I found the info. This wasted a
couple of hours of time so I thought that I would pass it along to the
group. Anyway this is what my mmap_device_ memory call looks like:

aperture1=mmap_device_memory(NULL,0x800000,
PROT_READ | PROT_WRITE | PROT_NOCACHE, MAP_SHARED | MAP_PHYS,
info.CpuBaseAddress[2]);

Thanks for your help. I’ll update the docs accordingly.
-Donna

Chris Fought <cfought@systran.com> wrote:

Hi Guys/Gals;
Some of you may remember that I was asking info about reading and
writing to PCI cards under QNX RTP. Well with the info I received from this
group I am successfully reading and writing to our in house PCI card. So I
thought that I would repay the favor…The biggest difficulty that I ran
into was how to map memory from our device. I looked through the online docs
under MMAP and found that under QNX RTP it is recommended that you use
mmap_device_memory. I found that there were a few options missing from the
function prototype information, the MAP_PHYS and MAP_SHARED flags seem to be
missing. After much digging on the online help I decided to search under PCI
and then look at hardware IO, that’s where I found the info. This wasted a
couple of hours of time so I thought that I would pass it along to the
group. Anyway this is what my mmap_device_ memory call looks like:

aperture1=mmap_device_memory(NULL,0x800000,
PROT_READ | PROT_WRITE | PROT_NOCACHE, MAP_SHARED | MAP_PHYS,
info.CpuBaseAddress[2]);

I knew this sounded familiar… the mmap() and mmap_device_memory()
functions were updated and reformatted at the end of November.
Unfortunately, that version of the docs haven’t hit the streets yet.
Further, since the reformatting occurred after a copy of the docs were
taken for Patch A, you won’t find the updates in there either.
When Patch A hits the streets, I’ll update the online docs
in the QDN (so the online docs will be newer than what’s in the patch).


The following information had been added to the
flags description in mmap_device_memory():

This function already uses MAP_SHARED ORed with MAP_PHYS
(see mmap() for a description of these flags).



And the following example was also added:

/* map in the physical memory, 0xb8000 is text mode VGA video memory */

ptr = mmap_device_memory( 0, len, PROT_READ|PROT_WRITE|PROT_NOCACHE, 0, 0xb8000 );
if ( ptr == MAP_FAILED ) {
perror( “mmap_device_memory for physical address 0xb8000 failed” );
exit( EXIT_FAILURE );
}


Thanks for your posting. Please continue to let us know of any other
run-arounds that you find in the docs… we’ll try to fix them too!

-Donna

“Chris Fought” <cfought@systran.com> wrote in message
news:93v1uo$1uv$1@inn.qnx.com

Well with the info I received from this
group I am successfully reading and writing to our in house PCI card.

Chris,

What processor/board are you using? I am having a lot of trouble getting a
compact PCI board to run on the MCP750 PowerPC based board. I have code
which works on an Intel X86 PC using mmap_device_memory() and
mmap_device_io() plus a combination of memory access and in/out calls from
hw/inout.h and I am using similar options to yourself. The manual implies
this code should be platform independent. However when I move to the PPC box
and cross compile the same code fails to work. It is as if it never maps the
correct addresses into physical memory even though the call returns
successfully (or alternatively it is not mapping the PCI memory into the
area).

Does anyone have a working PCI card driver for QNX RTP PPC I could compare
to mine or clues as to what may be required?

Thanks,

James

james@socrates.demon.co.uk