Subversion Repositories HelenOS-historic

Rev

Rev 755 | Rev 762 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 755 Rev 756
Line 27... Line 27...
27
 */
27
 */
28
 
28
 
29
#include <genarch/mm/page_pt.h>
29
#include <genarch/mm/page_pt.h>
30
#include <mm/page.h>
30
#include <mm/page.h>
31
#include <mm/frame.h>
31
#include <mm/frame.h>
-
 
32
#include <mm/as.h>
32
#include <arch/mm/page.h>
33
#include <arch/mm/page.h>
33
#include <arch/mm/as.h>
34
#include <arch/mm/as.h>
34
#include <arch/types.h>
35
#include <arch/types.h>
35
#include <typedefs.h>
36
#include <typedefs.h>
36
#include <arch/asm.h>
37
#include <arch/asm.h>
37
#include <memstr.h>
38
#include <memstr.h>
38
 
39
 
39
static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root);
40
static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags);
40
static pte_t *pt_mapping_find(as_t *as, __address page, __address root);
41
static pte_t *pt_mapping_find(as_t *as, __address page);
41
 
42
 
42
page_operations_t page_pt_operations = {
43
page_operations_t page_pt_operations = {
43
    .mapping_insert = pt_mapping_insert,
44
    .mapping_insert = pt_mapping_insert,
44
    .mapping_find = pt_mapping_find
45
    .mapping_find = pt_mapping_find
45
};
46
};
Line 47... Line 48...
47
/** Map page to frame using hierarchical page tables.
48
/** Map page to frame using hierarchical page tables.
48
 *
49
 *
49
 * Map virtual address 'page' to physical address 'frame'
50
 * Map virtual address 'page' to physical address 'frame'
50
 * using 'flags'.
51
 * using 'flags'.
51
 *
52
 *
-
 
53
 * The address space must be locked and interrupts must be disabled.
-
 
54
 *
52
 * @param as Ignored.
55
 * @param as Address space to wich page belongs.
53
 * @param page Virtual address of the page to be mapped.
56
 * @param page Virtual address of the page to be mapped.
54
 * @param frame Physical address of memory frame to which the mapping is done.
57
 * @param frame Physical address of memory frame to which the mapping is done.
55
 * @param flags Flags to be used for mapping.
58
 * @param flags Flags to be used for mapping.
56
 * @param root Explicit PTL0 address.
-
 
57
 */
59
 */
58
void pt_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root)
60
void pt_mapping_insert(as_t *as, __address page, __address frame, int flags)
59
{
61
{
60
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
62
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
61
    __address newpt;
63
    __address newpt;
62
 
64
 
63
    ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS());
65
    ptl0 = (pte_t *) PA2KA((__address) as->page_table);
64
 
66
 
65
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
67
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
66
        newpt = frame_alloc(FRAME_KA, ONE_FRAME, NULL);
68
        newpt = frame_alloc(FRAME_KA, ONE_FRAME, NULL);
67
        memsetb(newpt, PAGE_SIZE, 0);
69
        memsetb(newpt, PAGE_SIZE, 0);
68
        SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
70
        SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
Line 95... Line 97...
95
 
97
 
96
/** Find mapping for virtual page in hierarchical page tables.
98
/** Find mapping for virtual page in hierarchical page tables.
97
 *
99
 *
98
 * Find mapping for virtual page.
100
 * Find mapping for virtual page.
99
 *
101
 *
-
 
102
 * The address space must be locked and interrupts must be disabled.
-
 
103
 *
100
 * @param as Ignored.
104
 * @param as Address space to which page belongs.
101
 * @param page Virtual page.
105
 * @param page Virtual page.
102
 * @param root PTL0 address if non-zero.
-
 
103
 *
106
 *
104
 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise.
107
 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise.
105
 */
108
 */
106
pte_t *pt_mapping_find(as_t *as, __address page, __address root)
109
pte_t *pt_mapping_find(as_t *as, __address page)
107
{
110
{
108
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
111
    pte_t *ptl0, *ptl1, *ptl2, *ptl3;
109
 
112
 
110
    ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS());
113
    ptl0 = (pte_t *) PA2KA((__address) as->page_table);
111
 
114
 
112
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
115
    if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
113
        return NULL;
116
        return NULL;
114
 
117
 
115
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
118
    ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));