ISA Memory access (Use mmap_device_memory?)

Hi,

I am attempting to access 256 bytes of memory on a custom built ISA card
under QNX RTP. The physical memory address is 0xAF000 through 0xAF0FF.

We have existing code for QNX4 to access the ram as follows:

extern unsigned char __far *cp;
unsigned Card_base;

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

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;

// Read from ram
for (i=0;i<256;i++)
data = *(cp + i);



Under RTP, this is my best shot at the code:

unsigned char *cp;
cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,
MAP_PHYS | MAP_PRIVATE, 0xaf000);
assert(cp != MAP_FAILED);

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;

// Read from ram
for (i=0;i<256;i++)
data = *(cp + i);

However, this does not work. When the card is not plugged in, I can access
the ram (read and write to it), but it is obviously not the ISA card’s ram
(as it is not plugged in!). Under QNX4, it returns 255 (no matter what is
written) when the card is not plugged in. If the card is plugged in, I get
garbage back (mainly 0’s, some 168’s, and a few 255’s).

One value of the hardware’s RAM is hardcoded to 42 and this value does not
appear in the virtual address space that I can access from the “cp” pointer.
The address I am given back (cp) is always 0x40100000. I am able to access
nearly the next 4K of memory, and none of it is 42 (which tells me that I
have not correctly mapped the card’s RAM into virtual ram).

Is this the correct way to access RAM off an ISA card? What else do I need
to do?

Do I need to use mem_offset? However, the Migration Guide documentation
implies it is only needed for DMA access.

Thank you for any help you may offer!

Brian Fraser
(University Student, Simon Fraser University, Canada).

“Brian Fraser” <jasperwebster@netscape.net> wrote in message
news:99rqot$i54$1@inn.qnx.com

Hi,

I am attempting to access 256 bytes of memory on a custom built ISA card
under QNX RTP. The physical memory address is 0xAF000 through 0xAF0FF.

We have existing code for QNX4 to access the ram as follows:

extern unsigned char __far *cp;
unsigned Card_base;

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

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);



Under RTP, this is my best shot at the code:

unsigned char *cp;
cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,
MAP_PHYS | MAP_PRIVATE, 0xaf000);
assert(cp != MAP_FAILED);

Hum this should work: Try:

volatile unsigned char *cp;

cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,0,0xaf000);

assert(cp != MAP_FAILED);

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;
cp > = i ; // looks better > :wink:

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);
data > = cp> ; // looks better as well -)




However, this does not work. When the card is not plugged in, I can
access
the ram (read and write to it), but it is obviously not the ISA card’s ram
(as it is not plugged in!). Under QNX4, it returns 255 (no matter what is
written) when the card is not plugged in. If the card is plugged in, I
get
garbage back (mainly 0’s, some 168’s, and a few 255’s).

I’m assuming you are testing QNX4 and QNX6 on the same computer?

One value of the hardware’s RAM is hardcoded to 42 and this value does not
appear in the virtual address space that I can access from the “cp”
pointer.
The address I am given back (cp) is always 0x40100000. I am able to
access
nearly the next 4K of memory, and none of it is 42 (which tells me that I
have not correctly mapped the card’s RAM into virtual ram).

Is this the correct way to access RAM off an ISA card? What else do I
need
to do?

Do I need to use mem_offset? However, the Migration Guide documentation
implies it is only needed for DMA access.

Thank you for any help you may offer!

Brian Fraser
(University Student, Simon Fraser University, Canada).

Hi,

I tried the code you suggested, and got the same response back from the
hardware: All zeros. I changed the hardware configureation to return all
42’s (VHDL) and it works correctly under QNX 4, but only get back zeros
under RTP.

I am using the same machine for my RPT development as for the testing of the
existing code under QNX 4.

Are there any other ways to access the memory other than
mmap_device_memory() (and other than mmap… which is all the same stuff, is
it not?)

Thank you again!
Brian.



“Mario Charest” <mcharest@void_zinformatic.com> wrote in message
news:99spk8$dd5$1@nntp.qnx.com

“Brian Fraser” <> jasperwebster@netscape.net> > wrote in message
news:99rqot$i54$> 1@inn.qnx.com> …
Hi,

I am attempting to access 256 bytes of memory on a custom built ISA card
under QNX RTP. The physical memory address is 0xAF000 through 0xAF0FF.

We have existing code for QNX4 to access the ram as follows:

