18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _PGTABLE_NOPMD_H 38c2ecf20Sopenharmony_ci#define _PGTABLE_NOPMD_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <asm-generic/pgtable-nopud.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct mm_struct; 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define __PAGETABLE_PMD_FOLDED 1 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Having the pmd type consist of a pud gets the size right, and allows 158c2ecf20Sopenharmony_ci * us to conceptually access the pud entry that this pmd is folded into 168c2ecf20Sopenharmony_ci * without casting. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_citypedef struct { pud_t pud; } pmd_t; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define PMD_SHIFT PUD_SHIFT 218c2ecf20Sopenharmony_ci#define PTRS_PER_PMD 1 228c2ecf20Sopenharmony_ci#define PMD_SIZE (1UL << PMD_SHIFT) 238c2ecf20Sopenharmony_ci#define PMD_MASK (~(PMD_SIZE-1)) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * The "pud_xxx()" functions here are trivial for a folded two-level 278c2ecf20Sopenharmony_ci * setup: the pmd is never bad, and a pmd always exists (as it's folded 288c2ecf20Sopenharmony_ci * into the pud entry) 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_cistatic inline int pud_none(pud_t pud) { return 0; } 318c2ecf20Sopenharmony_cistatic inline int pud_bad(pud_t pud) { return 0; } 328c2ecf20Sopenharmony_cistatic inline int pud_present(pud_t pud) { return 1; } 338c2ecf20Sopenharmony_cistatic inline void pud_clear(pud_t *pud) { } 348c2ecf20Sopenharmony_ci#define pmd_ERROR(pmd) (pud_ERROR((pmd).pud)) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define pud_populate(mm, pmd, pte) do { } while (0) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* 398c2ecf20Sopenharmony_ci * (pmds are folded into puds so this doesn't get actually called, 408c2ecf20Sopenharmony_ci * but the define is needed for a generic inline function.) 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval }) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic inline pmd_t * pmd_offset(pud_t * pud, unsigned long address) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci return (pmd_t *)pud; 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci#define pmd_offset pmd_offset 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define pmd_val(x) (pud_val((x).pud)) 518c2ecf20Sopenharmony_ci#define __pmd(x) ((pmd_t) { __pud(x) } ) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define pud_page(pud) (pmd_page((pmd_t){ pud })) 548c2ecf20Sopenharmony_ci#define pud_pgtable(pud) ((pmd_t *)(pmd_page_vaddr((pmd_t){ pud }))) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* 578c2ecf20Sopenharmony_ci * allocating and freeing a pmd is trivial: the 1-entry pmd is 588c2ecf20Sopenharmony_ci * inside the pud, so has no extra memory associated with it. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci#define pmd_alloc_one(mm, address) NULL 618c2ecf20Sopenharmony_cistatic inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci#define pmd_free_tlb(tlb, x, a) do { } while (0) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#undef pmd_addr_end 678c2ecf20Sopenharmony_ci#define pmd_addr_end(addr, end) (end) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#endif /* _PGTABLE_NOPMD_H */ 72