1 #ifndef __LUNAIX_ARCH_TLB_H
2 #define __LUNAIX_ARCH_TLB_H
4 #include <lunaix/types.h>
6 #include <asm/aa64_mmu.h>
7 #include <asm/aa64_sysinst.h>
9 #define pack_va(asid, ttl, va) \
10 (((asid & 0xffffUL) << 48) | \
11 ((ttl & 0b1111UL) << 44) | \
12 (pfn(va) & ((1UL << 44) - 1)))
14 #define pack_rva(asid, ttl, base, n, scale) \
15 (((asid & 0xffffUL) << 48) | \
16 ((_MMU_TG & 0b11UL) << 46) | \
17 ((n & 0x1fUL) << 39) | \
18 ((scale & 0b11UL) << 37) | \
19 ((ttl & 0b1111UL) << 44) | \
20 (pfn(base)& ((1UL << 37) - 1)))
23 * @brief Invalidate an entry of all address space
27 static inline void must_inline
28 __tlb_invalidate(ptr_t va)
30 sys_a1(tlbi_vaae1, pack_va(0, 0, va));
35 * @brief Invalidate an entry of an address space indetified
40 static inline void must_inline
41 __tlb_flush_asid(unsigned int asid, ptr_t va)
43 sys_a1(tlbi_vae1, pack_va(asid, 0, va));
48 * @brief Invalidate an entry of global address space
52 static inline void must_inline
53 __tlb_flush_global(ptr_t va)
55 __tlb_flush_asid(0, va);
59 * @brief Invalidate an entire TLB
63 static inline void must_inline
71 * @brief Invalidate an entire address space
75 static inline void must_inline
76 __tlb_flush_asid_all(unsigned int asid)
78 sys_a1(tlbi_aside1, pack_va(asid, 0, 0));
84 * @brief Invalidate entries of all address spaces
91 tlb_flush_range(ptr_t addr, unsigned int npages)
94 for (unsigned int i = 0; i < npages; i++)
96 __tlb_invalidate(addr + i * PAGE_SIZE);
99 sys_a1(tlbi_rvaae1, pack_rva(0, 0, addr, npages, 0));
105 * @brief Invalidate entries of an address space identified
113 tlb_flush_asid_range(unsigned int asid, ptr_t addr, unsigned int npages)
116 for (unsigned int i = 0; i < npages; i++)
118 __tlb_flush_asid(asid, addr + i * PAGE_SIZE);
121 sys_a1(tlbi_rvae1, pack_rva(asid, 0, addr, npages, 0));
126 #include <asm-generic/tlb-shared.h>
128 #endif /* __LUNAIX_VMTLB_H */