[boot] Restructure boot paging and program loading

Restructuring paging into an object that carries its page cache with it
and makes for simpler code. Program loading is also changed to not copy
the pages loaded from the file into new pages - we can impose a new
constraint that anything loaded by boot have a simple, page-aligned
layout so that we can just map the existing pages into the right
addresses. Also included are some linker script changes to help
accommodate this.
This commit is contained in:
Justin C. Miller
2023-02-05 22:02:41 -08:00
parent aba45b9b67
commit ab31825ab3
16 changed files with 406 additions and 301 deletions

View File

@@ -7,10 +7,10 @@ uint32_t *apic_icr = reinterpret_cast<uint32_t*>(0xffffc000fee00300);
void const *symbol_table = nullptr;
void
install(uintptr_t entrypoint, const void *symbol_data)
install(uintptr_t entrypoint, util::const_buffer symbol_data)
{
IDT::set_nmi_handler(entrypoint);
symbol_table = symbol_data;
symbol_table = symbol_data.pointer;
}
} // namespace panic

View File

@@ -1,6 +1,8 @@
#pragma once
#include <stdint.h>
#include <util/counted.h>
#include "cpu.h"
namespace panic {
@@ -47,8 +49,8 @@ inline void panic(
/// Install a panic handler.
/// \arg entrypoint Virtual address of the panic handler's entrypoint
/// \arg symbol_data Pointer to the symbol table data
void install(uintptr_t entrypoint, const void *symbol_data);
/// \arg symbol_data Symbol table data
void install(uintptr_t entrypoint, util::const_buffer symbol_data);
} // namespace panic

View File

@@ -32,9 +32,8 @@ void load_init_server(bootproto::program &program, uintptr_t modules_address);
void
kernel_main(bootproto::args *args)
{
if (args->panic) {
const void *syms = util::offset_pointer(args->symbol_table, mem::linear_offset);
panic::install(args->panic->entrypoint, syms);
if (args->panic_handler) {
panic::install(args->panic_handler, args->symbol_table);
}
logger_init();
@@ -75,7 +74,7 @@ kernel_main(bootproto::args *args)
smp::ready();
// Load the init server
load_init_server(*args->init, args->modules);
load_init_server(args->init, args->init_modules);
sched->start();
}

View File

@@ -1,20 +1,36 @@
PHDRS
{
rodata PT_LOAD PHDRS FILEHDR FLAGS (4) /* read-only */;
text PT_LOAD ;
rwdata PT_LOAD ;
bss PT_LOAD ;
}
MEMORY
{
panic (rwxa) : ORIGIN = 0xFFFF800080000000, LENGTH = 256M
}
ENTRY(_panic_entry)
SECTIONS
{
. = 0xFFFF800080000000;
.text ALIGN(4096) : {
*(.text*)
}
.data ALIGN(4096) : {
*(.data*)
.rodata ORIGIN(panic) + SIZEOF_HEADERS : {
*(.rodata*)
}
} :rodata
.bss ALIGN(4096) : {
.text ALIGN(4K) : {
*(.text*)
} :text
.data ALIGN(4K) : {
*(.data*)
*(.init_array*)
} :rwdata
.bss ALIGN(4K) : {
__bss_start = .;
*(.bss*)
__bss_end = .;
}
} :bss
}