io.h (1104B)
1 #ifndef _IO_H_ 2 #define _IO_H_ 3 4 #include <u.h> 5 6 static inline u_int8_t 7 inb(u_int16_t port) 8 { 9 u_int8_t res; 10 11 __asm__ __volatile("in %%dx, %%al" : "=a" (res) : "d" (port)); 12 return (res); 13 } 14 15 static inline void 16 outb(u_int16_t port, u_int8_t v) 17 { 18 __asm__ __volatile("out %%al, %%dx" : : "a" (v), "d" (port)); 19 } 20 21 static inline u_int16_t 22 inw(u_int16_t port) 23 { 24 u_int16_t res; 25 26 __asm__ __volatile("in %%dx, %%ax" : "=a" (res) : "d" (port)); 27 return (res); 28 } 29 30 static inline void 31 outw(u_int16_t port, u_int16_t v) 32 { 33 __asm__ __volatile("out %%ax, %%dx" : : "a" (v), "d" (port)); 34 } 35 36 static inline u_int32_t 37 inl(u_int16_t port) 38 { 39 u_int32_t res; 40 41 __asm__ __volatile("in %%dx, %%eax" : "=a" (res) : "d" (port)); 42 return (res); 43 } 44 45 static inline void 46 outl(u_int16_t port, u_int32_t v) 47 { 48 __asm__ __volatile("out %%eax, %%dx" : : "a" (v), "d" (port)); 49 } 50 51 static inline void 52 hlt(void) 53 { 54 __asm__ __volatile("hlt"); 55 } 56 57 static inline void 58 cli(void) 59 { 60 __asm__ __volatile("cli"); 61 } 62 63 static inline void 64 sti(void) 65 { 66 __asm__ __volatile("sti"); 67 } 68 69 static inline void 70 io_wait(void) 71 { 72 outb(0x80, 0); 73 } 74 75 #endif /* _IO_H_ */