typedef struct { pudval_t pud; } pud_t;
=>typedef u64 pudval_t;
// dir表示L0页表索引的指针,指向PUD页表的基地址
#define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr)))) {
=>#define pud_offset_phys(dir, addr) (pgd_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t)) {
=>static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
{
return __pgd_to_phys(pgd);
=>#define __pgd_to_phys(pgd) __pte_to_phys(pgd_pte(pgd)) {
=>static inline pte_t pgd_pte(pgd_t pgd)
{
return __pte(pgd_val(pgd));
}
=>#define __pte_to_phys(pte) (pte_val(pte) & PTE_ADDR_MASK) {
=>#define pte_val(x) ((x).pte)
=>#define PTE_ADDR_MASK PTE_ADDR_LOW {
#define PTE_ADDR_LOW (((_AT(pteval_t, 1) << (48 - PAGE_SHIFT)) - 1) << PAGE_SHIFT)
}
}
}
}
=>#define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) {
=>#define PUD_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(1) {
=>#define ARM64_HW_PGTABLE_LEVEL_SHIFT(n) ((PAGE_SHIFT - 3) * (4 - (n)) + 3)
}
=>#define PTRS_PER_PUD PTRS_PER_PTE
=>#define PTRS_PER_PTE (1 << (PAGE_SHIFT - 3))
}
}
=>#define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x)))
=>#define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET)
=>#define PHYS_OFFSET ({ VM_BUG_ON(memstart_addr & 1); memstart_addr; })
|