Changes in boot/arch/riscv64/src/main.c [c09ff7b:ae8d7b0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/riscv64/src/main.c
rc09ff7b rae8d7b0 30 30 #include <arch/arch.h> 31 31 #include <arch/asm.h> 32 #include <arch/ucb.h> 33 #include <arch/mm.h> 32 34 #include <version.h> 33 35 #include <stddef.h> … … 41 43 #include "../../components.h" 42 44 43 #define KA2PA(x) (((uintptr_t) (x)) - UINT64_C(0xffff800000000000))44 #define PA2KA(x) (((uintptr_t) (x)) + UINT64_C(0xffff800000000000))45 46 45 static bootinfo_t bootinfo; 47 46 … … 50 49 version_print(); 51 50 51 bootinfo.htif_frame = ((uintptr_t) &htif_page) >> PAGE_WIDTH; 52 bootinfo.pt_frame = ((uintptr_t) &pt_page) >> PAGE_WIDTH; 53 54 bootinfo.ucbinfo.tohost = 55 (volatile uint64_t *) PA2KA((uintptr_t) &tohost); 56 bootinfo.ucbinfo.fromhost = 57 (volatile uint64_t *) PA2KA((uintptr_t) &fromhost); 58 52 59 // FIXME TODO: read from device tree 53 bootinfo.memmap.total = 1024 * 1024 * 1024; 54 bootinfo.memmap.cnt = 0; 60 bootinfo.physmem_start = PHYSMEM_START; 61 bootinfo.memmap.total = PHYSMEM_SIZE; 62 bootinfo.memmap.cnt = 1; 63 bootinfo.memmap.zones[0].start = (void *) PHYSMEM_START; 64 bootinfo.memmap.zones[0].size = PHYSMEM_SIZE; 55 65 56 printf("\nMemory statistics (total %lu MB)\n\n", bootinfo.memmap.total >> 20); 66 printf("\nMemory statistics (total %lu MB, starting at %p)\n\n", 67 bootinfo.memmap.total >> 20, (void *) bootinfo.physmem_start); 57 68 printf(" %p: boot info structure\n", &bootinfo); 58 69 59 uintptr_t top = 0;70 uintptr_t top = BOOT_OFFSET; 60 71 61 72 for (size_t i = 0; i < COMPONENTS; i++) { … … 66 77 uintptr_t tail = (uintptr_t) components[i].addr + 67 78 components[i].size; 68 if (tail > top) 69 top = tail; 79 if (tail > top) { 80 printf("\n%s: Image too large to fit (%p >= %p), halting.\n", 81 components[i].name, (void *) tail, (void *) top); 82 halt(); 83 } 70 84 } 71 85 72 top = ALIGN_UP(top, PAGE_SIZE);73 86 printf(" %p: inflate area\n", (void *) top); 74 87 … … 92 105 bootinfo.taskmap.cnt++; 93 106 } else 94 kernel_entry = (void *) top;107 kernel_entry = (void *) PA2KA(top); 95 108 96 109 dest[i] = (void *) top; … … 101 114 printf(" %p: kernel entry point\n", kernel_entry); 102 115 103 if (top >= bootinfo. memmap.total) {116 if (top >= bootinfo.physmem_start + bootinfo.memmap.total) { 104 117 printf("Not enough physical memory available.\n"); 105 118 printf("The boot image is too large. Halting.\n"); … … 125 138 126 139 printf("Booting the kernel...\n"); 127 jump_to_kernel( kernel_entry,PA2KA(&bootinfo));140 jump_to_kernel(PA2KA(&bootinfo)); 128 141 }
Note:
See TracChangeset
for help on using the changeset viewer.