Subversion Repositories HelenOS

Rev

Rev 2071 | Rev 2106 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2071 Rev 2089
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
/** @addtogroup genarchmm
29
/** @addtogroup genarchmm
30
 * @{
30
 * @{
31
 */
31
 */
32
 
32
 
33
/**
33
/**
34
 * @file
34
 * @file
35
 * @brief   Virtual Address Translation for hierarchical 4-level page tables.
35
 * @brief   Virtual Address Translation for hierarchical 4-level page tables.
36
 */
36
 */
37
 
37
 
38
#include <genarch/mm/page_pt.h>
38
#include <genarch/mm/page_pt.h>
39
#include <mm/page.h>
39
#include <mm/page.h>
40
#include <mm/frame.h>
40
#include <mm/frame.h>
41
#include <mm/as.h>
41
#include <mm/as.h>
42
#include <arch/mm/page.h>
42
#include <arch/mm/page.h>
43
#include <arch/mm/as.h>
43
#include <arch/mm/as.h>
44
#include <arch/types.h>
44
#include <arch/types.h>
45
#include <typedefs.h>
-
 
46
#include <arch/asm.h>
45
#include <arch/asm.h>
47
#include <memstr.h>
46
#include <memstr.h>
48
 
47
 
49
static void pt_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags);
48
static void pt_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags);
50
static void pt_mapping_remove(as_t *as, uintptr_t page);
49
static void pt_mapping_remove(as_t *as, uintptr_t page);
51
static pte_t *pt_mapping_find(as_t *as, uintptr_t page);
50
static pte_t *pt_mapping_find(as_t *as, uintptr_t page);
52
 
51
 
53
page_mapping_operations_t pt_mapping_operations = {
52
page_mapping_operations_t pt_mapping_operations = {
54
    .mapping_insert = pt_mapping_insert,
53
    .mapping_insert = pt_mapping_insert,
55
    .mapping_remove = pt_mapping_remove,
54
    .mapping_remove = pt_mapping_remove,
56
    .mapping_find = pt_mapping_find
55
    .mapping_find = pt_mapping_find
57
};
56
};
58
 
57
 
59
/** Map page to frame using hierarchical page tables.
58
/** Map page to frame using hierarchical page tables.
60
 *
59
 *
61
 * Map virtual address page to physical address frame
60
 * Map virtual address page to physical address frame
62
 * using flags.
61
 * using flags.
63
 *
62
 *
64
 * The page table must be locked and interrupts must be disabled.
63
 * The page table must be locked and interrupts must be disabled.
65
 *
64
 *
66
 * @param as Address space to wich page belongs.
65
 * @param as Address space to wich page belongs.
67
 * @param page Virtual address of the page to be mapped.
66
 * @param page Virtual address of the page to be mapped.
68
 * @param frame Physical address of memory frame to which the mapping is done.
67
 * @param frame Physical address of memory frame to which the mapping is done.
69
 * @param flags Flags to be used for mapping.
68
 * @param flags Flags to be used for mapping.
70
 */
69
 */
71
void pt_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
70
void pt_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
72
{
71
{
73
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
72
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
74
    pte_t *newpt;
73
    pte_t *newpt;
75
 
74
 
76
    ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
75
    ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
77
 
76
 
78
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
77
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
79
        newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
78
        newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
80
        memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
79
        memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
81
        SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
80
        SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
82
        SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
81
        SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
83
    }
82
    }
84
 
83
 
85
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
84
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
86
 
85
 
87
    if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
86
    if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
88
        newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
87
        newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
89
        memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
88
        memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
90
        SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
89
        SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
91
        SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
90
        SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
92
    }
91
    }
93
 
92
 
94
    ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
93
    ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
95
 
94
 
96
    if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
95
    if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
97
        newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
96
        newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
98
        memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
97
        memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
99
        SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
98
        SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
100
        SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
99
        SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
101
    }
100
    }
102
 
101
 
103
    ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
102
    ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
104
 
103
 
105
    SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
104
    SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
106
    SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags);
105
    SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags);
107
}
106
}
108
 
107
 
