/* * portio_getmap.c --- User mode program to read the portio I/O * permission map. * *------------------------------------------------------------------------ * * 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[] ) { portio_permission_map map; int i, j, index, num_lines, fd, status; char usage[] = "Usage: portio_getmap\n"; if ( argc > 1 ) { fputs( usage, stderr ); exit(1); } fd = open( PORTIO_DEVICE, O_RDONLY ); if ( fd == (-1) ) { perror( "portio_getmap: open failed" ); exit(1); } status = portio_getmap( fd, &map ); if ( status == (-1) ) { perror( "portio_getmap: ioctl failed" ); exit(1); } num_lines = PORTIO_NUM_PORTS / 8; for ( i = 0; i < num_lines; i++ ) { printf( "%#04x - ", PORTIO_MIN_ADDRESS + i * 8 ); for ( j = 0; j < 8; j++ ) { index = j + 8 * i; if ( map.map[ index ] == 0 ) { printf( ". " ); } else { printf( "* " ); } } printf( "\n" ); } exit(0); }