/* * inb.c --- User mode program to read a byte from an I/O port. * * * Copyright 1999 Illinois Institute of Technology * * See the file "LICENSE" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #include #include #include #include #include "portio.h" int main( int argc, char *argv[] ) { int fd, status; __u16 address; __u8 value; char usage[] = "Usage: inb address\n"; if ( argc == 2 ) { address = strtoul( argv[1], NULL, 0 ); } else { fputs( usage, stderr ); exit(1); } fd = open( PORTIO_DEVICE, O_RDONLY ); if ( fd == (-1) ) { perror( "inb: open failed" ); exit(1); } status = portio_inb( fd, &value, address ); if ( status == (-1) ) { perror( "inb: portio_inb failed" ); exit(1); } printf( "%#02x\n", value ); exit(0); }