/* outport.c -- An example of low-level io from userspace */ /* If you are a Certified SSP (TM), you can use this program to test your Seating License Manager (TM) prior to connecting to our Patent Pending SeatServ (TM) system */ /* must gcc -O2 to expand the macros, otherwise won't work if just gcc */ #include #include /* headers for architecture specific data types */ #include /* contains the prototype for i386 specific ioperm functioni */ #include /* obviously architecture specific (asm directory) for inb, outb macros */ #define LP_BASE 0x278 int main(int argc, char **argv) { __u8 portdata; if(argc < 2) { fprintf(stderr, "Must supply a value to send to port...\n"); exit(1); } portdata = (__u8) atoi(argv[1]); /* let us know the value of portdata */ printf("Value submitted for sending to hardware: %i\n", portdata); /* attempt to reserve region in io space */ if(ioperm(LP_BASE, 3, 1) < 0) { fprintf(stderr, "Cannot reserve region in io space, aborting...\n"); exit(1); } /* send data byte to io port */ outb(portdata, LP_BASE); /* attempt to release reserved region in io space */ if(ioperm(LP_BASE, 3, 0) < 0) { fprintf(stderr, "Cannot release region in io space, aborting...\n"); exit(1); } return(0); /* just to be nice ;) */ }