Changeset a35b458 in mainline for boot/arch/riscv64/src
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- boot/arch/riscv64/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/riscv64/src/asm.S
r3061bc1 ra35b458 85 85 li x30, 0 86 86 li x31, 0 87 87 88 88 /* Set up stack, create stack frame */ 89 89 la sp, boot_stack + BOOT_STACK_SIZE 90 90 addi sp, sp, -16 91 91 92 92 j bootstrap 93 93 … … 97 97 /* Enable performance counters access in supervisor mode */ 98 98 csrsi mcounteren, MCOUNTEREN_CY_MASK | MCOUNTEREN_TM_MASK | MCOUNTEREN_IR_MASK 99 99 100 100 /* Setup SV48 paging for supervisor mode */ 101 101 la t0, ptl_0 102 102 srli t0, t0, 12 103 103 104 104 li t1, SATP_PFN_MASK 105 105 and t0, t0, t1 106 106 107 107 li t1, SATP_MODE_SV48 108 108 or t0, t0, t1 109 109 110 110 csrw sptbr, t0 111 111 112 112 /* Jump to supervisor mode */ 113 113 csrr t0, mstatus 114 114 115 115 li t1, ~MSTATUS_MPP_MASK 116 116 and t0, t0, t1 117 117 118 118 /* 119 119 * TODO: Enable running with Supervisor User Mode … … 122 122 li t1, MSTATUS_MPP_SUPERVISOR | MSTATUS_SUM_MASK 123 123 or t0, t0, t1 124 124 125 125 csrw mstatus, t0 126 126 127 127 li ra, PA2KA(BOOT_OFFSET) 128 128 csrw mepc, ra 129 129 130 130 mret 131 131 FUNCTION_END(jump_to_kernel) -
boot/arch/riscv64/src/main.c
r3061bc1 ra35b458 48 48 { 49 49 version_print(); 50 50 51 51 bootinfo.htif_frame = ((uintptr_t) &htif_page) >> PAGE_WIDTH; 52 52 bootinfo.pt_frame = ((uintptr_t) &pt_page) >> PAGE_WIDTH; 53 53 54 54 bootinfo.ucbinfo.tohost = 55 55 (volatile uint64_t *) PA2KA((uintptr_t) &tohost); 56 56 bootinfo.ucbinfo.fromhost = 57 57 (volatile uint64_t *) PA2KA((uintptr_t) &fromhost); 58 58 59 59 // FIXME TODO: read from device tree 60 60 bootinfo.physmem_start = PHYSMEM_START; … … 63 63 bootinfo.memmap.zones[0].start = (void *) PHYSMEM_START; 64 64 bootinfo.memmap.zones[0].size = PHYSMEM_SIZE; 65 65 66 66 printf("\nMemory statistics (total %lu MB, starting at %p)\n\n", 67 67 bootinfo.memmap.total >> 20, (void *) bootinfo.physmem_start); 68 68 printf(" %p: boot info structure\n", &bootinfo); 69 69 70 70 uintptr_t top = BOOT_OFFSET; 71 71 72 72 for (size_t i = 0; i < COMPONENTS; i++) { 73 73 printf(" %p: %s image (%zu/%zu bytes)\n", components[i].addr, 74 74 components[i].name, components[i].inflated, 75 75 components[i].size); 76 76 77 77 uintptr_t tail = (uintptr_t) components[i].addr + 78 78 components[i].size; … … 83 83 } 84 84 } 85 85 86 86 printf(" %p: inflate area\n", (void *) top); 87 87 88 88 void *kernel_entry = NULL; 89 89 void *dest[COMPONENTS]; 90 90 size_t cnt = 0; 91 91 bootinfo.taskmap.cnt = 0; 92 92 93 93 for (size_t i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { 94 94 top = ALIGN_UP(top, PAGE_SIZE); 95 95 96 96 if (i > 0) { 97 97 bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].addr = … … 99 99 bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].size = 100 100 components[i].inflated; 101 101 102 102 str_cpy(bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].name, 103 103 BOOTINFO_TASK_NAME_BUFLEN, components[i].name); 104 104 105 105 bootinfo.taskmap.cnt++; 106 106 } else 107 107 kernel_entry = (void *) PA2KA(top); 108 108 109 109 dest[i] = (void *) top; 110 110 top += components[i].inflated; 111 111 cnt++; 112 112 } 113 113 114 114 printf(" %p: kernel entry point\n", kernel_entry); 115 115 116 116 if (top >= bootinfo.physmem_start + bootinfo.memmap.total) { 117 117 printf("Not enough physical memory available.\n"); … … 119 119 halt(); 120 120 } 121 121 122 122 printf("\nInflating components ... "); 123 123 124 124 for (size_t i = cnt; i > 0; i--) { 125 125 printf("%s ", components[i - 1].name); 126 126 127 127 int err = inflate(components[i - 1].addr, components[i - 1].size, 128 128 dest[i - 1], components[i - 1].inflated); 129 129 130 130 if (err != EOK) { 131 131 printf("\n%s: Inflating error %d, halting.\n", … … 134 134 } 135 135 } 136 136 137 137 printf(".\n"); 138 138 139 139 printf("Booting the kernel...\n"); 140 140 jump_to_kernel(PA2KA(&bootinfo)); -
boot/arch/riscv64/src/ucb.c
r3061bc1 ra35b458 39 39 if (!val) 40 40 return; 41 41 42 42 fromhost = 0; 43 43 } … … 48 48 (((uint64_t) cmd) << 48) | 49 49 (payload & UINT64_C(0xffffffffffff)); 50 50 51 51 while (tohost) 52 52 poll_fromhost(); 53 53 54 54 tohost = val; 55 55 }
Note:
See TracChangeset
for help on using the changeset viewer.
