Changes in kernel/arch/ia32/src/mm/page.c [40c8c17:7e752b2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/mm/page.c
r40c8c17 r7e752b2 49 49 #include <print.h> 50 50 #include <interrupt.h> 51 #include <macros.h>52 51 53 52 void page_arch_init(void) … … 56 55 int flags; 57 56 58 if (config.cpu_active > 1) { 59 /* Fast path for non-boot CPUs */ 57 if (config.cpu_active == 1) { 58 page_mapping_operations = &pt_mapping_operations; 59 60 /* 61 * PA2KA(identity) mapping for all frames until last_frame. 62 */ 63 page_table_lock(AS_KERNEL, true); 64 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { 65 flags = PAGE_CACHEABLE | PAGE_WRITE; 66 if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) 67 flags |= PAGE_GLOBAL; 68 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 69 } 70 page_table_unlock(AS_KERNEL, true); 71 72 exc_register(14, "page_fault", true, (iroutine_t) page_fault); 60 73 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); 61 paging_on(); 62 return; 63 } 74 } else 75 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); 76 77 paging_on(); 78 } 64 79 65 page_mapping_operations = &pt_mapping_operations; 80 81 uintptr_t hw_map(uintptr_t physaddr, size_t size) 82 { 83 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 84 panic("Unable to map physical memory %p (%zu bytes).", 85 (void *) physaddr, size); 66 86 67 /* 68 * PA2KA(identity) mapping for all low-memory frames. 69 */ 87 uintptr_t virtaddr = PA2KA(last_frame); 88 pfn_t i; 70 89 page_table_lock(AS_KERNEL, true); 71 for (cur = 0; cur < min(config.identity_size, config.physmem_end); 72 cur += FRAME_SIZE) { 73 flags = PAGE_CACHEABLE | PAGE_WRITE; 74 if ((PA2KA(cur) >= config.base) && 75 (PA2KA(cur) < config.base + config.kernel_size)) 76 flags |= PAGE_GLOBAL; 77 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 90 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { 91 uintptr_t addr = PFN2ADDR(i); 92 page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, PAGE_NOT_CACHEABLE | PAGE_WRITE); 78 93 } 79 94 page_table_unlock(AS_KERNEL, true); 80 81 exc_register(14, "page_fault", true, (iroutine_t) page_fault);82 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);83 95 84 paging_on(); 96 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); 97 98 return virtaddr; 85 99 } 86 100
Note:
See TracChangeset
for help on using the changeset viewer.