Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _PGTABLE_NOPMD_H
0003 #define _PGTABLE_NOPMD_H
0004 
0005 #ifndef __ASSEMBLY__
0006 
0007 #include <asm-generic/pgtable-nopud.h>
0008 
0009 struct mm_struct;
0010 
0011 #define __PAGETABLE_PMD_FOLDED 1
0012 
0013 /*
0014  * Having the pmd type consist of a pud gets the size right, and allows
0015  * us to conceptually access the pud entry that this pmd is folded into
0016  * without casting.
0017  */
0018 typedef struct { pud_t pud; } pmd_t;
0019 
0020 #define PMD_SHIFT   PUD_SHIFT
0021 #define PTRS_PER_PMD    1
0022 #define PMD_SIZE    (1UL << PMD_SHIFT)
0023 #define PMD_MASK    (~(PMD_SIZE-1))
0024 
0025 /*
0026  * The "pud_xxx()" functions here are trivial for a folded two-level
0027  * setup: the pmd is never bad, and a pmd always exists (as it's folded
0028  * into the pud entry)
0029  */
0030 static inline int pud_none(pud_t pud)       { return 0; }
0031 static inline int pud_bad(pud_t pud)        { return 0; }
0032 static inline int pud_present(pud_t pud)    { return 1; }
0033 static inline int pud_user(pud_t pud)       { return 0; }
0034 static inline int pud_leaf(pud_t pud)       { return 0; }
0035 static inline void pud_clear(pud_t *pud)    { }
0036 #define pmd_ERROR(pmd)              (pud_ERROR((pmd).pud))
0037 
0038 #define pud_populate(mm, pmd, pte)      do { } while (0)
0039 
0040 /*
0041  * (pmds are folded into puds so this doesn't get actually called,
0042  * but the define is needed for a generic inline function.)
0043  */
0044 #define set_pud(pudptr, pudval)         set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
0045 
0046 static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
0047 {
0048     return (pmd_t *)pud;
0049 }
0050 #define pmd_offset pmd_offset
0051 
0052 #define pmd_val(x)              (pud_val((x).pud))
0053 #define __pmd(x)                ((pmd_t) { __pud(x) } )
0054 
0055 #define pud_page(pud)               (pmd_page((pmd_t){ pud }))
0056 #define pud_pgtable(pud)            ((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
0057 
0058 /*
0059  * allocating and freeing a pmd is trivial: the 1-entry pmd is
0060  * inside the pud, so has no extra memory associated with it.
0061  */
0062 #define pmd_alloc_one(mm, address)      NULL
0063 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
0064 {
0065 }
0066 #define pmd_free_tlb(tlb, x, a)     do { } while (0)
0067 
0068 #undef  pmd_addr_end
0069 #define pmd_addr_end(addr, end)         (end)
0070 
0071 #endif /* __ASSEMBLY__ */
0072 
0073 #endif /* _PGTABLE_NOPMD_H */