/* chaser.c -- An example of wasted cpu cycles */ #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 0x240 */ //board we made is 240 rather than 0x378 or 0x278 as normal parallel port #define LP_BASE 0x378 int main(void) { int portdata = 3; int shiftin; /* 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); } while(1) { /* send data byte to io port */ outb(~ (__u8)portdata, LP_BASE); if(portdata & 0x80) { shiftin = 1; } else { shiftin = 0; } /* shift pattern left */ portdata = 0xFF & ((portdata << 1) | shiftin); /* pause to let user see pattern */ usleep(50000); } /* 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 ;) */ }