Subversion Repositories HelenOS-historic

Rev

Rev 1767 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1767 Rev 1780
Line 74... Line 74...
74
    ipl_t ipl;
74
    ipl_t ipl;
75
 
75
 
76
    dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA);
76
    dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA);
77
 
77
 
78
    if (flags & FLAG_AS_KERNEL) {
78
    if (flags & FLAG_AS_KERNEL) {
79
        memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
79
        memsetb((uintptr_t) dst_ptl0, PAGE_SIZE, 0);
80
    } else {
80
    } else {
81
        __address src, dst;
81
        uintptr_t src, dst;
82
   
82
   
83
        /*
83
        /*
84
         * Copy the kernel address space portion to new PTL0.
84
         * Copy the kernel address space portion to new PTL0.
85
         */
85
         */
86
         
86
         
87
        ipl = interrupts_disable();
87
        ipl = interrupts_disable();
88
        mutex_lock(&AS_KERNEL->lock);      
88
        mutex_lock(&AS_KERNEL->lock);      
89
        src_ptl0 = (pte_t *) PA2KA((__address) AS_KERNEL->page_table);
89
        src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->page_table);
90
 
90
 
91
        src = (__address) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
91
        src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
92
        dst = (__address) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
92
        dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
93
 
93
 
94
        memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
94
        memsetb((uintptr_t) dst_ptl0, PAGE_SIZE, 0);
95
        memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (__address) src_ptl0));
95
        memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (uintptr_t) src_ptl0));
96
        mutex_unlock(&AS_KERNEL->lock);
96
        mutex_unlock(&AS_KERNEL->lock);
97
        interrupts_restore(ipl);
97
        interrupts_restore(ipl);
98
    }
98
    }
99
 
99
 
100
    return (pte_t *) KA2PA((__address) dst_ptl0);
100
    return (pte_t *) KA2PA((uintptr_t) dst_ptl0);
101
}
101
}
102
 
102
 
103
/** Destroy page table.
103
/** Destroy page table.
104
 *
104
 *
105
 * Destroy PTL0, other levels are expected to be already deallocated.
105
 * Destroy PTL0, other levels are expected to be already deallocated.
106
 *
106
 *
107
 * @param page_table Physical address of PTL0.
107
 * @param page_table Physical address of PTL0.
108
 */
108
 */
109
void ptl0_destroy(pte_t *page_table)
109
void ptl0_destroy(pte_t *page_table)
110
{
110
{
111
    frame_free((__address)page_table);
111
    frame_free((uintptr_t)page_table);
112
}
112
}
113
 
113
 
114
/** Lock page tables.
114
/** Lock page tables.
115
 *
115
 *
116
 * Lock only the address space.
116
 * Lock only the address space.