1 #ifndef _LL_ARCH_X86C_MISC_H
2 #define _LL_ARCH_X86C_MISC_H
4 #include <lowlevel/types.h>
6 // Call this inside busy loops to tell the CPU to save power,
7 // use the bus less, or other CPU-specific effects.
8 // This function is not privileged.
10 static inline void ll_busywait()
12 asm volatile("pause" : : : "memory");
15 // The ll_ints functions are normally privileged, but on x86 can
16 // be also be used with IOPL 3.
18 static inline void ll_ints_off()
20 asm volatile("cli" : : : "memory");
23 static inline void ll_ints_on()
25 asm volatile("sti" : : : "memory");
28 static inline unsigned long ll_ints_save_and_off()
31 asm volatile("pushf; pop %0; cli" : "=r" (ret) : : "memory");
35 static inline void ll_ints_restore(unsigned long saved)
37 asm volatile("push %0; popf" : : "r" (saved) : "memory");
40 // Returns true if ints on, false if off. This function is not privileged.
42 static inline int ll_get_int_state()
45 asm volatile("pushf; pop %0" : "=r" (flags));
50 // Invalidates the TLB entry for one page. This function is privileged,
51 // and requires at least a 486.
53 static inline void ll_invalidate_tlb_entry(unsigned long addr)
55 asm volatile("invlpg %0" : "+m" (*(char *)addr) : : "memory");