Changeset cfdeedc in mainline for boot/arch/riscv64


Ignore:
Timestamp:
2018-10-21T23:12:23Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bf05c74
Parents:
d59718e
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-21 22:53:48)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-21 23:12:23)
Message:

Keep kernel in ELF format

By keeping kernel in an ELF file (instead of converting it to
a flat binary), we can use the information it contains, like
symbol table and debug info.

We can also later implement more advanced functionality, like
loading kernel at multiple discontiguous blocks, or loading
a position-independent kernel at a randomized address.

Currently the functionality is quite restricted, to keep changes
to a minimum. Code in boot/generic/src/kernel.c validates that
the kernel image was built with the same addresses as the boot
loader uses, giving an extra level of sanity checking compared
to a flat binary.

Location:
boot/arch/riscv64
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/riscv64/Makefile.inc

    rd59718e rcfdeedc  
    3030BFD_OUTPUT = $(BFD_NAME)
    3131BFD_ARCH = riscv
    32 BFD = binary
    3332
    3433BITS = 64
     
    5150        generic/src/gzip.c \
    5251        generic/src/tar.c \
     52        generic/src/kernel.c \
    5353        generic/src/payload.c
  • boot/arch/riscv64/include/arch/asm.h

    rd59718e rcfdeedc  
    3636extern char pt_page[];
    3737
    38 extern _Noreturn void jump_to_kernel(uintptr_t);
     38extern _Noreturn void jump_to_kernel(uintptr_t, uintptr_t);
    3939
    4040#endif
  • boot/arch/riscv64/src/asm.S

    rd59718e rcfdeedc  
    125125        csrw mstatus, t0
    126126
    127         li ra, PA2KA(BOOT_OFFSET)
     127        /* Entry point address is in a1. */
     128        mv ra, a1
    128129        csrw mepc, ra
    129130
  • boot/arch/riscv64/src/main.c

    rd59718e rcfdeedc  
    4242#include <halt.h>
    4343#include <payload.h>
     44#include <kernel.h>
    4445
    4546static bootinfo_t bootinfo;
     
    8889        extract_payload(&bootinfo.taskmap, load_addr, end, kernel_addr, NULL);
    8990
     91        uintptr_t entry = check_kernel(load_addr);
     92
    9093        printf("Booting the kernel...\n");
    91         jump_to_kernel(PA2KA(&bootinfo));
     94        jump_to_kernel(PA2KA(&bootinfo), entry);
    9295}
Note: See TracChangeset for help on using the changeset viewer.