Accessing ISA Memory under RTP vs 4.0? (mmap_device_memory)

I posted this question (re-phrased) under qdn.public.porting. I believe
this may be a better area for it, however.

I am trying to read an 512 block of RAM off a custom ISA card under QNX RTP.
I have code that works under QNX 4.0, and on the same machine, I have code
that I believe should work for RTP. However it doesn’t. The code for both
RTP and 4.0 are at the end of this message.

The ram locations have been hardcoded (for testing) to 1’s, except for
location 20 and 21 inside the RAM block should be 42. It works under QNX
4.0 fine. Under RTP almost the entire 512 bytes are 0’s, except for the
last 15 bytes which are sets of three in the following order: 75, 255, 217,
157, and 63. The rest of memory seems to be filled with numbers that repeat
3 times in a row.

In the rest of the ram that my RTP code searches around the pointer to the
RAM, there are no 1’s or 42’s. (This tells me that the mapping did not

I am hoping for suggestions on how to fix my code under RTP (or even
suggestions to try), different ways to read the RAM instead of using
mmap_device_memory, or ideas on how to debug the problem. Should I change
what the hardware stores and watch to see if memory changes? Do I need to
say any magic words so my process can actually access the hardware?

I would greatly appreciate any further help on solving this issue!
Thank you!

Here is the QNX 4.0 Code:

#include <stdio.h>
#include <i86.h>

int main()
int index =0;
unsigned int Card_base = 0;
volatile unsigned char _far *cp = NULL;

printf(“Starting QNX 4.25 HW Tester.\n”);

Card_base = qnx_segment_overlay ( 0xaf000, 512);
cp = MK_FP(Card_base, 0x000);

printf(“Card_base=%x, cp=%x\n”, Card_base, cp);

for (index = 0; index < 512; index++)
printf("%i = %u \t\n", index, (unsigned char) cp[index]);

return 0;

Under RTP, I am trying:
#include <stdio.h>
#include <sys/mman.h>
#include <assert.h>

#define KToSearch 30

int main()
int index = 0;
volatile unsigned char *cp;

// Open Memory Map:
cp = mmap_device_memory(
NULL, // Start address (Don’t care)
512, // Length
0, // Flags. Have also tried MAP_PHYS|MAP_SHARED,
0xAF000); // Physical Address

assert(cp != MAP_FAILED);

// Verify memory by reading back from it.
for (index = 0; index < 1024*KToSearch; index++)
printf(“At %u = %u\t”, index, cp[index]);

return 0;