Warning: This file is not a C or C++ file. It does not have highlighting.

1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_PGTABLE_TYPES_H
3#define _ASM_POWERPC_PGTABLE_TYPES_H
4
5#if defined(__CHECKER__) || !defined(CONFIG_PPC32)
6#define STRICT_MM_TYPECHECKS
7#endif
8
9/* PTE level */
10#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES)
11typedef struct { pte_basic_t pte, pte1, pte2, pte3; } pte_t;
12#elif defined(STRICT_MM_TYPECHECKS)
13typedef struct { pte_basic_t pte; } pte_t;
14#else
15typedef pte_basic_t pte_t;
16#endif
17
18#if defined(STRICT_MM_TYPECHECKS) || \
19 (defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES))
20#define __pte(x) ((pte_t) { (x) })
21static inline pte_basic_t pte_val(pte_t x)
22{
23 return x.pte;
24}
25#else
26#define __pte(x) ((pte_t)(x))
27static inline pte_basic_t pte_val(pte_t x)
28{
29 return x;
30}
31#endif
32
33/* PMD level */
34#ifdef CONFIG_PPC64
35typedef struct { unsigned long pmd; } pmd_t;
36#define __pmd(x) ((pmd_t) { (x) })
37static inline unsigned long pmd_val(pmd_t x)
38{
39 return x.pmd;
40}
41
42/* 64 bit always use 4 level table. */
43typedef struct { unsigned long pud; } pud_t;
44#define __pud(x) ((pud_t) { (x) })
45static inline unsigned long pud_val(pud_t x)
46{
47 return x.pud;
48}
49#endif /* CONFIG_PPC64 */
50
51/* PGD level */
52#if defined(CONFIG_PPC_85xx) && defined(CONFIG_PTE_64BIT)
53typedef struct { unsigned long long pgd; } pgd_t;
54
55static inline unsigned long long pgd_val(pgd_t x)
56{
57 return x.pgd;
58}
59#else
60typedef struct { unsigned long pgd; } pgd_t;
61
62static inline unsigned long pgd_val(pgd_t x)
63{
64 return x.pgd;
65}
66#endif
67#define __pgd(x) ((pgd_t) { (x) })
68
69/* Page protection bits */
70typedef struct { unsigned long pgprot; } pgprot_t;
71#define pgprot_val(x) ((x).pgprot)
72#define __pgprot(x) ((pgprot_t) { (x) })
73
74/*
75 * With hash config 64k pages additionally define a bigger "real PTE" type that
76 * gathers the "second half" part of the PTE for pseudo 64k pages
77 */
78#ifdef CONFIG_PPC_64K_PAGES
79typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
80#else
81typedef struct { pte_t pte; } real_pte_t;
82#endif
83
84#ifdef CONFIG_PPC_BOOK3S_64
85#include <asm/cmpxchg.h>
86
87static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
88{
89 unsigned long *p = (unsigned long *)ptep;
90
91 /* See comment in switch_mm_irqs_off() */
92 return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new));
93}
94#endif
95
96#endif /* _ASM_POWERPC_PGTABLE_TYPES_H */
97

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of linux/arch/powerpc/include/asm/pgtable-types.h