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