Changeset 63a045c in mainline for boot/arch/riscv64/src/main.c
- Timestamp:
- 2018-10-10T17:41:44Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9286475
- Parents:
- 63c1dd5
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-10 17:11:15)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-10 17:41:44)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/riscv64/src/main.c
r63c1dd5 r63a045c 41 41 #include <str.h> 42 42 #include <halt.h> 43 #include <inflate.h> 44 #include "../../components.h" 43 #include <payload.h> 45 44 46 45 static bootinfo_t bootinfo; … … 69 68 printf(" %p: boot info structure\n", &bootinfo); 70 69 71 uintptr_t top = BOOT_OFFSET; 70 uint8_t *load_addr = (uint8_t *) BOOT_OFFSET; 71 uintptr_t kernel_addr = PA2KA(load_addr); 72 72 73 for (size_t i = 0; i < COMPONENTS; i++) { 74 printf(" %p: %s image (%zu/%zu bytes)\n", components[i].addr, 75 components[i].name, components[i].inflated, 76 components[i].size); 73 printf(" %p: inflate area\n", load_addr); 74 printf(" %p: kernel entry point\n", (void *) kernel_addr); 77 75 78 uintptr_t tail = (uintptr_t) components[i].addr + 79 components[i].size; 80 if (tail > top) { 81 printf("\n%s: Image too large to fit (%p >= %p), halting.\n", 82 components[i].name, (void *) tail, (void *) top); 83 halt(); 76 /* Find the end of the memory zone containing the load address. */ 77 uint8_t *end = NULL; 78 for (size_t i = 0; i < bootinfo.memmap.cnt; i++) { 79 memzone_t z = bootinfo.memmap.zones[i]; 80 81 if (z.start <= (void *) load_addr && 82 z.start + z.size > (void *) load_addr) { 83 end = z.start + z.size; 84 84 } 85 85 } 86 86 87 printf(" %p: inflate area\n", (void *) top); 88 89 void *kernel_entry = NULL; 90 void *dest[COMPONENTS]; 91 size_t cnt = 0; 92 bootinfo.taskmap.cnt = 0; 93 94 for (size_t i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { 95 top = ALIGN_UP(top, PAGE_SIZE); 96 97 if (i > 0) { 98 bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].addr = 99 (void *) PA2KA(top); 100 bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].size = 101 components[i].inflated; 102 103 str_cpy(bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].name, 104 BOOTINFO_TASK_NAME_BUFLEN, components[i].name); 105 106 bootinfo.taskmap.cnt++; 107 } else 108 kernel_entry = (void *) PA2KA(top); 109 110 dest[i] = (void *) top; 111 top += components[i].inflated; 112 cnt++; 113 } 114 115 printf(" %p: kernel entry point\n", kernel_entry); 116 117 if (top >= bootinfo.physmem_start + bootinfo.memmap.total) { 118 printf("Not enough physical memory available.\n"); 119 printf("The boot image is too large. Halting.\n"); 120 halt(); 121 } 122 123 printf("\nInflating components ... "); 124 125 for (size_t i = cnt; i > 0; i--) { 126 printf("%s ", components[i - 1].name); 127 128 int err = inflate(components[i - 1].addr, components[i - 1].size, 129 dest[i - 1], components[i - 1].inflated); 130 131 if (err != EOK) { 132 printf("\n%s: Inflating error %d, halting.\n", 133 components[i - 1].name, err); 134 halt(); 135 } 136 } 137 138 printf(".\n"); 87 // TODO: Cache-coherence callback? 88 extract_payload(&bootinfo.taskmap, load_addr, end, kernel_addr, NULL); 139 89 140 90 printf("Booting the kernel...\n");
Note:
See TracChangeset
for help on using the changeset viewer.