Rev 1248 | Rev 1702 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1248 | Rev 1266 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2006 Jakub Jermar |
2 | * Copyright (C) 2006 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
- | 29 | /** |
|
- | 30 | * @file page_pt.c |
|
- | 31 | * @brief Virtual Address Translation for hierarchical 4-level page tables. |
|
- | 32 | */ |
|
- | 33 | ||
29 | #include <genarch/mm/page_pt.h> |
34 | #include <genarch/mm/page_pt.h> |
30 | #include <mm/page.h> |
35 | #include <mm/page.h> |
31 | #include <mm/frame.h> |
36 | #include <mm/frame.h> |
32 | #include <mm/as.h> |
37 | #include <mm/as.h> |
33 | #include <arch/mm/page.h> |
38 | #include <arch/mm/page.h> |
34 | #include <arch/mm/as.h> |
39 | #include <arch/mm/as.h> |
35 | #include <arch/types.h> |
40 | #include <arch/types.h> |
36 | #include <typedefs.h> |
41 | #include <typedefs.h> |
37 | #include <arch/asm.h> |
42 | #include <arch/asm.h> |
38 | #include <memstr.h> |
43 | #include <memstr.h> |
39 | 44 | ||
40 | static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags); |
45 | static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags); |
41 | static void pt_mapping_remove(as_t *as, __address page); |
46 | static void pt_mapping_remove(as_t *as, __address page); |
42 | static pte_t *pt_mapping_find(as_t *as, __address page); |
47 | static pte_t *pt_mapping_find(as_t *as, __address page); |
43 | 48 | ||
44 | page_mapping_operations_t pt_mapping_operations = { |
49 | page_mapping_operations_t pt_mapping_operations = { |
45 | .mapping_insert = pt_mapping_insert, |
50 | .mapping_insert = pt_mapping_insert, |
46 | .mapping_remove = pt_mapping_remove, |
51 | .mapping_remove = pt_mapping_remove, |
47 | .mapping_find = pt_mapping_find |
52 | .mapping_find = pt_mapping_find |
48 | }; |
53 | }; |
49 | 54 | ||
50 | /** Map page to frame using hierarchical page tables. |
55 | /** Map page to frame using hierarchical page tables. |
51 | * |
56 | * |
52 | * Map virtual address page to physical address frame |
57 | * Map virtual address page to physical address frame |
53 | * using flags. |
58 | * using flags. |
54 | * |
59 | * |
55 | * The page table must be locked and interrupts must be disabled. |
60 | * The page table must be locked and interrupts must be disabled. |
56 | * |
61 | * |
57 | * @param as Address space to wich page belongs. |
62 | * @param as Address space to wich page belongs. |
58 | * @param page Virtual address of the page to be mapped. |
63 | * @param page Virtual address of the page to be mapped. |
59 | * @param frame Physical address of memory frame to which the mapping is done. |
64 | * @param frame Physical address of memory frame to which the mapping is done. |
60 | * @param flags Flags to be used for mapping. |
65 | * @param flags Flags to be used for mapping. |
61 | */ |
66 | */ |
62 | void pt_mapping_insert(as_t *as, __address page, __address frame, int flags) |
67 | void pt_mapping_insert(as_t *as, __address page, __address frame, int flags) |
63 | { |
68 | { |
64 | pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
69 | pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
65 | __address newpt; |
70 | __address newpt; |
66 | 71 | ||
67 | ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
72 | ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
68 | 73 | ||
69 | if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { |
74 | if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { |
70 | newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
75 | newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
71 | memsetb(newpt, PAGE_SIZE, 0); |
76 | memsetb(newpt, PAGE_SIZE, 0); |
72 | SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); |
77 | SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); |
73 | SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
78 | SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
74 | } |
79 | } |
75 | 80 | ||
76 | ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
81 | ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
77 | 82 | ||
78 | if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { |
83 | if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { |
79 | newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
84 | newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
80 | memsetb(newpt, PAGE_SIZE, 0); |
85 | memsetb(newpt, PAGE_SIZE, 0); |
81 | SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); |
86 | SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); |
82 | SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
87 | SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
83 | } |
88 | } |
84 | 89 | ||
85 | ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
90 | ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
86 | 91 | ||
87 | if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { |
92 | if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { |
88 | newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
93 | newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
89 | memsetb(newpt, PAGE_SIZE, 0); |
94 | memsetb(newpt, PAGE_SIZE, 0); |
90 | SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); |
95 | SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); |
91 | SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
96 | SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
92 | } |
97 | } |
93 | 98 | ||
94 | ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
99 | ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
95 | 100 | ||
96 | SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); |
101 | SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); |
97 | SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags); |
102 | SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags); |
98 | } |
103 | } |
99 | 104 | ||
100 | /** Remove mapping of page from hierarchical page tables. |
105 | /** Remove mapping of page from hierarchical page tables. |
101 | * |
106 | * |
102 | * Remove any mapping of page within address space as. |
107 | * Remove any mapping of page within address space as. |
103 | * TLB shootdown should follow in order to make effects of |
108 | * TLB shootdown should follow in order to make effects of |
104 | * this call visible. |
109 | * this call visible. |
105 | * |
110 | * |
106 | * Empty page tables except PTL0 are freed. |
111 | * Empty page tables except PTL0 are freed. |
107 | * |
112 | * |
108 | * The page table must be locked and interrupts must be disabled. |
113 | * The page table must be locked and interrupts must be disabled. |
109 | * |
114 | * |
110 | * @param as Address space to wich page belongs. |
115 | * @param as Address space to wich page belongs. |
111 | * @param page Virtual address of the page to be demapped. |
116 | * @param page Virtual address of the page to be demapped. |
112 | */ |
117 | */ |
113 | void pt_mapping_remove(as_t *as, __address page) |
118 | void pt_mapping_remove(as_t *as, __address page) |
114 | { |
119 | { |
115 | pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
120 | pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
116 | bool empty = true; |
121 | bool empty = true; |
117 | int i; |
122 | int i; |
118 | 123 | ||
119 | /* |
124 | /* |
120 | * First, remove the mapping, if it exists. |
125 | * First, remove the mapping, if it exists. |
121 | */ |
126 | */ |
122 | 127 | ||
123 | ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
128 | ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
124 | 129 | ||
125 | if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) |
130 | if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) |
126 | return; |
131 | return; |
127 | 132 | ||
128 | ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
133 | ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
129 | 134 | ||
130 | if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) |
135 | if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) |
131 | return; |
136 | return; |
132 | 137 | ||
133 | ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
138 | ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
134 | 139 | ||
135 | if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) |
140 | if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) |
136 | return; |
141 | return; |
137 | 142 | ||
138 | ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
143 | ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
139 | 144 | ||
140 | /* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */ |
145 | /* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */ |
141 | memsetb((__address) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0); |
146 | memsetb((__address) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0); |
142 | 147 | ||
143 | /* |
148 | /* |
144 | * Second, free all empty tables along the way from PTL3 down to PTL0. |
149 | * Second, free all empty tables along the way from PTL3 down to PTL0. |
145 | */ |
150 | */ |
146 | 151 | ||
147 | /* check PTL3 */ |
152 | /* check PTL3 */ |
148 | for (i = 0; i < PTL3_ENTRIES; i++) { |
153 | for (i = 0; i < PTL3_ENTRIES; i++) { |
149 | if (PTE_VALID(&ptl3[i])) { |
154 | if (PTE_VALID(&ptl3[i])) { |
150 | empty = false; |
155 | empty = false; |
151 | break; |
156 | break; |
152 | } |
157 | } |
153 | } |
158 | } |
154 | if (empty) { |
159 | if (empty) { |
155 | /* |
160 | /* |
156 | * PTL3 is empty. |
161 | * PTL3 is empty. |
157 | * Release the frame and remove PTL3 pointer from preceding table. |
162 | * Release the frame and remove PTL3 pointer from preceding table. |
158 | */ |
163 | */ |
159 | frame_free(ADDR2PFN(KA2PA((__address) ptl3))); |
164 | frame_free(ADDR2PFN(KA2PA((__address) ptl3))); |
160 | if (PTL2_ENTRIES) |
165 | if (PTL2_ENTRIES) |
161 | memsetb((__address) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0); |
166 | memsetb((__address) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0); |
162 | else if (PTL1_ENTRIES) |
167 | else if (PTL1_ENTRIES) |
163 | memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0); |
168 | memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0); |
164 | else |
169 | else |
165 | memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
170 | memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
166 | } else { |
171 | } else { |
167 | /* |
172 | /* |
168 | * PTL3 is not empty. |
173 | * PTL3 is not empty. |
169 | * Therefore, there must be a path from PTL0 to PTL3 and |
174 | * Therefore, there must be a path from PTL0 to PTL3 and |
170 | * thus nothing to free in higher levels. |
175 | * thus nothing to free in higher levels. |
171 | */ |
176 | */ |
172 | return; |
177 | return; |
173 | } |
178 | } |
174 | 179 | ||
175 | /* check PTL2, empty is still true */ |
180 | /* check PTL2, empty is still true */ |
176 | if (PTL2_ENTRIES) { |
181 | if (PTL2_ENTRIES) { |
177 | for (i = 0; i < PTL2_ENTRIES; i++) { |
182 | for (i = 0; i < PTL2_ENTRIES; i++) { |
178 | if (PTE_VALID(&ptl2[i])) { |
183 | if (PTE_VALID(&ptl2[i])) { |
179 | empty = false; |
184 | empty = false; |
180 | break; |
185 | break; |
181 | } |
186 | } |
182 | } |
187 | } |
183 | if (empty) { |
188 | if (empty) { |
184 | /* |
189 | /* |
185 | * PTL2 is empty. |
190 | * PTL2 is empty. |
186 | * Release the frame and remove PTL2 pointer from preceding table. |
191 | * Release the frame and remove PTL2 pointer from preceding table. |
187 | */ |
192 | */ |
188 | frame_free(ADDR2PFN(KA2PA((__address) ptl2))); |
193 | frame_free(ADDR2PFN(KA2PA((__address) ptl2))); |
189 | if (PTL1_ENTRIES) |
194 | if (PTL1_ENTRIES) |
190 | memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0); |
195 | memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0); |
191 | else |
196 | else |
192 | memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
197 | memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
193 | } |
198 | } |
194 | else { |
199 | else { |
195 | /* |
200 | /* |
196 | * PTL2 is not empty. |
201 | * PTL2 is not empty. |
197 | * Therefore, there must be a path from PTL0 to PTL2 and |
202 | * Therefore, there must be a path from PTL0 to PTL2 and |
198 | * thus nothing to free in higher levels. |
203 | * thus nothing to free in higher levels. |
199 | */ |
204 | */ |
200 | return; |
205 | return; |
201 | } |
206 | } |
202 | } |
207 | } |
203 | 208 | ||
204 | /* check PTL1, empty is still true */ |
209 | /* check PTL1, empty is still true */ |
205 | if (PTL1_ENTRIES) { |
210 | if (PTL1_ENTRIES) { |
206 | for (i = 0; i < PTL1_ENTRIES; i++) { |
211 | for (i = 0; i < PTL1_ENTRIES; i++) { |
207 | if (PTE_VALID(&ptl1[i])) { |
212 | if (PTE_VALID(&ptl1[i])) { |
208 | empty = false; |
213 | empty = false; |
209 | break; |
214 | break; |
210 | } |
215 | } |
211 | } |
216 | } |
212 | if (empty) { |
217 | if (empty) { |
213 | /* |
218 | /* |
214 | * PTL1 is empty. |
219 | * PTL1 is empty. |
215 | * Release the frame and remove PTL1 pointer from preceding table. |
220 | * Release the frame and remove PTL1 pointer from preceding table. |
216 | */ |
221 | */ |
217 | frame_free(ADDR2PFN(KA2PA((__address) ptl1))); |
222 | frame_free(ADDR2PFN(KA2PA((__address) ptl1))); |
218 | memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
223 | memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
219 | } |
224 | } |
220 | } |
225 | } |
221 | 226 | ||
222 | } |
227 | } |
223 | 228 | ||
224 | /** Find mapping for virtual page in hierarchical page tables. |
229 | /** Find mapping for virtual page in hierarchical page tables. |
225 | * |
230 | * |
226 | * Find mapping for virtual page. |
231 | * Find mapping for virtual page. |
227 | * |
232 | * |
228 | * The page table must be locked and interrupts must be disabled. |
233 | * The page table must be locked and interrupts must be disabled. |
229 | * |
234 | * |
230 | * @param as Address space to which page belongs. |
235 | * @param as Address space to which page belongs. |
231 | * @param page Virtual page. |
236 | * @param page Virtual page. |
232 | * |
237 | * |
233 | * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise. |
238 | * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise. |
234 | */ |
239 | */ |
235 | pte_t *pt_mapping_find(as_t *as, __address page) |
240 | pte_t *pt_mapping_find(as_t *as, __address page) |
236 | { |
241 | { |
237 | pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
242 | pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
238 | 243 | ||
239 | ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
244 | ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
240 | 245 | ||
241 | if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) |
246 | if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) |
242 | return NULL; |
247 | return NULL; |
243 | 248 | ||
244 | ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
249 | ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
245 | 250 | ||
246 | if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) |
251 | if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) |
247 | return NULL; |
252 | return NULL; |
248 | 253 | ||
249 | ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
254 | ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
250 | 255 | ||
251 | if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) |
256 | if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) |
252 | return NULL; |
257 | return NULL; |
253 | 258 | ||
254 | ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
259 | ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
255 | 260 | ||
256 | return &ptl3[PTL3_INDEX(page)]; |
261 | return &ptl3[PTL3_INDEX(page)]; |
257 | } |
262 | } |
258 | 263 |