extern unsigned char __far *cp;
unsigned Card_base;

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

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);



Under RTP, this is my best shot at the code:

unsigned char *cp;
cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,
MAP_PHYS | MAP_PRIVATE, 0xaf000);
assert(cp != MAP_FAILED);

Hum this should work: Try:

volatile unsigned char *cp;

cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,0,0xaf000);

assert(cp != MAP_FAILED);

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;
cp > = i ; // looks better > :wink:

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);
data > = cp> ; // looks better as well -)


However, this does not work. When the card is not plugged in, I can
access
the ram (read and write to it), but it is obviously not the ISA card’s
ram
(as it is not plugged in!). Under QNX4, it returns 255 (no matter what
is
written) when the card is not plugged in. If the card is plugged in, I
get
garbage back (mainly 0’s, some 168’s, and a few 255’s).


I’m assuming you are testing QNX4 and QNX6 on the same computer?

One value of the hardware’s RAM is hardcoded to 42 and this value does
not
appear in the virtual address space that I can access from the “cp”
pointer.
The address I am given back (cp) is always 0x40100000. I am able to
access
nearly the next 4K of memory, and none of it is 42 (which tells me that
I
have not correctly mapped the card’s RAM into virtual ram).

Is this the correct way to access RAM off an ISA card? What else do I
need
to do?

Do I need to use mem_offset? However, the Migration Guide documentation
implies it is only needed for DMA access.

Thank you for any help you may offer!

Brian Fraser
(University Student, Simon Fraser University, Canada).

\

“Brian Fraser” <jasperwebster@netscape.net> wrote in message
news:99tqpi$bu1$1@inn.qnx.com

Hi,

I tried the code you suggested, and got the same response back from the
hardware: All zeros. I changed the hardware configureation to return all
42’s (VHDL) and it works correctly under QNX 4, but only get back zeros
under RTP.

To rule out your code or the build environment;
Use spatch and open /dev/mem to read the memory.
The Next option in the menu doesn’t work (always come
back to index 0) so used the Goto option instead.

I am using the same machine for my RPT development as for the testing of
the
existing code under QNX 4.

Are there any other ways to access the memory other than
mmap_device_memory() (and other than mmap… which is all the same stuff,
is
it not?)

Not to my knowledge.

Thank you again!
Brian.



“Mario Charest” <mcharest@void_zinformatic.com> wrote in message
news:99spk8$dd5$> 1@nntp.qnx.com> …

“Brian Fraser” <> jasperwebster@netscape.net> > wrote in message
news:99rqot$i54$> 1@inn.qnx.com> …
Hi,

I am attempting to access 256 bytes of memory on a custom built ISA
card
under QNX RTP. The physical memory address is 0xAF000 through
0xAF0FF.

We have existing code for QNX4 to access the ram as follows:

extern unsigned char __far *cp;
unsigned Card_base;

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

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);



Under RTP, this is my best shot at the code:

unsigned char *cp;
cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,
MAP_PHYS | MAP_PRIVATE, 0xaf000);
assert(cp != MAP_FAILED);

Hum this should work: Try:

volatile unsigned char *cp;

cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,0,0xaf000);

assert(cp != MAP_FAILED);

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;
cp > = i ; // looks better > :wink:

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);
data > = cp> ; // looks better as well -)


However, this does not work. When the card is not plugged in, I can
access
the ram (read and write to it), but it is obviously not the ISA card’s
ram
(as it is not plugged in!). Under QNX4, it returns 255 (no matter
what
is
written) when the card is not plugged in. If the card is plugged in,
I
get
garbage back (mainly 0’s, some 168’s, and a few 255’s).


I’m assuming you are testing QNX4 and QNX6 on the same computer?

One value of the hardware’s RAM is hardcoded to 42 and this value does
not
appear in the virtual address space that I can access from the “cp”
pointer.
The address I am given back (cp) is always 0x40100000. I am able to
access
nearly the next 4K of memory, and none of it is 42 (which tells me
that
I
have not correctly mapped the card’s RAM into virtual ram).

Is this the correct way to access RAM off an ISA card? What else do I
need
to do?

Do I need to use mem_offset? However, the Migration Guide
documentation
implies it is only needed for DMA access.

Thank you for any help you may offer!

Brian Fraser
(University Student, Simon Fraser University, Canada).



\

Thanks for the suggestion…

