#include #include #include #include #include #include #include #include static __inline__ void port_out(int value, int port) { __asm__ volatile ("outb %0,%1" ::"a" ((unsigned char) value), "d"((unsigned short) port)); } static __inline__ int port_in(int port) { unsigned char value; __asm__ volatile ("inb %1,%0" :"=a" (value) :"d"((unsigned short) port)); return value; } void delay (void) { usleep(1); } int main(int argc, char *argv[]) { int i; uint8_t msr; struct termios t0,t1; if (ioperm(0x3ba,0x21,1)) { fprintf(stderr,"ioperm : %d(%s)\n",errno,strerror(errno)); return 1; } ioctl(0,TCGETS,&t0); t1 = t0; t1.c_lflag &= ~ISIG; ioctl(0,TCSETSW,&t1); msr = port_in(0x3cc); delay(); if (msr & 0x1) port_in(0x3da); else port_in(0x3ba); delay(); for (i = 0; i < 16; i++) { if (msr & 0x1) port_in(0x3da); else port_in(0x3ba); delay (); port_out (i, 0x3c0); delay (); port_out (i, 0x3c0); delay (); } if (msr & 0x1) port_in(0x3da); else port_in(0x3ba); delay(); port_out (0x20, 0x3c0); delay (); ioctl(0,TCSETSW,&t0); return 0; }