109
/** Remove mapping of page from hierarchical page tables.
108
/** Remove mapping of page from hierarchical page tables.
110
 *
109
 *
111
 * Remove any mapping of page within address space as.
110
 * Remove any mapping of page within address space as.
112
 * TLB shootdown should follow in order to make effects of
111
 * TLB shootdown should follow in order to make effects of
113
 * this call visible.
112
 * this call visible.
114
 *
113
 *
115
 * Empty page tables except PTL0 are freed.
114
 * Empty page tables except PTL0 are freed.
116
 *
115
 *
117
 * The page table must be locked and interrupts must be disabled.
116
 * The page table must be locked and interrupts must be disabled.
118
 *
117
 *
119
 * @param as Address space to wich page belongs.
118
 * @param as Address space to wich page belongs.
120
 * @param page Virtual address of the page to be demapped.
119
 * @param page Virtual address of the page to be demapped.
121
 */
120
 */
122
void pt_mapping_remove(as_t *as, uintptr_t page)
121
void pt_mapping_remove(as_t *as, uintptr_t page)
123
{
122
{
124
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
123
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
125
    bool empty = true;
124
    bool empty = true;
126
    int i;
125
    int i;
127
 
126
 
128
    /*
127
    /*
129
     * First, remove the mapping, if it exists.
128
     * First, remove the mapping, if it exists.
130
     */
129
     */
131
 
130
 
132
    ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
131
    ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
133
 
132
 
134
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
133
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
135
        return;
134
        return;
136
 
135
 
137
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
136
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
138
 
137
 
139
    if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
138
    if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
140
        return;
139
        return;
141
 
140
 
142
    ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
141
    ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
143
 
142
 
144
    if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
143
    if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
145
        return;
144
        return;
146
 
145
 
147
    ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
146
    ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
148
 
147
 
149
    /* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */
148
    /* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */
150
    memsetb((uintptr_t) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0);
149
    memsetb((uintptr_t) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0);
151
 
150
 
152
    /*
151
    /*
153
     * Second, free all empty tables along the way from PTL3 down to PTL0.
152
     * Second, free all empty tables along the way from PTL3 down to PTL0.
154
     */
153
     */
155
   
154
   
156
    /* check PTL3 */
155
    /* check PTL3 */
157
    for (i = 0; i < PTL3_ENTRIES; i++) {
156
    for (i = 0; i < PTL3_ENTRIES; i++) {
158
        if (PTE_VALID(&ptl3[i])) {
157
        if (PTE_VALID(&ptl3[i])) {
159
            empty = false;
158
            empty = false;
160
            break;
159
            break;
161
        }
160
        }
162
    }
161
    }
163
    if (empty) {
162
    if (empty) {
164
        /*
163
        /*
165
         * PTL3 is empty.
164
         * PTL3 is empty.
166
         * Release the frame and remove PTL3 pointer from preceding table.
165
         * Release the frame and remove PTL3 pointer from preceding table.
167
         */
166
         */
168
        frame_free(KA2PA((uintptr_t) ptl3));
167
        frame_free(KA2PA((uintptr_t) ptl3));
169
        if (PTL2_ENTRIES)
168
        if (PTL2_ENTRIES)
170
            memsetb((uintptr_t) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0);
169
            memsetb((uintptr_t) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0);
171
        else if (PTL1_ENTRIES)
170
        else if (PTL1_ENTRIES)
172
            memsetb((uintptr_t) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
171
            memsetb((uintptr_t) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
173
        else
172
        else
174
            memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
173
            memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
175
    } else {
174
    } else {
176
        /*
175
        /*
177
         * PTL3 is not empty.
176
         * PTL3 is not empty.
178
         * Therefore, there must be a path from PTL0 to PTL3 and
177
         * Therefore, there must be a path from PTL0 to PTL3 and
179
         * thus nothing to free in higher levels.
178
         * thus nothing to free in higher levels.
180
         */
179
         */
181
        return;
180
        return;
182
    }
181
    }
183
   
182
   
184
    /* check PTL2, empty is still true */
183
    /* check PTL2, empty is still true */
185
    if (PTL2_ENTRIES) {
184
    if (PTL2_ENTRIES) {
186
        for (i = 0; i < PTL2_ENTRIES; i++) {
185
        for (i = 0; i < PTL2_ENTRIES; i++) {
187
            if (PTE_VALID(&ptl2[i])) {
186
            if (PTE_VALID(&ptl2[i])) {
188
                empty = false;
187
                empty = false;
189
                break;
188
                break;
190
            }
189
            }
191
        }
190
        }
192
        if (empty) {
191
        if (empty) {
193
            /*
192
            /*
194
             * PTL2 is empty.
193
             * PTL2 is empty.
195
             * Release the frame and remove PTL2 pointer from preceding table.
194
             * Release the frame and remove PTL2 pointer from preceding table.
196
             */
195
             */
197
            frame_free(KA2PA((uintptr_t) ptl2));
196
            frame_free(KA2PA((uintptr_t) ptl2));
198
            if (PTL1_ENTRIES)
197
            if (PTL1_ENTRIES)
199
                memsetb((uintptr_t) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
198
                memsetb((uintptr_t) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
200
            else
199
            else
201
                memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
200
                memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
202
        }
201
        }
203
        else {
202
        else {
204
            /*
203
            /*
205
             * PTL2 is not empty.
204
             * PTL2 is not empty.
206
             * Therefore, there must be a path from PTL0 to PTL2 and
205
             * Therefore, there must be a path from PTL0 to PTL2 and
207
             * thus nothing to free in higher levels.
206
             * thus nothing to free in higher levels.
208
             */
207
             */
209
            return;
208
            return;
210
        }
209
        }
211
    }
210
    }
212
 
211
 
213
    /* check PTL1, empty is still true */
212
    /* check PTL1, empty is still true */
214
    if (PTL1_ENTRIES) {
213
    if (PTL1_ENTRIES) {
215
        for (i = 0; i < PTL1_ENTRIES; i++) {
214
        for (i = 0; i < PTL1_ENTRIES; i++) {
216
            if (PTE_VALID(&ptl1[i])) {
215
            if (PTE_VALID(&ptl1[i])) {
217
                empty = false;
216
                empty = false;
218
                break;
217
                break;
219
            }
218
            }
220
        }
219
        }
221
        if (empty) {
220
        if (empty) {
222
            /*
221
            /*
223
             * PTL1 is empty.
222
             * PTL1 is empty.
224
             * Release the frame and remove PTL1 pointer from preceding table.
223
             * Release the frame and remove PTL1 pointer from preceding table.
225
             */
224
             */
226
            frame_free(KA2PA((uintptr_t) ptl1));
225
            frame_free(KA2PA((uintptr_t) ptl1));
227
            memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
226
            memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
228
        }
227
        }
229
    }
228
    }
230
 
229
 
231
}
230
}
232
 
231
 
233
/** Find mapping for virtual page in hierarchical page tables.
232
/** Find mapping for virtual page in hierarchical page tables.
234
 *
233
 *
235
 * Find mapping for virtual page.
234
 * Find mapping for virtual page.
236
 *
235
 *
237
 * The page table must be locked and interrupts must be disabled.
236
 * The page table must be locked and interrupts must be disabled.
238
 *
237
 *
239
 * @param as Address space to which page belongs.
238
 * @param as Address space to which page belongs.
240
 * @param page Virtual page.
239
 * @param page Virtual page.
241
 *
240
 *
242
 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise.
241
 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise.
243
 */
242
 */
244
pte_t *pt_mapping_find(as_t *as, uintptr_t page)
243
pte_t *pt_mapping_find(as_t *as, uintptr_t page)
245
{
244
{
246
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
245
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
247
 
246
 
248
    ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
247
    ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
249
 
248
 
250
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
249
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
251
        return NULL;
250
        return NULL;
252
 
251
 
253
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
252
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
254
 
253
 
255
    if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
254
    if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
256
        return NULL;
255
        return NULL;
257
 
256
 
258
    ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
257
    ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
259
 
258
 
260
    if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
259
    if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
261
        return NULL;
260
        return NULL;
262
 
261
 
263
    ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
262
    ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
264
 
263
 
265
    return &ptl3[PTL3_INDEX(page)];
264
    return &ptl3[PTL3_INDEX(page)];
266
}
265
}
267
 
266
 
268
/** @}
267
/** @}
269
 */
268
 */
270
 
269