xref: /OK3568_Linux_fs/kernel/include/asm-generic/pgtable-nopud.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _PGTABLE_NOPUD_H
3*4882a593Smuzhiyun #define _PGTABLE_NOPUD_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #ifndef __ASSEMBLY__
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #include <asm-generic/pgtable-nop4d.h>
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #define __PAGETABLE_PUD_FOLDED 1
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /*
12*4882a593Smuzhiyun  * Having the pud type consist of a p4d gets the size right, and allows
13*4882a593Smuzhiyun  * us to conceptually access the p4d entry that this pud is folded into
14*4882a593Smuzhiyun  * without casting.
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun typedef struct { p4d_t p4d; } pud_t;
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #define PUD_SHIFT	P4D_SHIFT
19*4882a593Smuzhiyun #define PTRS_PER_PUD	1
20*4882a593Smuzhiyun #define PUD_SIZE  	(1UL << PUD_SHIFT)
21*4882a593Smuzhiyun #define PUD_MASK  	(~(PUD_SIZE-1))
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /*
24*4882a593Smuzhiyun  * The "p4d_xxx()" functions here are trivial for a folded two-level
25*4882a593Smuzhiyun  * setup: the pud is never bad, and a pud always exists (as it's folded
26*4882a593Smuzhiyun  * into the p4d entry)
27*4882a593Smuzhiyun  */
p4d_none(p4d_t p4d)28*4882a593Smuzhiyun static inline int p4d_none(p4d_t p4d)		{ return 0; }
p4d_bad(p4d_t p4d)29*4882a593Smuzhiyun static inline int p4d_bad(p4d_t p4d)		{ return 0; }
p4d_present(p4d_t p4d)30*4882a593Smuzhiyun static inline int p4d_present(p4d_t p4d)	{ return 1; }
p4d_clear(p4d_t * p4d)31*4882a593Smuzhiyun static inline void p4d_clear(p4d_t *p4d)	{ }
32*4882a593Smuzhiyun #define pud_ERROR(pud)				(p4d_ERROR((pud).p4d))
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define p4d_populate(mm, p4d, pud)		do { } while (0)
35*4882a593Smuzhiyun #define p4d_populate_safe(mm, p4d, pud)		do { } while (0)
36*4882a593Smuzhiyun /*
37*4882a593Smuzhiyun  * (puds are folded into p4ds so this doesn't get actually called,
38*4882a593Smuzhiyun  * but the define is needed for a generic inline function.)
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun #define set_p4d(p4dptr, p4dval)	set_pud((pud_t *)(p4dptr), (pud_t) { p4dval })
41*4882a593Smuzhiyun 
pud_offset(p4d_t * p4d,unsigned long address)42*4882a593Smuzhiyun static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
43*4882a593Smuzhiyun {
44*4882a593Smuzhiyun 	return (pud_t *)p4d;
45*4882a593Smuzhiyun }
46*4882a593Smuzhiyun #define pud_offset pud_offset
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #define pud_val(x)				(p4d_val((x).p4d))
49*4882a593Smuzhiyun #define __pud(x)				((pud_t) { __p4d(x) })
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun #define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
52*4882a593Smuzhiyun #define p4d_page_vaddr(p4d)			(pud_page_vaddr((pud_t){ p4d }))
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun /*
55*4882a593Smuzhiyun  * allocating and freeing a pud is trivial: the 1-entry pud is
56*4882a593Smuzhiyun  * inside the p4d, so has no extra memory associated with it.
57*4882a593Smuzhiyun  */
58*4882a593Smuzhiyun #define pud_alloc_one(mm, address)		NULL
59*4882a593Smuzhiyun #define pud_free(mm, x)				do { } while (0)
60*4882a593Smuzhiyun #define pud_free_tlb(tlb, x, a)		        do { } while (0)
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun #undef  pud_addr_end
63*4882a593Smuzhiyun #define pud_addr_end(addr, end)			(end)
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
66*4882a593Smuzhiyun #endif /* _PGTABLE_NOPUD_H */
67