Subversion Repositories HelenOS

Rev

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

Rev 2125 Rev 2465
Line 95... Line 95...
95
 */
95
 */
96
pte_t *ptl0_create(int flags)
96
pte_t *ptl0_create(int flags)
97
{
97
{
98
    pte_t *src_ptl0, *dst_ptl0;
98
    pte_t *src_ptl0, *dst_ptl0;
99
    ipl_t ipl;
99
    ipl_t ipl;
-
 
100
    int table_size;
100
 
101
 
101
    dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA);
102
    dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE, FRAME_KA);
-
 
103
    table_size = FRAME_SIZE << PTL0_SIZE;
102
 
104
 
103
    if (flags & FLAG_AS_KERNEL) {
105
    if (flags & FLAG_AS_KERNEL) {
104
        memsetb((uintptr_t) dst_ptl0, PAGE_SIZE, 0);
106
        memsetb((uintptr_t) dst_ptl0, table_size, 0);
105
    } else {
107
    } else {
106
        uintptr_t src, dst;
108
        uintptr_t src, dst;
107
   
109
   
108
        /*
110
        /*
109
         * Copy the kernel address space portion to new PTL0.
111
         * Copy the kernel address space portion to new PTL0.
Line 114... Line 116...
114
        src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
116
        src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
115
 
117
 
116
        src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
118
        src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
117
        dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
119
        dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
118
 
120
 
119
        memsetb((uintptr_t) dst_ptl0, PAGE_SIZE, 0);
121
        memsetb((uintptr_t) dst_ptl0, table_size, 0);
120
        memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (uintptr_t) src_ptl0));
122
        memcpy((void *) dst, (void *) src, table_size - (src - (uintptr_t) src_ptl0));
121
        mutex_unlock(&AS_KERNEL->lock);
123
        mutex_unlock(&AS_KERNEL->lock);
122
        interrupts_restore(ipl);
124
        interrupts_restore(ipl);
123
    }
125
    }
124
 
126
 
125
    return (pte_t *) KA2PA((uintptr_t) dst_ptl0);
127
    return (pte_t *) KA2PA((uintptr_t) dst_ptl0);