March 2002
Intermediate to advanced
432 pages
9h
English
I/O port operations with Linux couldn't be simpler. There's one command for input—inb(address)—and one for output—outb(value, address). C macro expansion implements these two commands without involving any libraries. Use of inb and outb does require a couple extra lines of code, though. The ioperm command requests and relinquishes port access from the kernel.1 Writing a byte the parallel port could be as simple as these three lines of code
if (ioperm(0x378, 3, 1)) exit(1); outb(argv[1][0], 0x378); if (ioperm(0x378, 3, 0)) exit(1);
Likewise, reading a byte is simple. You can use the following code to read the parallel port's status lines:
if (ioperm(0x378, 3, 1)) exit(1); putc(inb(0x379)); if (ioperm(0x378, ...
Read now
Unlock full access