Commit | Line | Data |
---|---|---|
2bf59916 AK |
1 | #ifndef _ASM_POWERPC_PGTABLE_TYPES_H |
2 | #define _ASM_POWERPC_PGTABLE_TYPES_H | |
3 | ||
2bf59916 AK |
4 | /* PTE level */ |
5 | typedef struct { pte_basic_t pte; } pte_t; | |
6 | #define __pte(x) ((pte_t) { (x) }) | |
7 | static inline pte_basic_t pte_val(pte_t x) | |
8 | { | |
9 | return x.pte; | |
10 | } | |
11 | ||
2bf59916 AK |
12 | /* PMD level */ |
13 | #ifdef CONFIG_PPC64 | |
14 | typedef struct { unsigned long pmd; } pmd_t; | |
15 | #define __pmd(x) ((pmd_t) { (x) }) | |
16 | static inline unsigned long pmd_val(pmd_t x) | |
17 | { | |
18 | return x.pmd; | |
19 | } | |
20 | ||
368ced78 AK |
21 | /* |
22 | * 64 bit hash always use 4 level table. Everybody else use 4 level | |
23 | * only for 4K page size. | |
24 | */ | |
25 | #if defined(CONFIG_PPC_BOOK3S_64) || !defined(CONFIG_PPC_64K_PAGES) | |
2bf59916 AK |
26 | typedef struct { unsigned long pud; } pud_t; |
27 | #define __pud(x) ((pud_t) { (x) }) | |
28 | static inline unsigned long pud_val(pud_t x) | |
29 | { | |
30 | return x.pud; | |
31 | } | |
368ced78 | 32 | #endif /* CONFIG_PPC_BOOK3S_64 || !CONFIG_PPC_64K_PAGES */ |
2bf59916 AK |
33 | #endif /* CONFIG_PPC64 */ |
34 | ||
35 | /* PGD level */ | |
36 | typedef struct { unsigned long pgd; } pgd_t; | |
37 | #define __pgd(x) ((pgd_t) { (x) }) | |
38 | static inline unsigned long pgd_val(pgd_t x) | |
39 | { | |
40 | return x.pgd; | |
41 | } | |
42 | ||
43 | /* Page protection bits */ | |
44 | typedef struct { unsigned long pgprot; } pgprot_t; | |
45 | #define pgprot_val(x) ((x).pgprot) | |
46 | #define __pgprot(x) ((pgprot_t) { (x) }) | |
47 | ||
ae9a71af AK |
48 | /* |
49 | * With hash config 64k pages additionally define a bigger "real PTE" type that | |
50 | * gathers the "second half" part of the PTE for pseudo 64k pages | |
51 | */ | |
52 | #if defined(CONFIG_PPC_64K_PAGES) && defined(CONFIG_PPC_STD_MMU_64) | |
53 | typedef struct { pte_t pte; unsigned long hidx; } real_pte_t; | |
54 | #else | |
55 | typedef struct { pte_t pte; } real_pte_t; | |
2bf59916 | 56 | #endif |
3910a7f4 ME |
57 | |
58 | #ifdef CONFIG_PPC_STD_MMU_64 | |
59 | #include <asm/cmpxchg.h> | |
60 | ||
61 | static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new) | |
62 | { | |
63 | unsigned long *p = (unsigned long *)ptep; | |
64 | ||
65 | return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new)); | |
66 | } | |
67 | #endif | |
68 | ||
2bf59916 | 69 | #endif /* _ASM_POWERPC_PGTABLE_TYPES_H */ |