1 #ifndef __LUNAIX_ARCH_TLB_H
2 #define __LUNAIX_ARCH_TLB_H
4 #include <lunaix/compiler.h>
5 #include <asm/mm_defs.h>
8 * @brief Invalidate an entry of all address space
12 static inline void must_inline
13 __tlb_invalidate(ptr_t va)
15 asm volatile("invlpg (%0)" ::"r"(va) : "memory");
19 * @brief Invalidate an entry of an address space indetified
24 static inline void must_inline
25 __tlb_flush_asid(unsigned int asid, ptr_t va)
27 // not supported on x86_32
28 asm volatile("invlpg (%0)" ::"r"(va) : "memory");
32 * @brief Invalidate an entry of global address space
36 static inline void must_inline
37 __tlb_flush_global(ptr_t va)
39 // not supported on x86_32
40 asm volatile("invlpg (%0)" ::"r"(va) : "memory");
44 * @brief Invalidate an entire TLB
48 static inline void must_inline
59 * @brief Invalidate an entire address space
63 static inline void must_inline
64 __tlb_flush_asid_all(unsigned int asid)
66 // not supported on x86_32
72 * @brief Invalidate entries of all address spaces
79 tlb_flush_range(ptr_t addr, unsigned int npages)
81 for (unsigned int i = 0; i < npages; i++)
83 __tlb_invalidate(addr + i * PAGE_SIZE);
88 * @brief Invalidate entries of an address space identified
96 tlb_flush_asid_range(unsigned int asid, ptr_t addr, unsigned int npages)
98 for (unsigned int i = 0; i < npages; i++)
100 __tlb_flush_asid(asid, addr + i * PAGE_SIZE);
105 * @brief Invalidate an entry of kernel address spaces
112 tlb_flush_kernel(ptr_t addr)
114 __tlb_flush_global(addr);
118 * @brief Invalidate entries of kernel address spaces
125 tlb_flush_kernel_ranged(ptr_t addr, unsigned int npages)
127 for (unsigned int i = 0; i < npages; i++)
129 tlb_flush_kernel(addr + i * PAGE_SIZE);
133 #include <asm-generic/tlb-shared.h>
135 #endif /* __LUNAIX_VMTLB_H */