#include #include #include static inline uint8_t inb(uint16_t port) { uint8_t x; asm volatile("inb (%%dx),%%al" : /*outputs*/"=a"(x) : /*inputs*/"d"(port)); return x; } static inline uint16_t inw(uint16_t port) { uint16_t x; asm volatile("inw (%%dx),%%ax" : /*outputs*/"=a"(x) : /*inputs*/"d"(port) : /*clobber*/"memory"); return x; } static inline uint32_t inl(uint16_t port) { uint32_t x; asm volatile("inl (%%dx),%%eax" : /*outputs*/"=a"(x) : /*inputs*/"d"(port) : /*clobber*/"memory"); return x; } static inline void outb(uint16_t port, uint8_t x) { asm volatile("outb %%al,(%%dx)" : /*outputs*/ : /*inputs*/"a"(x), "d"(port) : /*clobber*/"memory"); } static inline void outw(uint16_t port, uint16_t x) { asm volatile("outw %%ax,(%%dx)" : /*outputs*/ : /*inputs*/"a"(x), "d"(port) : /*clobber*/"memory"); } static inline void outl(uint16_t port, uint32_t x) { asm volatile("outl %%eax,(%%dx)" : /*outputs*/ : /*inputs*/"a"(x), "d"(port) : /*clobber*/"memory"); } int main(void) { uint16_t tctl1; if (x86_64_iopl(1) == -1) err(1, "x86_64_iopl(1)"); tctl1 = inw(0x400 + 0x8); outw(0x400 + 0x8, tctl1 | (1 << 8)); outw(0x400 + 0x8, tctl1); if (x86_64_iopl(0) == -1) err(1, "x86_64_iopl(1)"); }