mmap questions

I’m writing a program under QNX 6.1a on an AMD Elan 520 cpu. This cpu has a
large table of read/write data that I need to access at memory address
0xEF00 (for AMD folks it’s the MMCR control register table). I have tried
many combinations of mmap() and mmap_device_memory() to get a pointer to
this table, but regardless of what I do I am getting back bogus data. When
I read consecutive bytes of the table it merely increments such as
[40,41,42,43,44,45,…] which is… wrong.

My current implementation looks something like this (although I’ve tried a
lot of combos):

ptr = (unsigned char *) mmap( 0, 0x1000, PROT_READ|PROT_WRITE,
MAP_PHYS|MAP_SHARED, NOFD, 0xef00 );

The function returns successfully but grabbing data with “AByte = *ptr;”
simply isn’t working.

Ideas anyone?

Thanks,

Jason Farque’

I do the same (but with different HW) with this command:

void *ptr;
ptr = mmap_device_memory(0, 0x1000, PROT_READ | PROT_WRITE | PROT_NOCACHE,
0, 0xef00);

Pavol Kycina

“Jason Farque” <jasonf@pigging.com> wrote in message
news:a32tak$hvv$1@inn.qnx.com

I’m writing a program under QNX 6.1a on an AMD Elan 520 cpu. This cpu has
a
large table of read/write data that I need to access at memory address
0xEF00 (for AMD folks it’s the MMCR control register table). I have tried
many combinations of mmap() and mmap_device_memory() to get a pointer to
this table, but regardless of what I do I am getting back bogus data.
When
I read consecutive bytes of the table it merely increments such as
[40,41,42,43,44,45,…] which is… wrong.

My current implementation looks something like this (although I’ve tried a
lot of combos):

ptr = (unsigned char *) mmap( 0, 0x1000, PROT_READ|PROT_WRITE,
MAP_PHYS|MAP_SHARED, NOFD, 0xef00 );

The function returns successfully but grabbing data with “AByte = *ptr;”
simply isn’t working.

Ideas anyone?

Thanks,

Jason Farque’

Pavol,

Thanks for the response, but your command is giving me the same results.
I’m reading the CBAR I/O register with in32() which should return the offset
of the MMCR in my system. That number is 0xEF000. According to an AMD
example I have that number then needs to be shifted right 4 bits (i.e. ptr

= 4;) which yields 0xEF00 as the address of my MMCR table (which sounds
plausible). However, using the mmap() functions I can’t seem to retrieve

sane results from this address.

Could you please cut and paste your code to read the CBAR and derive the
table pointer? I’d be most grateful.

Jason

“Pavol Kycina” <kycina@microstep-hdo.sk> wrote in message
news:3c550ba1$1@asrpx.mshdo

I do the same (but with different HW) with this command:

void *ptr;
ptr = mmap_device_memory(0, 0x1000, PROT_READ | PROT_WRITE | PROT_NOCACHE,
0, 0xef00);

Pavol Kycina

“Jason Farque” <> jasonf@pigging.com> > wrote in message
news:a32tak$hvv$> 1@inn.qnx.com> …
I’m writing a program under QNX 6.1a on an AMD Elan 520 cpu. This cpu
has
a
large table of read/write data that I need to access at memory address
0xEF00 (for AMD folks it’s the MMCR control register table). I have
tried
many combinations of mmap() and mmap_device_memory() to get a pointer to
this table, but regardless of what I do I am getting back bogus data.
When
I read consecutive bytes of the table it merely increments such as
[40,41,42,43,44,45,…] which is… wrong.

My current implementation looks something like this (although I’ve tried
a
lot of combos):

ptr = (unsigned char *) mmap( 0, 0x1000, PROT_READ|PROT_WRITE,
MAP_PHYS|MAP_SHARED, NOFD, 0xef00 );

The function returns successfully but grabbing data with “AByte = *ptr;”
simply isn’t working.

Ideas anyone?

Thanks,

Jason Farque’

\