Changeset ef67bab in mainline for generic/src/mm
- Timestamp:
- 2006-02-01T00:02:16Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 071a8ae6
- Parents:
- fc1e4f6
- Location:
- generic/src/mm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/mm/as.c
rfc1e4f6 ref67bab 34 34 35 35 #include <mm/as.h> 36 #include < mm/asid.h>36 #include <arch/mm/as.h> 37 37 #include <mm/page.h> 38 38 #include <mm/frame.h> … … 43 43 #include <mm/asid.h> 44 44 #include <arch/mm/asid.h> 45 #include <arch/mm/as.h>46 45 #include <arch/types.h> 47 46 #include <typedefs.h> … … 56 55 #include <print.h> 57 56 58 #define KAS_START_INDEX PTL0_INDEX(KERNEL_ADDRESS_SPACE_START) 59 #define KAS_END_INDEX PTL0_INDEX(KERNEL_ADDRESS_SPACE_END) 60 #define KAS_INDICES (1+(KAS_END_INDEX-KAS_START_INDEX)) 57 as_operations_t *as_operations = NULL; 61 58 62 59 static int get_area_flags(as_area_t *a); 63 60 61 /** Initialize address space subsystem. */ 62 void as_init(void) 63 { 64 as_arch_init(); 65 AS_KERNEL = as_create(FLAG_AS_KERNEL); 66 if (!AS_KERNEL) 67 panic("can't create kernel address space\n"); 68 } 69 64 70 /** Create address space. */ 65 /* 66 * FIXME: this interface must be meaningful for all possible VAT 67 * (Virtual Address Translation) mechanisms. 68 */ 69 as_t *as_create(pte_t *ptl0, int flags) 71 as_t *as_create(int flags) 70 72 { 71 73 as_t *as; … … 82 84 as->asid = ASID_INVALID; 83 85 84 as->ptl0 = ptl0; 85 if (!as->ptl0) { 86 pte_t *src_ptl0, *dst_ptl0; 87 88 src_ptl0 = (pte_t *) PA2KA((__address) GET_PTL0_ADDRESS()); 89 dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL); 90 91 // memsetb((__address) dst_ptl0, PAGE_SIZE, 0); 92 // memcpy((void *) &dst_ptl0[KAS_START_INDEX], (void *) &src_ptl0[KAS_START_INDEX], KAS_INDICES); 93 94 memcpy((void *) dst_ptl0,(void *) src_ptl0, PAGE_SIZE); 95 96 as->ptl0 = (pte_t *) KA2PA((__address) dst_ptl0); 97 } 86 as->page_table = page_table_create(flags); 98 87 } 99 88 … … 187 176 */ 188 177 189 page_mapping_insert(as, page, frame, get_area_flags(area) , (__address) as->ptl0);178 page_mapping_insert(as, page, frame, get_area_flags(area)); 190 179 191 180 spinlock_unlock(&area->lock); … … 267 256 * inserted into page tables. 268 257 */ 269 page_mapping_insert(AS, page, frame, get_area_flags(area) , (__address) AS->ptl0);258 page_mapping_insert(AS, page, frame, get_area_flags(area)); 270 259 271 260 spinlock_unlock(&area->lock); … … 287 276 ipl = interrupts_disable(); 288 277 spinlock_lock(&as->lock); 289 ASSERT(as->p tl0);290 SET_PTL0_ADDRESS(as->p tl0);278 ASSERT(as->page_table); 279 SET_PTL0_ADDRESS(as->page_table); 291 280 spinlock_unlock(&as->lock); 292 281 interrupts_restore(ipl); … … 328 317 return flags; 329 318 } 319 320 /** Create page table. 321 * 322 * Depending on architecture, create either address space 323 * private or global page table. 324 * 325 * @param flags Flags saying whether the page table is for kernel address space. 326 * 327 * @return First entry of the page table. 328 */ 329 pte_t *page_table_create(int flags) 330 { 331 ASSERT(as_operations); 332 ASSERT(as_operations->page_table_create); 333 334 return as_operations->page_table_create(flags); 335 } -
generic/src/mm/page.c
rfc1e4f6 ref67bab 49 49 { 50 50 page_arch_init(); 51 page_mapping_insert(AS_KERNEL, 0x0, 0x0, PAGE_NOT_PRESENT, 0);52 51 } 53 52 … … 69 68 70 69 for (i = 0; i < cnt; i++) 71 page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE , 0);70 page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE); 72 71 73 72 } … … 78 77 * using 'flags'. Allocate and setup any missing page tables. 79 78 * 80 * @param as Address space to wich page belongs. Must be locked prior the call. 79 * The address space must be locked and interrupts must be disabled. 80 * 81 * @param as Address space to wich page belongs.. 81 82 * @param page Virtual address of the page to be mapped. 82 83 * @param frame Physical address of memory frame to which the mapping is done. 83 84 * @param flags Flags to be used for mapping. 84 * @param root Explicit PTL0 address.85 85 */ 86 void page_mapping_insert(as_t *as, __address page, __address frame, int flags , __address root)86 void page_mapping_insert(as_t *as, __address page, __address frame, int flags) 87 87 { 88 88 ASSERT(page_operations); 89 89 ASSERT(page_operations->mapping_insert); 90 90 91 page_operations->mapping_insert(as, page, frame, flags , root);91 page_operations->mapping_insert(as, page, frame, flags); 92 92 } 93 93 … … 96 96 * Find mapping for virtual page. 97 97 * 98 * @param as Address space to wich page belongs must be locked prior the call. 98 * The address space must be locked and interrupts must be disabled. 99 * 100 * @param as Address space to wich page belongs. 99 101 * @param page Virtual page. 100 * @param root PTL0 address if non-zero.101 102 * 102 103 * @return NULL if there is no such mapping; requested mapping otherwise. 103 104 */ 104 pte_t *page_mapping_find(as_t *as, __address page , __address root)105 pte_t *page_mapping_find(as_t *as, __address page) 105 106 { 106 107 ASSERT(page_operations); 107 108 ASSERT(page_operations->mapping_find); 108 109 109 return page_operations->mapping_find(as, page , root);110 return page_operations->mapping_find(as, page); 110 111 }
Note:
See TracChangeset
for help on using the changeset viewer.
