I have one programme,which is running in dos,now I want to rewrite it in qnx,in the programme it has several lines that include “outportb()” and “inportb()”,how can I do?I try to use “out8” and “in8” to replace them,but I can’t get the result that I want,by the way,before use it,I have used ThreadCtl(_NTO_TCTL_IO, 0),in the help doc it said i should use mmap_device_io(),sorry I don’t know how to use it?for example if I want to write one value 0x5555 to address 0x4011,how to acheive it?
In general, out8() is the QNX equivalent to outportb(). Reasons for not working properly are numerous, perhaps you could give some more information on hardware platform etc and some code snippets. Here are some guesses:
- Remember to run the program as root, otherwise ThreadCtl(NTO_TCTL_IO, 0) will fail. Check for return value.
-Likewise for mmap_device_io() which is actually very simple to use, you just give the number of bytes to map in and the start address where your device physically maps into the processor’s address space. The return value (if successful) is a kind of pointer that you can use in subsequent calls to out8 etc.
- Make sure the device registers are really at the location you are expecting them.
btw, out8 writes only values from 0 to 255, so your example of writing 0x5555 would be truncated to 0x55 I guess and in the worst case you might get an alignment fault if you try to use out16 on an odd address.
Best regards,
Albrecht