Subversion Repositories HelenOS-historic

Rev

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

Rev 1266 Rev 1380
Line 33... Line 33...
33
 
33
 
34
#include <genarch/mm/page_pt.h>
34
#include <genarch/mm/page_pt.h>
35
#include <mm/page.h>
35
#include <mm/page.h>
36
#include <mm/frame.h>
36
#include <mm/frame.h>
37
#include <mm/as.h>
37
#include <mm/as.h>
-
 
38
#include <synch/mutex.h>
38
#include <arch/mm/page.h>
39
#include <arch/mm/page.h>
39
#include <arch/mm/as.h>
40
#include <arch/mm/as.h>
40
#include <arch/types.h>
41
#include <arch/types.h>
41
#include <typedefs.h>
42
#include <typedefs.h>
42
#include <memstr.h>
43
#include <memstr.h>
Line 76... Line 77...
76
        /*
77
        /*
77
         * Copy the kernel address space portion to new PTL0.
78
         * Copy the kernel address space portion to new PTL0.
78
         */
79
         */
79
         
80
         
80
        ipl = interrupts_disable();
81
        ipl = interrupts_disable();
81
        spinlock_lock(&AS_KERNEL->lock);       
82
        mutex_lock(&AS_KERNEL->lock);      
82
        src_ptl0 = (pte_t *) PA2KA((__address) AS_KERNEL->page_table);
83
        src_ptl0 = (pte_t *) PA2KA((__address) AS_KERNEL->page_table);
83
 
84
 
84
        src = (__address) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
85
        src = (__address) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
85
        dst = (__address) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
86
        dst = (__address) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
86
 
87
 
87
        memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
88
        memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
88
        memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (__address) src_ptl0));
89
        memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (__address) src_ptl0));
89
        spinlock_unlock(&AS_KERNEL->lock);
90
        mutex_unlock(&AS_KERNEL->lock);
90
        interrupts_restore(ipl);
91
        interrupts_restore(ipl);
91
    }
92
    }
92
 
93
 
93
    return (pte_t *) KA2PA((__address) dst_ptl0);
94
    return (pte_t *) KA2PA((__address) dst_ptl0);
94
}
95
}
Line 102... Line 103...
102
 * @param lock If false, do not attempt to lock the address space.
103
 * @param lock If false, do not attempt to lock the address space.
103
 */
104
 */
104
void pt_lock(as_t *as, bool lock)
105
void pt_lock(as_t *as, bool lock)
105
{
106
{
106
    if (lock)
107
    if (lock)
107
        spinlock_lock(&as->lock);
108
        mutex_lock(&as->lock);
108
}
109
}
109
 
110
 
110
/** Unlock page tables.
111
/** Unlock page tables.
111
 *
112
 *
112
 * Unlock the address space.
113
 * Unlock the address space.
Line 116... Line 117...
116
 * @param unlock If false, do not attempt to unlock the address space.
117
 * @param unlock If false, do not attempt to unlock the address space.
117
 */
118
 */
118
void pt_unlock(as_t *as, bool unlock)
119
void pt_unlock(as_t *as, bool unlock)
119
{
120
{
120
    if (unlock)
121
    if (unlock)
121
        spinlock_unlock(&as->lock);
122
        mutex_unlock(&as->lock);
122
}
123
}