Linux does not, by default, allow userland code to write to I/O ports. (Doing so can be quite dangerous from a security perspective.) If you’d like Linux to give your process access to the I/O ports, you have two options:
You can use the
ioperm
system call. However,ioperm
has been deprecated for some time, and Josh Triplett recently pushed a patch that allows users to remove it from the kernel. Avoidioperm
if you want your code to continue working for the forseeable future.You can read from and write to /dev/port. See mem(4). Your process will, obviously, need read and write permissions for /dev/mem; on Wheezy, that means it needs to run as root, unless you change the permissions on the device.