Changeset ef67bab in mainline
- Timestamp:
- 2006-02-01T00:02:16Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 071a8ae6
- Parents:
- fc1e4f6
- Files:
-
- 9 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/Makefile.inc
rfc1e4f6 ref67bab 88 88 arch/$(ARCH)/src/bios/bios.c \ 89 89 arch/$(ARCH)/src/interrupt.c \ 90 arch/$(ARCH)/src/mm/as.c \ 90 91 arch/$(ARCH)/src/mm/frame.c \ 91 92 arch/$(ARCH)/src/mm/page.c \ -
arch/amd64/include/mm/as.h
rfc1e4f6 ref67bab 43 43 #define as_install_arch(as) 44 44 45 extern void as_arch_init(void); 46 45 47 #endif -
arch/amd64/src/mm/page.c
rfc1e4f6 ref67bab 39 39 #include <interrupt.h> 40 40 41 static __address bootstrap_dba;42 43 41 void page_arch_init(void) 44 42 { 45 __address dba;46 43 __address cur; 47 44 … … 49 46 page_operations = &page_pt_operations; 50 47 51 dba = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);52 memsetb(dba, PAGE_SIZE, 0);53 54 bootstrap_dba = dba;55 56 48 /* 57 49 * PA2KA(identity) mapping for all frames. 58 50 */ 59 51 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { 60 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE | PAGE_EXEC , KA2PA(dba));52 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE | PAGE_EXEC); 61 53 } 62 54 63 55 exc_register(14, "page_fault", page_fault); 64 write_cr3( KA2PA(dba));56 write_cr3((__address) AS_KERNEL->page_table); 65 57 } 66 58 else { 67 write_cr3( KA2PA(bootstrap_dba));59 write_cr3((__address) AS_KERNEL->page_table); 68 60 } 69 61 } -
arch/ia32/Makefile.inc
rfc1e4f6 ref67bab 111 111 arch/$(ARCH)/src/userspace.c \ 112 112 arch/$(ARCH)/src/cpu/cpu.c \ 113 arch/$(ARCH)/src/mm/as.c \ 113 114 arch/$(ARCH)/src/mm/frame.c \ 114 115 arch/$(ARCH)/src/mm/memory_init.c \ -
arch/ia32/include/mm/as.h
rfc1e4f6 ref67bab 43 43 #define as_install_arch(as) 44 44 45 extern void as_arch_init(void); 46 45 47 #endif -
arch/ia32/src/drivers/ega.c
rfc1e4f6 ref67bab 60 60 __u8 hi, lo; 61 61 62 page_mapping_insert(AS_KERNEL, PA2KA(VIDEORAM), VIDEORAM, PAGE_NOT_CACHEABLE , 0);62 page_mapping_insert(AS_KERNEL, PA2KA(VIDEORAM), VIDEORAM, PAGE_NOT_CACHEABLE); 63 63 outb(0x3d4,0xe); 64 64 hi = inb(0x3d5); -
arch/ia32/src/mm/page.c
rfc1e4f6 ref67bab 43 43 #include <interrupt.h> 44 44 45 static __address bootstrap_dba;46 47 45 void page_arch_init(void) 48 46 { 49 __address dba;50 47 __address cur; 51 48 … … 53 50 page_operations = &page_pt_operations; 54 51 55 dba = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);56 memsetb(dba, PAGE_SIZE, 0);57 58 bootstrap_dba = dba;59 60 52 /* 61 53 * PA2KA(identity) mapping for all frames until last_frame. 62 54 */ 63 55 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) 64 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE , KA2PA(dba));56 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE); 65 57 66 58 exc_register(14, "page_fault", page_fault); 67 write_cr3( KA2PA(dba));59 write_cr3((__address) AS_KERNEL->page_table); 68 60 } 69 61 else { 70 write_cr3( KA2PA(bootstrap_dba));62 write_cr3((__address) AS_KERNEL->page_table); 71 63 } 72 64 -
arch/ia32/src/smp/smp.c
rfc1e4f6 ref67bab 67 67 if (config.cpu_count > 1) { 68 68 page_mapping_insert(AS_KERNEL, (__address) l_apic, (__address) l_apic, 69 PAGE_NOT_CACHEABLE , 0);69 PAGE_NOT_CACHEABLE); 70 70 page_mapping_insert(AS_KERNEL, (__address) io_apic, (__address) io_apic, 71 PAGE_NOT_CACHEABLE , 0);71 PAGE_NOT_CACHEABLE); 72 72 } 73 73 -
arch/ia64/Makefile.inc
rfc1e4f6 ref67bab 65 65 arch/$(ARCH)/src/ivt.S \ 66 66 arch/$(ARCH)/src/interrupt.c \ 67 arch/$(ARCH)/src/mm/as.c \ 67 68 arch/$(ARCH)/src/mm/frame.c \ 68 69 arch/$(ARCH)/src/mm/page.c \ -
arch/ia64/include/mm/as.h
rfc1e4f6 ref67bab 43 43 #define as_install_arch(as) 44 44 45 extern void as_arch_init(void); 46 45 47 #endif -
arch/ia64/include/mm/page.h
rfc1e4f6 ref67bab 44 44 #define PA2KA(x) ((__address) (x)) 45 45 46 #define GET_PTL0_ADDRESS_ARCH() ((pte_t *) 0) 47 #define SET_PTL0_ADDRESS_ARCH(ptl0) 46 #define SET_PTL0_ADDRESS_ARCH(x) /**< To be removed as situation permits. */ 48 47 49 48 /** Implementation of page hash table interface. */ 50 #define HT_ ENTRIES_ARCH (VHPT_SIZE/sizeof(pte_t))49 #define HT_WIDTH_ARCH 20 /* 1M */ 51 50 #define HT_HASH_ARCH(page, asid) vhpt_hash((page), (asid)) 52 51 #define HT_COMPARE_ARCH(page, asid, t) vhpt_compare((page), (asid), (t)) -
arch/ia64/src/mm/tlb.c
rfc1e4f6 ref67bab 34 34 #include <arch/mm/asid.h> 35 35 36 /** Invalidate all TLB entries. 37 * 38 * Because of ASID management, region registers must be reset 39 * with new RIDs derived from the potentionally new ASID. 40 */ 36 /** Invalidate all TLB entries. */ 41 37 void tlb_invalidate_all(void) 42 38 { -
arch/mips32/include/mm/as.h
rfc1e4f6 ref67bab 42 42 #define UDATA_ADDRESS_ARCH 0x01001000 43 43 44 extern void as_arch_init(void); 45 44 46 #endif -
arch/mips32/src/mm/as.c
rfc1e4f6 ref67bab 28 28 29 29 #include <arch/mm/as.h> 30 #include <genarch/mm/as_pt.h> 30 31 #include <arch/mm/tlb.h> 31 32 #include <mm/tlb.h> … … 33 34 #include <arch/cp0.h> 34 35 #include <arch.h> 36 37 /** Architecture dependent address space init. */ 38 void as_arch_init(void) 39 { 40 as_operations = &as_pt_operations; 41 } 35 42 36 43 /** Install address space. … … 57 64 interrupts_restore(ipl); 58 65 } 66 -
arch/mips32/src/mm/tlb.c
rfc1e4f6 ref67bab 340 340 * Check if the mapping exists in page tables. 341 341 */ 342 pte = page_mapping_find(AS, badvaddr , 0);342 pte = page_mapping_find(AS, badvaddr); 343 343 if (pte && pte->lo.v) { 344 344 /* … … 357 357 * The mapping ought to be in place. 358 358 */ 359 pte = page_mapping_find(AS, badvaddr , 0);359 pte = page_mapping_find(AS, badvaddr); 360 360 ASSERT(pte && pte->lo.v); 361 361 return pte; -
arch/ppc32/Makefile.inc
rfc1e4f6 ref67bab 61 61 arch/$(ARCH)/src/asm.S \ 62 62 arch/$(ARCH)/src/cpu/cpu.c \ 63 arch/$(ARCH)/src/mm/as.c \ 63 64 arch/$(ARCH)/src/mm/frame.c \ 64 65 arch/$(ARCH)/src/mm/memory_init.c \ -
arch/ppc32/include/mm/as.h
rfc1e4f6 ref67bab 43 43 #define as_install_arch(as) 44 44 45 extern void as_arch_init(void); 46 45 47 #endif -
arch/sparc64/Makefile.inc
rfc1e4f6 ref67bab 65 65 arch/$(ARCH)/src/context.S \ 66 66 arch/$(ARCH)/src/dummy.s \ 67 arch/$(ARCH)/src/mm/as.c \ 67 68 arch/$(ARCH)/src/mm/frame.c \ 68 69 arch/$(ARCH)/src/mm/page.c \ -
arch/sparc64/include/mm/as.h
rfc1e4f6 ref67bab 43 43 #define as_install_arch(as) 44 44 45 extern void as_arch_init(void); 46 45 47 #endif -
arch/sparc64/include/mm/frame.h
rfc1e4f6 ref67bab 32 32 #include <arch/types.h> 33 33 34 #define FRAME_SIZE 8192 34 #define FRAME_WIDTH 13 35 #define FRAME_SIZE (1<<FRAME_WIDTH) 35 36 36 37 union frame_address { -
arch/sparc64/include/mm/page.h
rfc1e4f6 ref67bab 39 39 #define PA2KA(x) ((__address) (x)) 40 40 41 #define GET_PTL0_ADDRESS_ARCH() 0 42 #define SET_PTL0_ADDRESS_ARCH(ptl0) 41 #define SET_PTL0_ADDRESS_ARCH(x) /**< To be removed as situation permits. */ 43 42 44 43 /** Implementation of page hash table interface. */ 45 #define HT_ ENTRIES_ARCH 044 #define HT_WIDTH_ARCH 20 /* 1M */ 46 45 #define HT_HASH_ARCH(page, asid) 0 47 46 #define HT_COMPARE_ARCH(page, asid, t) 0 -
genarch/Makefile.inc
rfc1e4f6 ref67bab 40 40 ifeq ($(CONFIG_PAGE_PT),y) 41 41 GENARCH_SOURCES += \ 42 genarch/src/mm/page_pt.c 42 genarch/src/mm/page_pt.c \ 43 genarch/src/mm/as_pt.c 43 44 endif 44 45 ifeq ($(CONFIG_PAGE_HT),y) 45 46 GENARCH_SOURCES += \ 46 genarch/src/mm/page_ht.c 47 genarch/src/mm/page_ht.c \ 48 genarch/src/mm/as_ht.c 47 49 endif 48 50 ifeq ($(CONFIG_ASID),y) -
genarch/include/mm/page_ht.h
rfc1e4f6 ref67bab 39 39 #include <typedefs.h> 40 40 41 /** Number of slots in page hash table. */ 42 #define HT_ENTRIES HT_ENTRIES_ARCH 41 /** Page hash table size. */ 42 #define HT_WIDTH HT_WIDTH_ARCH 43 #define HT_SIZE (1<<HT_WIDTH) 44 #define HT_ENTRIES (HT_SIZE/sizeof(pte_t)) 43 45 44 46 /** Hash function. … … 100 102 #define HT_SET_RECORD(t, page, asid, frame, flags) HT_SET_RECORD_ARCH(t, page, asid, frame, flags) 101 103 102 103 104 extern page_operations_t page_ht_operations; 104 105 extern spinlock_t page_ht_lock; -
genarch/include/mm/page_pt.h
rfc1e4f6 ref67bab 88 88 extern page_operations_t page_pt_operations; 89 89 90 extern void page_mapping_insert_pt(as_t *as, __address page, __address frame, int flags , __address root);91 extern pte_t *page_mapping_find_pt(as_t *as, __address page , __address root);90 extern void page_mapping_insert_pt(as_t *as, __address page, __address frame, int flags); 91 extern pte_t *page_mapping_find_pt(as_t *as, __address page); 92 92 93 93 #endif -
genarch/src/acpi/acpi.c
rfc1e4f6 ref67bab 80 80 static void map_sdt(struct acpi_sdt_header *sdt) 81 81 { 82 page_mapping_insert(AS_KERNEL, (__address) sdt, (__address) sdt, PAGE_NOT_CACHEABLE , 0);82 page_mapping_insert(AS_KERNEL, (__address) sdt, (__address) sdt, PAGE_NOT_CACHEABLE); 83 83 map_structure((__address) sdt, sdt->length); 84 84 } -
genarch/src/mm/page_ht.c
rfc1e4f6 ref67bab 39 39 #include <arch.h> 40 40 #include <debug.h> 41 #include <memstr.h> 41 42 42 43 /** 43 * This lock protects the page hash table. Note that software must 44 * be still careful about ordering of writes to ensure consistent 45 * view of the page hash table for hardware helpers such as VHPT 46 * walker on ia64. 44 * This lock protects the page hash table. 47 45 */ 48 46 SPINLOCK_INITIALIZE(page_ht_lock); … … 54 52 pte_t *page_ht = NULL; 55 53 56 static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags , __address root);57 static pte_t *ht_mapping_find(as_t *as, __address page , __address root);54 static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags); 55 static pte_t *ht_mapping_find(as_t *as, __address page); 58 56 59 57 page_operations_t page_ht_operations = { 60 58 .mapping_insert = ht_mapping_insert, 61 .mapping_find = ht_mapping_find 59 .mapping_find = ht_mapping_find, 62 60 }; 63 61 … … 65 63 * 66 64 * Map virtual address 'page' to physical address 'frame' 67 * using 'flags'. In order not to disturb hardware searching, 68 * new mappings are appended to the end of the collision 69 * chain. 65 * using 'flags'. 70 66 * 71 * @param as Address space to which page belongs. Must be locked prior the call. 67 * The address space must be locked and interruptsmust be disabled. 68 * 69 * @param as Address space to which page belongs. 72 70 * @param page Virtual address of the page to be mapped. 73 71 * @param frame Physical address of memory frame to which the mapping is done. 74 72 * @param flags Flags to be used for mapping. 75 * @param root Ignored.76 73 */ 77 void ht_mapping_insert(as_t *as, __address page, __address frame, int flags , __address root)74 void ht_mapping_insert(as_t *as, __address page, __address frame, int flags) 78 75 { 79 76 pte_t *t, *u; … … 122 119 * Find mapping for virtual page. 123 120 * 124 * Interrupts must be disabled.121 * The address space must be locked and interrupts must be disabled. 125 122 * 126 * @param as Address space to wich page belongs. Must be locked prior the call.123 * @param as Address space to wich page belongs. 127 124 * @param page Virtual page. 128 * @param root Ignored.129 125 * 130 126 * @return NULL if there is no such mapping; requested mapping otherwise. 131 127 */ 132 pte_t *ht_mapping_find(as_t *as, __address page , __address root)128 pte_t *ht_mapping_find(as_t *as, __address page) 133 129 { 134 130 pte_t *t; -
genarch/src/mm/page_pt.c
rfc1e4f6 ref67bab 30 30 #include <mm/page.h> 31 31 #include <mm/frame.h> 32 #include <mm/as.h> 32 33 #include <arch/mm/page.h> 33 34 #include <arch/mm/as.h> … … 37 38 #include <memstr.h> 38 39 39 static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags , __address root);40 static pte_t *pt_mapping_find(as_t *as, __address page , __address root);40 static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags); 41 static pte_t *pt_mapping_find(as_t *as, __address page); 41 42 42 43 page_operations_t page_pt_operations = { … … 50 51 * using 'flags'. 51 52 * 52 * @param as Ignored. 53 * The address space must be locked and interrupts must be disabled. 54 * 55 * @param as Address space to wich page belongs. 53 56 * @param page Virtual address of the page to be mapped. 54 57 * @param frame Physical address of memory frame to which the mapping is done. 55 58 * @param flags Flags to be used for mapping. 56 * @param root Explicit PTL0 address.57 59 */ 58 void pt_mapping_insert(as_t *as, __address page, __address frame, int flags , __address root)60 void pt_mapping_insert(as_t *as, __address page, __address frame, int flags) 59 61 { 60 62 pte_t *ptl0, *ptl1, *ptl2, *ptl3; 61 63 __address newpt; 62 64 63 ptl0 = (pte_t *) PA2KA( root ? root : (__address) GET_PTL0_ADDRESS());65 ptl0 = (pte_t *) PA2KA((__address) as->page_table); 64 66 65 67 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { … … 98 100 * Find mapping for virtual page. 99 101 * 100 * @param as Ignored. 102 * The address space must be locked and interrupts must be disabled. 103 * 104 * @param as Address space to which page belongs. 101 105 * @param page Virtual page. 102 * @param root PTL0 address if non-zero.103 106 * 104 107 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise. 105 108 */ 106 pte_t *pt_mapping_find(as_t *as, __address page , __address root)109 pte_t *pt_mapping_find(as_t *as, __address page) 107 110 { 108 111 pte_t *ptl0, *ptl1, *ptl2, *ptl3; 109 112 110 ptl0 = (pte_t *) PA2KA( root ? root : (__address) GET_PTL0_ADDRESS());113 ptl0 = (pte_t *) PA2KA((__address) as->page_table); 111 114 112 115 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) -
generic/include/mm/as.h
rfc1e4f6 ref67bab 81 81 SPINLOCK_DECLARE(lock); 82 82 link_t as_area_head; 83 pte_t *ptl0; 84 asid_t asid; /**< Address space identifier. */ 83 84 /** Page table pointer. Constant on architectures that use global page hash table. */ 85 pte_t *page_table; 86 87 /** Address space identifier. Constant on architectures that do not support ASIDs.*/ 88 asid_t asid; 85 89 }; 86 90 91 struct as_operations { 92 pte_t *(* page_table_create)(int flags); 93 }; 94 typedef struct as_operations as_operations_t; 95 87 96 extern as_t *AS_KERNEL; 97 extern as_operations_t *as_operations; 88 98 89 extern as_t *as_create(pte_t *ptl0, int flags); 99 extern void as_init(void); 100 extern as_t *as_create(int flags); 90 101 extern as_area_t *as_area_create(as_t *as, as_area_type_t type, size_t size, __address base); 91 102 extern void as_set_mapping(as_t *as, __address page, __address frame); -
generic/include/mm/buddy.h
rfc1e4f6 ref67bab 58 58 extern void buddy_system_structure_print(buddy_system_t *b, size_t elem_size); 59 59 60 61 60 #endif -
generic/include/mm/page.h
rfc1e4f6 ref67bab 62 62 /** Operations to manipulate page mappings. */ 63 63 struct page_operations { 64 void (* mapping_insert)(as_t *as, __address page, __address frame, int flags , __address root);65 pte_t *(* mapping_find)(as_t *as, __address page , __address root);64 void (* mapping_insert)(as_t *as, __address page, __address frame, int flags); 65 pte_t *(* mapping_find)(as_t *as, __address page); 66 66 }; 67 67 typedef struct page_operations page_operations_t; … … 70 70 71 71 extern void page_init(void); 72 extern void page_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root); 73 extern pte_t *page_mapping_find(as_t *as, __address page, __address root); 72 extern void page_mapping_insert(as_t *as, __address page, __address frame, int flags); 73 extern pte_t *page_mapping_find(as_t *as, __address page); 74 extern pte_t *page_table_create(int flags); 74 75 extern void map_structure(__address s, size_t size); 75 76 -
generic/src/main/kinit.c
rfc1e4f6 ref67bab 148 148 panic("config.init_addr is not frame aligned"); 149 149 150 as = as_create( NULL,0);150 as = as_create(0); 151 151 if (!as) 152 152 panic("as_create\n"); … … 159 159 160 160 /* 161 * Create the text as_area and copy the userspace code there.161 * Create the text as_area and initialize its mapping. 162 162 */ 163 163 … … 170 170 if (!a) 171 171 panic("as_area_create: text\n"); 172 172 173 for (i = 0; i < frames; i++) 174 as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE); 175 173 176 /* 174 177 * Create the data as_area. … … 178 181 panic("as_area_create: stack\n"); 179 182 180 /*181 * Initialize text area mapping.182 */183 for (i = 0; i < frames; i++)184 as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE);185 186 187 183 thread_ready(t); 188 184 } -
generic/src/main/main.c
rfc1e4f6 ref67bab 139 139 void main_bsp_separated_stack(void) 140 140 { 141 as_t *as;142 141 task_t *k; 143 142 thread_t *t; … … 152 151 kconsole_init(); 153 152 154 /* Exception handler initialization, before architecture 153 /* 154 * Exception handler initialization, before architecture 155 155 * starts adding its own handlers 156 156 */ … … 163 163 early_heap_init(config.heap_addr, config.heap_size + config.heap_delta); 164 164 frame_init(); 165 as_init(); 165 166 page_init(); 166 167 tlb_init(); … … 190 191 191 192 /* 192 * Create kernel address space.193 */194 as = as_create(GET_PTL0_ADDRESS(), FLAG_AS_KERNEL);195 if (!as)196 panic("can't create kernel address space\n");197 198 /*199 193 * Create kernel task. 200 194 */ 201 k = task_create( as);195 k = task_create(AS_KERNEL); 202 196 if (!k) 203 197 panic("can't create kernel task\n"); -
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 } -
test/mm/mapping1/test.c
rfc1e4f6 ref67bab 57 57 58 58 printf("Mapping virtual address %P to physical address %P.\n", PAGE0, KA2PA(frame0)); 59 page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE , 0);59 page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE); 60 60 printf("Mapping virtual address %P to physical address %P.\n", PAGE1, KA2PA(frame1)); 61 page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE , 0);61 page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE); 62 62 63 63 printf("Value at virtual address %P is %L.\n", PAGE0, v0 = *((__u32 *) PAGE0));
Note:
See TracChangeset
for help on using the changeset viewer.