Changeset b07769b6 in mainline for src/mm/vm.c
- Timestamp:
- 2005-08-19T13:12:32Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4a61ef
- Parents:
- 6a4177a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mm/vm.c
r6a4177a rb07769b6 40 40 #include <panic.h> 41 41 #include <arch/asm.h> 42 #include <debug.h> 42 43 43 vm_t *vm_create(void) 44 #define KAS_START_INDEX PTL0_INDEX(KERNEL_ADDRESS_SPACE_START) 45 #define KAS_END_INDEX PTL0_INDEX(KERNEL_ADDRESS_SPACE_END) 46 #define KAS_INDICES (1+(KAS_END_INDEX-KAS_START_INDEX)) 47 48 vm_t *vm_create(pte_t *ptl0) 44 49 { 45 50 vm_t *m; … … 49 54 spinlock_initialize(&m->lock); 50 55 list_initialize(&m->vm_area_head); 51 m->ptl0 = NULL; 56 57 /* 58 * Each vm_t is supposed to have its own page table. 59 * It is either passed one or it has to allocate and set one up. 60 */ 61 if (!(m->ptl0 = ptl0)) { 62 pte_t *src_ptl0, *dst_ptl0; 63 64 src_ptl0 = (pte_t *) PA2KA(GET_PTL0_ADDRESS()); 65 dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC); 66 memsetb((__address) dst_ptl0, PAGE_SIZE, 0); 67 memcopy((__address) &src_ptl0[KAS_START_INDEX], (__address) &dst_ptl0[KAS_START_INDEX], KAS_INDICES*sizeof(pte_t)); 68 m->ptl0 = (pte_t *) KA2PA(dst_ptl0); 69 } 52 70 } 53 71 … … 110 128 } 111 129 112 void vm_area_map(vm_area_t *a )130 void vm_area_map(vm_area_t *a, vm_t *m) 113 131 { 114 132 int i, flags; … … 116 134 117 135 pri = cpu_priority_high(); 136 spinlock_lock(&m->lock); 118 137 spinlock_lock(&a->lock); 119 138 … … 127 146 break; 128 147 default: 129 panic("unexpected vm_type_t %d", a->type); 148 panic("unexpected vm_type_t %d", a->type); 130 149 } 131 150 151 ASSERT(m->ptl0); 132 152 for (i=0; i<a->size; i++) 133 map_page_to_frame(a->address + i*PAGE_SIZE, a->mapping[i], flags, 0);153 map_page_to_frame(a->address + i*PAGE_SIZE, a->mapping[i], flags, (__address) m->ptl0); 134 154 135 155 spinlock_unlock(&a->lock); 156 spinlock_unlock(&m->lock); 136 157 cpu_priority_restore(pri); 137 158 } 138 159 139 void vm_area_unmap(vm_area_t *a )160 void vm_area_unmap(vm_area_t *a, vm_t *m) 140 161 { 141 162 int i; … … 143 164 144 165 pri = cpu_priority_high(); 166 spinlock_lock(&m->lock); 145 167 spinlock_lock(&a->lock); 146 168 169 ASSERT(m->ptl0); 147 170 for (i=0; i<a->size; i++) 148 map_page_to_frame(a->address + i*PAGE_SIZE, 0, PAGE_NOT_PRESENT, 0);171 map_page_to_frame(a->address + i*PAGE_SIZE, 0, PAGE_NOT_PRESENT, (__address) m->ptl0); 149 172 150 173 spinlock_unlock(&a->lock); 174 spinlock_unlock(&m->lock); 151 175 cpu_priority_restore(pri); 152 176 } … … 158 182 159 183 pri = cpu_priority_high(); 184 185 tlb_shootdown_start(); 160 186 spinlock_lock(&m->lock); 161 187 162 for(l = m->vm_area_head.next; l != &m->vm_area_head; l = l->next)163 vm_area_map(list_get_instance(l, vm_area_t, link));188 ASSERT(m->ptl0); 189 SET_PTL0_ADDRESS(m->ptl0); 164 190 165 191 spinlock_unlock(&m->lock); 166 cpu_priority_restore(pri);167 }168 169 void vm_uninstall(vm_t *m)170 {171 link_t *l;172 pri_t pri;173 174 pri = cpu_priority_high();175 176 tlb_shootdown_start();177 178 spinlock_lock(&m->lock);179 180 for(l = m->vm_area_head.next; l != &m->vm_area_head; l = l->next)181 vm_area_unmap(list_get_instance(l, vm_area_t, link));182 183 spinlock_unlock(&m->lock);184 185 192 tlb_shootdown_finalize(); 186 193
Note:
See TracChangeset
for help on using the changeset viewer.