Hello,
Anybody knows how to use in8() or out8() ? Is it the same use as inb() or
outb() in Linux, setting all ports turn on and run it
with root privilege?
Thanks,
Belinda
Hello,
Anybody knows how to use in8() or out8() ? Is it the same use as inb() or
outb() in Linux, setting all ports turn on and run it
with root privilege?
Thanks,
Belinda
Belinda <yye@borg.cs.dal.ca> wrote:
Hello,
Anybody knows how to use in8() or out8() ? Is it the same use as inb() or
outb() in Linux, setting all ports turn on and run it
with root privilege?
in8() and out8() read/write 8 bytes to a control register/io-port.
You need hardware privilege to use them – see the ThreadCtl() function
for this, and you need root (super user) access to succeed with the
ThreadCtl().
QNX Training Services
dagibbs@qnx.com
“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9qkub4$nro$1@nntp.qnx.com…
Belinda <> yye@borg.cs.dal.ca> > wrote:
Hello,Anybody knows how to use in8() or out8() ? Is it the same use as inb()
or
outb() in Linux, setting all ports turn on and run it
with root privilege?in8() and out8() read/write 8 bytes to a control register/io-port.
You need hardware privilege to use them – see the ThreadCtl() function
for this, and you need root (super user) access to succeed with the
ThreadCtl().
It’s also good pratice to obtain the address to pass to in*/ou*
via mmap_device_io. It increases portability to other platform.
-David
QNX Training Services
dagibbs@qnx.com
Hi,
#include <hw/inout.h>
#include <sys/neutrino.h>
#define BASE_ADDRESS 0x300
#define DEBUG
int main()
{
unsigned char byteToPort;
unsigned char byteFromPort;
if (ThreadCtl(_NTO_TCTL_IO,0)==-1) {
#ifdef DEBUG
printf(“ThreadCtl return error!”);
#endif
return -1;
}else {
#ifdef DEBUG
printf(“ThreadCtl() return success!”);
#endif
}
byteToPort=‘h’;
out8(BASE_ADDRESS, byteToPort);
#ifdef DEBUG
printf(“write success!”);
#endif
byteFromPort=in8(BASE_ADDRESS);
#ifdef DEBUG
printf(“IN_PORT: %s /n”, byteFromPort);
#endif
return 0;
With the root of privilege, I run the above code and it is reported the
error of memory dumption. I found this error is caused by using in8()
functio and it seems that outb() can work. I couldn’t know what’s the
reason caused it happened.
And if I don’t use root priviledge, do you think I can find the other ways
to solve it?
Thanks,
Belinda
“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9qkub4$nro$1@nntp.qnx.com…
Belinda <> yye@borg.cs.dal.ca> > wrote:
Hello,Anybody knows how to use in8() or out8() ? Is it the same use as inb()
or
outb() in Linux, setting all ports turn on and run it
with root privilege?in8() and out8() read/write 8 bytes to a control register/io-port.
You need hardware privilege to use them – see the ThreadCtl() function
for this, and you need root (super user) access to succeed with the
ThreadCtl().-David
QNX Training Services
dagibbs@qnx.com
“Belinda” <yye@borg.cs.dal.ca> wrote in message
news:9qnsbt$7at$1@inn.qnx.com…
Hi,
Thanks for your solution. I tried it. And it still has some errors. I just
write a simple code , followed as :
[cut]
#ifdef DEBUG
printf(“IN_PORT: %s /n”, byteFromPort);
#endif
You are trying to print byteFromPort as if it was a string.
Printf uses byteFromPort as a pointer which most obviously
doesn’t point in valid address space. Try 0x%x instead
to show the value in hexadecimal.