1static inline uint8_t 2inb(uint16_t port) 3{ 4 uint8_t rv; 5 6 __asm__ __volatile__("inb %1, %0" : "=a"(rv) : "d"(port)); 7 8 return rv; 9} 10 11static inline uint32_t 12inl(uint16_t port) 13{ 14 uint32_t rv; 15 16 __asm__ __volatile__("inl %1, %0" : "=a"(rv) : "d"(port)); 17 18 return rv; 19} 20 21static inline void 22outb(uint16_t port, uint8_t value) 23{ 24 25 __asm__ __volatile__("outb %0, %1" :: "a"(value), "d"(port)); 26} 27 28static inline void 29outl(uint16_t port, uint32_t value) 30{ 31 32 __asm__ __volatile__("outl %0, %1" :: "a"(value), "d"(port)); 33} 34 35extern int spldepth; 36 37static inline void 38splhigh(void) 39{ 40 41 __asm__ __volatile__("cli"); 42 spldepth++; 43} 44 45static inline void 46spl0(void) 47{ 48 49 if (spldepth == 0) 50 bmk_platform_halt("out of interrupt depth!"); 51 if (--spldepth == 0) 52 __asm__ __volatile__("sti"); 53} 54 55static inline void 56hlt(void) 57{ 58 59 __asm__ __volatile__("hlt"); 60} 61 62static inline uint64_t 63rdtsc(void) 64{ 65 uint64_t val; 66 unsigned long eax, edx; 67 68 __asm__ __volatile__("rdtsc" : "=a"(eax), "=d"(edx)); 69 val = ((uint64_t)edx<<32)|(eax); 70 return val; 71} 72