Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/riscv64/src/main.c

    rae8d7b0 rc09ff7b  
    3030#include <arch/arch.h>
    3131#include <arch/asm.h>
    32 #include <arch/ucb.h>
    33 #include <arch/mm.h>
    3432#include <version.h>
    3533#include <stddef.h>
     
    4341#include "../../components.h"
    4442
     43#define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffff800000000000))
     44#define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffff800000000000))
     45
    4546static bootinfo_t bootinfo;
    4647
     
    4950        version_print();
    5051       
    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;
    5355       
    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);
    6857        printf(" %p: boot info structure\n", &bootinfo);
    6958       
    70         uintptr_t top = BOOT_OFFSET;
     59        uintptr_t top = 0;
    7160       
    7261        for (size_t i = 0; i < COMPONENTS; i++) {
     
    7766                uintptr_t tail = (uintptr_t) components[i].addr +
    7867                    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;
    8470        }
    8571       
     72        top = ALIGN_UP(top, PAGE_SIZE);
    8673        printf(" %p: inflate area\n", (void *) top);
    8774       
     
    10592                        bootinfo.taskmap.cnt++;
    10693                } else
    107                         kernel_entry = (void *) PA2KA(top);
     94                        kernel_entry = (void *) top;
    10895               
    10996                dest[i] = (void *) top;
     
    114101        printf(" %p: kernel entry point\n", kernel_entry);
    115102       
    116         if (top >= bootinfo.physmem_start + bootinfo.memmap.total) {
     103        if (top >= bootinfo.memmap.total) {
    117104                printf("Not enough physical memory available.\n");
    118105                printf("The boot image is too large. Halting.\n");
     
    138125       
    139126        printf("Booting the kernel...\n");
    140         jump_to_kernel(PA2KA(&bootinfo));
     127        jump_to_kernel(kernel_entry, PA2KA(&bootinfo));
    141128}
Note: See TracChangeset for help on using the changeset viewer.