This source file includes following definitions.
- get_segmap
- put_segmap
- get_pte
- put_pte
- switch_to_context
- get_context
1
2
3
4
5
6
7 #ifndef _SPARC_PAGE_H
8 #define _SPARC_PAGE_H
9
10 #include <asm/asi.h>
11 #include <asm/contregs.h>
12
13 #define PAGE_SHIFT 12
14
15 #ifndef __ASSEMBLY__
16 #define PAGE_SIZE (1UL << PAGE_SHIFT)
17
18
19 #define PAGE_MASK (~(PAGE_SIZE-1))
20
21 #ifdef __KERNEL__
22
23
24
25
26
27
28
29
30
31 struct sparc_phys_banks {
32 unsigned long base_addr;
33 unsigned long num_bytes;
34 };
35
36 #define CONFIG_STRICT_MM_TYPECHECKS
37
38 #ifdef CONFIG_STRICT_MM_TYPECHECKS
39
40
41
42 typedef struct { unsigned long pte; } pte_t;
43 typedef struct { unsigned long pmd; } pmd_t;
44 typedef struct { unsigned long pgd; } pgd_t;
45 typedef struct { unsigned long pgprot; } pgprot_t;
46
47 #define pte_val(x) ((x).pte)
48 #define pmd_val(x) ((x).pmd)
49 #define pgd_val(x) ((x).pgd)
50 #define pgprot_val(x) ((x).pgprot)
51
52 #define __pte(x) ((pte_t) { (x) } )
53 #define __pmd(x) ((pmd_t) { (x) } )
54 #define __pgd(x) ((pgd_t) { (x) } )
55 #define __pgprot(x) ((pgprot_t) { (x) } )
56
57 #else
58
59
60
61 typedef unsigned long pte_t;
62 typedef unsigned long pmd_t;
63 typedef unsigned long pgd_t;
64 typedef unsigned long pgprot_t;
65
66 #define pte_val(x) (x)
67 #define pmd_val(x) (x)
68 #define pgd_val(x) (x)
69 #define pgprot_val(x) (x)
70
71 #define __pte(x) (x)
72 #define __pmd(x) (x)
73 #define __pgd(x) (x)
74 #define __pgprot(x) (x)
75
76 #endif
77
78
79
80
81
82 #define invalidate() flush_vac_context()
83
84
85 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
86
87 #define PAGE_OFFSET 0
88 #define MAP_NR(addr) (((unsigned long)(addr)) >> PAGE_SHIFT)
89 #define MAP_PAGE_RESERVED (1<<15)
90
91
92 #endif
93
94
95
96
97
98
99
100
101
102 #define PTE_V 0x80000000
103 #define PTE_ACC 0x60000000
104 #define PTE_W 0x40000000
105 #define PTE_P 0x20000000
106 #define PTE_NC 0x10000000
107 #define PTE_TYP 0x0c000000
108 #define PTE_RMEM 0x00000000
109 #define PTE_IO 0x04000000
110 #define PTE_VME16 0x08000000
111 #define PTE_VME32 0x0c000000
112 #define PTE_R 0x02000000
113 #define PTE_M 0x01000000
114 #define PTE_RESV 0x00f80000
115 #define PTE_PHYPG 0x0007ffff
116
117 extern __inline__ unsigned long get_segmap(unsigned long addr)
118 {
119 register unsigned long entry;
120
121 __asm__ __volatile__("lduba [%1] 0x3, %0" :
122 "=r" (entry) :
123 "r" (addr));
124
125 return (entry&0x7f);
126 }
127
128 extern __inline__ void put_segmap(unsigned long addr, unsigned long entry)
129 {
130
131 __asm__ __volatile__("stba %1, [%0] 0x3" : : "r" (addr), "r" (entry&0x7f));
132
133 return;
134 }
135
136 extern __inline__ unsigned long get_pte(unsigned long addr)
137 {
138 register unsigned long entry;
139
140 __asm__ __volatile__("lda [%1] 0x4, %0" :
141 "=r" (entry) :
142 "r" (addr));
143 return entry;
144 }
145
146 extern __inline__ void put_pte(unsigned long addr, unsigned long entry)
147 {
148 __asm__ __volatile__("sta %1, [%0] 0x4" : :
149 "r" (addr),
150 "r" (entry));
151
152 return;
153 }
154
155 extern __inline__ void switch_to_context(int context)
156 {
157 __asm__ __volatile__("stba %0, [%1] 0x2" : :
158 "r" (context),
159 "r" (0x30000000));
160
161 return;
162 }
163
164 extern __inline__ int get_context(void)
165 {
166 register int ctx;
167
168 __asm__ __volatile__("lduba [%1] 0x2, %0" :
169 "=r" (ctx) :
170 "r" (0x30000000));
171
172 return ctx;
173 }
174
175 typedef unsigned short mem_map_t;
176
177 #endif
178
179 #endif