Subversion Repositories HelenOS

Rev

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

Rev 3022 Rev 4055
Line 50... Line 50...
50
static void ptl0_destroy(pte_t *page_table);
50
static void ptl0_destroy(pte_t *page_table);
51
 
51
 
52
static void pt_lock(as_t *as, bool lock);
52
static void pt_lock(as_t *as, bool lock);
53
static void pt_unlock(as_t *as, bool unlock);
53
static void pt_unlock(as_t *as, bool unlock);
54
 
54
 
55
#ifdef __OBJC__
-
 
56
@implementation as_t
-
 
57
 
-
 
58
+ (pte_t *) page_table_create: (int) flags
-
 
59
{
-
 
60
    return ptl0_create(flags);
-
 
61
}
-
 
62
 
-
 
63
+ (void) page_table_destroy: (pte_t *) page_table
-
 
64
{
-
 
65
    ptl0_destroy(page_table);
-
 
66
}
-
 
67
 
-
 
68
- (void) page_table_lock: (bool) _lock
-
 
69
{
-
 
70
    pt_lock(self, _lock);
-
 
71
}
-
 
72
 
-
 
73
- (void) page_table_unlock: (bool) unlock
-
 
74
{
-
 
75
    pt_unlock(self, unlock);
-
 
76
}
-
 
77
 
-
 
78
@end
-
 
79
#else
-
 
80
as_operations_t as_pt_operations = {
55
as_operations_t as_pt_operations = {
81
    .page_table_create = ptl0_create,
56
    .page_table_create = ptl0_create,
82
    .page_table_destroy = ptl0_destroy,
57
    .page_table_destroy = ptl0_destroy,
83
    .page_table_lock = pt_lock,
58
    .page_table_lock = pt_lock,
84
    .page_table_unlock = pt_unlock
59
    .page_table_unlock = pt_unlock
85
};
60
};
86
#endif
-
 
87
 
61
 
88
/** Create PTL0.
62
/** Create PTL0.
89
 *
63
 *
90
 * PTL0 of 4-level page table will be created for each address space.
64
 * PTL0 of 4-level page table will be created for each address space.
91
 *
65
 *
Line 101... Line 75...
101
 
75
 
102
    dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE, FRAME_KA);
76
    dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE, FRAME_KA);
103
    table_size = FRAME_SIZE << PTL0_SIZE;
77
    table_size = FRAME_SIZE << PTL0_SIZE;
104
 
78
 
105
    if (flags & FLAG_AS_KERNEL) {
79
    if (flags & FLAG_AS_KERNEL) {
106
        memsetb((uintptr_t) dst_ptl0, table_size, 0);
80
        memsetb(dst_ptl0, table_size, 0);
107
    } else {
81
    } else {
108
        uintptr_t src, dst;
82
        uintptr_t src, dst;
109
   
83
   
110
        /*
84
        /*
111
         * Copy the kernel address space portion to new PTL0.
85
         * Copy the kernel address space portion to new PTL0.
Line 116... Line 90...
116
        src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
90
        src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
117
 
91
 
118
        src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
92
        src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
119
        dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
93
        dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
120
 
94
 
121
        memsetb((uintptr_t) dst_ptl0, table_size, 0);
95
        memsetb(dst_ptl0, table_size, 0);
122
        memcpy((void *) dst, (void *) src, table_size - (src - (uintptr_t) src_ptl0));
96
        memcpy((void *) dst, (void *) src, table_size - (src - (uintptr_t) src_ptl0));
123
        mutex_unlock(&AS_KERNEL->lock);
97
        mutex_unlock(&AS_KERNEL->lock);
124
        interrupts_restore(ipl);
98
        interrupts_restore(ipl);
125
    }
99
    }
126
 
100