I tried spatch on /dev/mem and looked around. I am presuming that /dev/mem
is the physical memory? So when I look at 0xAF000 it is actually that in
memory, not virtual address space?

What I see in spatch is not what I should be seeing from the hardware (which
is known to work). The memory is exactly the same as I get under my code
that uses mmap_device_memory under RTP. This tells me that
mmap_device_memory is functioning correctly, and that RTP is having
difficulties (or I am having difficulties with it) seeing the memory on my
card.

In spatch, I hit A and entered af000 (physical memory I hope) and had a
look. It is quite obviously not the ram of my card, and I could not find
the ram of my card anywhere in the space between 0xa0000 to 0xfffff (RAM
mapped for ISA IO cards I believe).

Is there any way under QNX 4 to see the physical RAM in the af000 range? If
so, I could look at it to verify that it sees the correct results in actual
RAM.

What needs to be done to get RTP to see the RAM on the ISA card?
Also, do I need special priority to read from hardware? I’m
running/compiling it as root.

I am, as always, open to all sugestions on what to try. It is very
important for me to get my code reading from our RAM.

Thank you again!
Brian.


“Mario Charest” <mcharest@antispam_zinformatic.com> wrote in message
news:9a27oh$fmk$1@inn.qnx.com

“Brian Fraser” <> jasperwebster@netscape.net> > wrote in message
news:99tqpi$bu1$> 1@inn.qnx.com> …
Hi,

I tried the code you suggested, and got the same response back from the
hardware: All zeros. I changed the hardware configureation to return
all
42’s (VHDL) and it works correctly under QNX 4, but only get back zeros
under RTP.


To rule out your code or the build environment;
Use spatch and open /dev/mem to read the memory.
The Next option in the menu doesn’t work (always come
back to index 0) so used the Goto option instead.

I am using the same machine for my RPT development as for the testing of
the
existing code under QNX 4.

Are there any other ways to access the memory other than
mmap_device_memory() (and other than mmap… which is all the same
stuff,
is
it not?)

Not to my knowledge.


Thank you again!
Brian.



“Mario Charest” <mcharest@void_zinformatic.com> wrote in message
news:99spk8$dd5$> 1@nntp.qnx.com> …

“Brian Fraser” <> jasperwebster@netscape.net> > wrote in message
news:99rqot$i54$> 1@inn.qnx.com> …
Hi,

I am attempting to access 256 bytes of memory on a custom built ISA
card
under QNX RTP. The physical memory address is 0xAF000 through
0xAF0FF.

We have existing code for QNX4 to access the ram as follows:

extern unsigned char __far *cp;
unsigned Card_base;

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

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);



Under RTP, this is my best shot at the code:

unsigned char *cp;
cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,
MAP_PHYS | MAP_PRIVATE, 0xaf000);
assert(cp != MAP_FAILED);

Hum this should work: Try:

volatile unsigned char *cp;

cp= mmap_device_memory( NULL, 256,
PROT_READ | PROT_WRITE | PROT_NOCACHE,0,0xaf000);

assert(cp != MAP_FAILED);

// Write to ram:
for (i=0;i<256;i++)
*(cp + i) = 0xff & i;
cp > = i ; // looks better > :wink:

// Read from ram
for (i=0;i<256;i++)
data > = *(cp + i);
data > = cp> ; // looks better as well -)


However, this does not work. When the card is not plugged in, I can
access
the ram (read and write to it), but it is obviously not the ISA
card’s
ram
(as it is not plugged in!). Under QNX4, it returns 255 (no matter
what
is
written) when the card is not plugged in. If the card is plugged
in,
I
get
garbage back (mainly 0’s, some 168’s, and a few 255’s).


I’m assuming you are testing QNX4 and QNX6 on the same computer?

One value of the hardware’s RAM is hardcoded to 42 and this value
does
not
appear in the virtual address space that I can access from the “cp”
pointer.
The address I am given back (cp) is always 0x40100000. I am able to
access
nearly the next 4K of memory, and none of it is 42 (which tells me
that
I
have not correctly mapped the card’s RAM into virtual ram).

Is this the correct way to access RAM off an ISA card? What else do
I
need
to do?

Do I need to use mem_offset? However, the Migration Guide
documentation
implies it is only needed for DMA access.

Thank you for any help you may offer!

Brian Fraser
(University Student, Simon Fraser University, Canada).





\