= 2009-05-08 = * [午餐] [http://www.ipeen.com.tw/shop/shop.php?id=15102 聯合泰國小吃店]  * [專案] 在 Windows 底下常用的 inportb() 跟 outportb(),在 Linux 底下可以用 port I/O (有很多種 outb(), outw(), outl(), outsb(), outsw(), outsl(), inb(), inw(), inl(), insb(), insw(), insl() ) 來實現。而在 !VxWorks 則用 sysInByte() 跟 sysOutByte() 來實現 {{{ #!C static int outportb(unsigned int port, unsigned int val, int size) { static int iopldone = 0; #ifdef DEBUG printf("outportb(0x%04x)<=0x%02x\n", port, val); #endif if (port > 1024) { if (!iopldone && iopl(3)) { fprintf(stderr, "iopl(): %s\n", strerror(errno)); return 1; } iopldone++; } else if (ioperm(port,size,1)) { fprintf(stderr, "ioperm(%x): %s\n", port, strerror(errno)); return 1; } if (size == 4) outl(val, port); else if (size == 2) outw(val&0xffff, port); else outb(val&0xff, port); return 0; } static int inportb(unsigned int port, int size) { static int iopldone = 0; #ifdef DEBUG printf("inportb(0x%04x)\n", port); #endif if (port > 1024) { if (!iopldone && iopl(3)) { fprintf(stderr, "iopl(): %s\n", strerror(errno)); return 1; } iopldone++; } else if (ioperm(port,size,1)) { fprintf(stderr, "ioperm(%x): %s\n", port, strerror(errno)); return 1; } if (size == 4) return inl(port); else if (size == 2) return inw(port) & 0xffff; else return inb(port) & 0xff; } }}}