io.h (887B)
1 #ifndef _KERNEL_IO_H_ 2 #define _KERNEL_IO_H_ 3 4 #include <stdint.h> 5 6 static inline uint8_t 7 inb(uint16_t port) 8 { 9 uint8_t res; 10 11 __asm__ __volatile__ ("in %%dx, %%al" : "=a" (res) : "d" (port)); 12 return res; 13 } 14 15 static inline void 16 outb(uint16_t port, uint8_t v) 17 { 18 __asm__ __volatile__ ("out %%al, %%dx" : : "a" (v), "d" (port)); 19 } 20 21 static inline uint16_t 22 inw(uint16_t port) 23 { 24 uint16_t res; 25 26 __asm__ __volatile__ ("in %%dx, %%ax" : "=a" (res) : "d" (port)); 27 return res; 28 } 29 30 static inline void 31 outw(uint16_t port, uint16_t v) 32 { 33 __asm__ __volatile__ ("out %%ax, %%dx" : : "a" (v), "d" (port)); 34 } 35 36 static inline uint32_t 37 inl(uint16_t port) 38 { 39 uint32_t res; 40 41 __asm__ __volatile__ ("in %%dx, %%eax" : "=a" (res) : "d" (port)); 42 return res; 43 } 44 45 static inline void 46 outl(uint16_t port, uint32_t v) 47 { 48 __asm__ __volatile__ ("out %%eax, %%dx" : : "a" (v), "d" (port)); 49 } 50 51 #endif /* _KERNEL_IO_H_ */