using mmap_device_io

I’m writing a test app to talk to a commercial PC-104 card directly. (Later
I will turn this in to a resource manager).
I use ‘mmap_device_io’ to supposedly map the device into the process space.
I assume that the ‘uintptr_t’ data type returned by ‘map_device_io’ is then
a pointer that I use to talk to the hardware. Therefore pseudo-code would
look like this…

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(memptr,dataword);

This seems to work. However, the following also appears to work

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(BASE_ADDR,dataword);

So please help me understand. What does the mmap_device_io() function call
do for me. Why does the statement ‘out16(BASE_ADDR,dataword);’ also appear
to work?

“Chris Rose” <chris.rose@viasat.com> wrote in message
news:9v56nt$sq3$1@inn.qnx.com

I’m writing a test app to talk to a commercial PC-104 card directly.
(Later
I will turn this in to a resource manager).
I use ‘mmap_device_io’ to supposedly map the device into the process
space.
I assume that the ‘uintptr_t’ data type returned by ‘map_device_io’ is
then
a pointer that I use to talk to the hardware. Therefore pseudo-code would
look like this…

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(memptr,dataword);

This seems to work. However, the following also appears to work

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(BASE_ADDR,dataword);

So please help me understand. What does the mmap_device_io() function call
do for me.

Portability (across various CPU platform), compatibility with futur
revision of QNX6.

It could make it possible for the OS to display what program is handling
what IO.

Why does the statement ‘out16(BASE_ADDR,dataword);’ also appear
to work?

Because mmap_device_io() currently does nothing on x86 platform.

that a process doesn’t really have its own protected memory space?
Also is it the same story with mapping shared memory? Does it really do
nothing on x86 platform?


“Mario Charest” <mcharest@clipzinformatic.com> wrote in message
news:9v571q$52$1@inn.qnx.com

“Chris Rose” <> chris.rose@viasat.com> > wrote in message
news:9v56nt$sq3$> 1@inn.qnx.com> …
I’m writing a test app to talk to a commercial PC-104 card directly.
(Later
I will turn this in to a resource manager).
I use ‘mmap_device_io’ to supposedly map the device into the process
space.
I assume that the ‘uintptr_t’ data type returned by ‘map_device_io’ is
then
a pointer that I use to talk to the hardware. Therefore pseudo-code
would
look like this…

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(memptr,dataword);

This seems to work. However, the following also appears to work

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(BASE_ADDR,dataword);

So please help me understand. What does the mmap_device_io() function
call
do for me.

Portability (across various CPU platform), compatibility with futur
revision of QNX6.

It could make it possible for the OS to display what program is handling
what IO.

Why does the statement ‘out16(BASE_ADDR,dataword);’ also appear
to work?

Because mmap_device_io() currently does nothing on x86 platform.




\

“Chris Rose” <chris.rose@viasat.com> wrote in message
news:9v595d$1c2$1@inn.qnx.com

that a process doesn’t really have its own protected memory space?

All process have they own protected memory space.
They don’t have protected io space. Once a program does
ThreadCtl(_NTO_TCTL_IO, 0); it can write any io it wants.
However in the futur, QNX may add io space protection management,
but since lots of people don’t use mmap_device_io it would
probably break lots of code.


Also is it the same story with mapping shared memory? Does it really do
nothing on x86 platform?

No it does a lot actually :wink: All memory addresses are virtual,
so the physical memory needs to be mapped in the virtual
address space of the process. io address are always physical,
they don’t have a virtual counterpart.

“Mario Charest” <> mcharest@clipzinformatic.com> > wrote in message
news:9v571q$52$> 1@inn.qnx.com> …

“Chris Rose” <> chris.rose@viasat.com> > wrote in message
news:9v56nt$sq3$> 1@inn.qnx.com> …
I’m writing a test app to talk to a commercial PC-104 card directly.
(Later
I will turn this in to a resource manager).
I use ‘mmap_device_io’ to supposedly map the device into the process
space.
I assume that the ‘uintptr_t’ data type returned by ‘map_device_io’ is
then
a pointer that I use to talk to the hardware. Therefore pseudo-code
would
look like this…

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(memptr,dataword);

This seems to work. However, the following also appears to work

ThreadCtl(_NTO_TCTL_IO, 0);
memptr=mmap_device_io(MAPSIZE, BASE_ADDR);

out16(BASE_ADDR,dataword);

So please help me understand. What does the mmap_device_io() function
call
do for me.

Portability (across various CPU platform), compatibility with futur
revision of QNX6.

It could make it possible for the OS to display what program is handling
what IO.

Why does the statement ‘out16(BASE_ADDR,dataword);’ also appear
to work?

Because mmap_device_io() currently does nothing on x86 platform.






\