Changeset ccc362a1 in mainline for kernel/arch/riscv64/src/mm/page.c
- Timestamp:
- 2017-08-21T18:46:34Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c742f5e
- Parents:
- c16479e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/riscv64/src/mm/page.c
rc16479e rccc362a1 48 48 #include <interrupt.h> 49 49 50 #define SATP_PFN_MASK UINT64_C(0x00000fffffffffff) 51 52 #define SATP_MODE_MASK UINT64_C(0xf000000000000000) 53 #define SATP_MODE_BARE UINT64_C(0x0000000000000000) 54 #define SATP_MODE_SV39 UINT64_C(0x8000000000000000) 55 #define SATP_MODE_SV48 UINT64_C(0x9000000000000000) 56 50 57 void page_arch_init(void) 51 58 { 52 if (config.cpu_active == 1) 59 if (config.cpu_active == 1) { 53 60 page_mapping_operations = &pt_mapping_operations; 61 62 page_table_lock(AS_KERNEL, true); 63 64 /* 65 * PA2KA(identity) mapping for all low-memory frames. 66 */ 67 for (uintptr_t cur = 0; 68 cur < min(config.identity_size, config.physmem_end); 69 cur += FRAME_SIZE) 70 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, 71 PAGE_GLOBAL | PAGE_CACHEABLE | PAGE_EXEC | PAGE_WRITE | PAGE_READ); 72 73 page_table_unlock(AS_KERNEL, true); 74 75 // FIXME: register page fault extension handler 76 77 write_satp((uintptr_t) AS_KERNEL->genarch.page_table); 78 79 /* The boot page table is no longer needed. */ 80 // FIXME: frame_mark_available(pt_frame, 1); 81 } 54 82 } 55 83 … … 58 86 } 59 87 88 void write_satp(uintptr_t ptl0) 89 { 90 uint64_t satp = ((ptl0 >> FRAME_WIDTH) & SATP_PFN_MASK) | 91 SATP_MODE_SV48; 92 93 asm volatile ( 94 "csrw sptbr, %[satp]\n" 95 :: [satp] "r" (satp) 96 ); 97 } 98 60 99 /** @} 61 100 */
Note:
See TracChangeset
for help on using the changeset viewer.