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
14
15
16
17 #define invalidate() flush_vac_context()
18
19
20 #define PAGE_SHIFT 12
21 #define PGDIR_SHIFT 18
22 #define PAGE_SIZE 4096
23 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
24
25 #define PAGE_OFFSET 0
26 #define MAP_NR(addr) (((addr)) >> PAGE_SHIFT)
27 #define MAP_PAGE_RESERVED (1<<31)
28
29
30
31 #define PAGE_PRESENT 0x001
32 #define PAGE_RW 0x002
33 #define PAGE_USER 0x004
34 #define PAGE_ACCESSED 0x020
35 #define PAGE_DIRTY 0x040
36 #define PAGE_COW 0x200
37
38 #define PAGE_PRIVATE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
39 #define PAGE_SHARED (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
40 #define PAGE_COPY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
41 #define PAGE_READONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
42 #define PAGE_EXECONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
43 #define PAGE_TABLE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
44
45 #define PAGE_CHG_MASK (PAGE_MASK | PAGE_ACCESSED | PAGE_DIRTY)
46
47 #ifdef __KERNEL__
48
49
50 #define BITS_PER_PTR (8*sizeof(unsigned long))
51
52
53 #define PAGE_MASK (~(PAGE_SIZE-1))
54
55
56 #define PGDIR_MASK (~(PGDIR_SIZE-1))
57
58
59 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
60 #define PGDIR_ALIGN(addr) (((addr)+PGDIR_SIZE-1)&PGDIR_MASK)
61
62
63 #define PTR_MASK (~(sizeof(void*)-1))
64
65
66 #define SIZEOF_PTR_LOG2 2
67
68
69
70
71
72
73
74 #define PAGE_DIR_OFFSET(base, address) ((unsigned long *) 0)
75 #define PAGE_PTR(address) ((unsigned long) 0)
76 #define PTRS_PER_PAGE (64)
77
78
79
80 #define PTE_V 0x80000000
81 #define PTE_ACC 0x60000000
82 #define PTE_W 0x40000000
83 #define PTE_P 0x20000000
84 #define PTE_NC 0x10000000
85 #define PTE_TYP 0x0c000000
86 #define PTE_RMEM 0x00000000
87 #define PTE_IO 0x04000000
88 #define PTE_VME16 0x08000000
89 #define PTE_VME32 0x0c000000
90 #define PTE_R 0x02000000
91 #define PTE_M 0x01000000
92 #define PTE_RESV 0x00f80000
93 #define PTE_PHYPG 0x0007ffff
94
95
96
97
98
99 #ifndef __ASSEMBLY__
100
101
102
103
104
105
106
107 extern unsigned long __bad_page(void);
108 extern unsigned long __bad_pagetable(void);
109 extern unsigned long __zero_page(void);
110
111 typedef unsigned int mem_map_t;
112
113 #define BAD_PAGETABLE __bad_pagetable()
114 #define BAD_PAGE __bad_page()
115 #define ZERO_PAGE __zero_page()
116
117 extern __inline__ unsigned long get_segmap(unsigned long addr)
118 {
119 register unsigned long entry;
120
121 __asm__ __volatile__("lduha [%1] 0x3, %0" :
122 "=r" (entry) :
123 "r" (addr));
124
125 return entry;
126 }
127
128 extern __inline__ void put_segmap(unsigned long* addr, unsigned long entry)
129 {
130
131 __asm__ __volatile__("stha %1, [%0] 0x3" : : "r" (addr), "r" (entry));
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
176
177
178
179
180
181 #define SET_PAGE_DIR(tsk,pgdir)
182
183
184 #endif
185
186 #endif
187
188 #endif