Changeset ae8d7b0 in mainline for boot/arch/riscv64/src/main.c


Ignore:
Timestamp:
2017-08-21T18:23:39Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c58441d
Parents:
fdc29300
Message:

riscv64: update to the latest Privileged Architecture specification (1.10)

File:
1 edited

Legend:

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

    rfdc29300 rae8d7b0  
    3030#include <arch/arch.h>
    3131#include <arch/asm.h>
     32#include <arch/ucb.h>
     33#include <arch/mm.h>
    3234#include <version.h>
    3335#include <stddef.h>
     
    4143#include "../../components.h"
    4244
    43 #define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffff800000000000))
    44 #define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffff800000000000))
    45 
    4645static bootinfo_t bootinfo;
    4746
     
    5049        version_print();
    5150       
     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       
    5259        // 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;
    5565       
    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);
    5768        printf(" %p: boot info structure\n", &bootinfo);
    5869       
    59         uintptr_t top = 0;
     70        uintptr_t top = BOOT_OFFSET;
    6071       
    6172        for (size_t i = 0; i < COMPONENTS; i++) {
     
    6677                uintptr_t tail = (uintptr_t) components[i].addr +
    6778                    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                }
    7084        }
    7185       
    72         top = ALIGN_UP(top, PAGE_SIZE);
    7386        printf(" %p: inflate area\n", (void *) top);
    7487       
     
    92105                        bootinfo.taskmap.cnt++;
    93106                } else
    94                         kernel_entry = (void *) top;
     107                        kernel_entry = (void *) PA2KA(top);
    95108               
    96109                dest[i] = (void *) top;
     
    101114        printf(" %p: kernel entry point\n", kernel_entry);
    102115       
    103         if (top >= bootinfo.memmap.total) {
     116        if (top >= bootinfo.physmem_start + bootinfo.memmap.total) {
    104117                printf("Not enough physical memory available.\n");
    105118                printf("The boot image is too large. Halting.\n");
     
    125138       
    126139        printf("Booting the kernel...\n");
    127         jump_to_kernel(kernel_entry, PA2KA(&bootinfo));
     140        jump_to_kernel(PA2KA(&bootinfo));
    128141}
Note: See TracChangeset for help on using the changeset viewer.