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