I/O port access from the command line
By Richard W.M. Jones
----------------------------------------------------------------------
This package adds commands to access machine I/O ports directly. For
example:
outw 0x443 0xf
inb 0x278
Note most of the time you should never use these commands unless you
know what you are doing.
Usage
----------------------------------------------------------------------
The commands are pretty much used as you would expect. For additional
help, use '--help' and/or read the manual page.
You will need to run the commands as root. Strictly speaking you will
need CAP_SYS_RAWIO capability.
Implementation
----------------------------------------------------------------------
At first glance it would seem that /dev/port would be the best way to
access I/O ports. However /dev/port under Linux is fundamentally
flawed because it only allows byte-sized access to ports. For example
if you write a single long (4 bytes) it will turn that into 4
individual outb operations.
Instead we use iopl(2) to raise our I/O privilege level so that we can
do the correct in<size> and out<size> operation as requested.