[boot] Go back to loading symbol table in boot

The symbol table needs to be passed to the panic handler very early in
the kernel, loading it in init is far less useful. Return it to the boot
directory and remove it from the initrd.
This commit is contained in:
Justin C. Miller
2023-02-04 00:00:59 -08:00
parent 86d458fc6c
commit aba45b9b67
11 changed files with 50 additions and 79 deletions

View File

@@ -31,11 +31,11 @@ bootconfig::bootconfig(util::buffer data, uefi::boot_services *bs)
status_line status {L"Loading boot config"};
if (*util::read<uint64_t>(data) != jsixboot)
error::raise(uefi::status::load_error, L"Bad header in jsix_boot.dat");
error::raise(uefi::status::load_error, L"Bad header in boot config");
const uint8_t version = *util::read<uint8_t>(data);
if (version != 1)
error::raise(uefi::status::incompatible_version, L"Bad version in jsix_boot.dat");
error::raise(uefi::status::incompatible_version, L"Bad version in boot config");
uint8_t num_panics = *util::read<uint8_t>(data);
m_flags = *util::read<uint16_t>(data);
@@ -43,6 +43,7 @@ bootconfig::bootconfig(util::buffer data, uefi::boot_services *bs)
read_descriptor(m_kernel, data);
read_descriptor(m_init, data);
m_initrd = read_string(data);
m_symbols = read_string(data);
m_panics.count = num_panics;
m_panics.pointer = new descriptor [num_panics];

View File

@@ -31,6 +31,7 @@ public:
inline const descriptor & kernel() const { return m_kernel; }
inline const descriptor & init() const { return m_init; }
inline const wchar_t * initrd() const { return m_initrd; }
inline const wchar_t * symbols() const { return m_symbols; }
inline const descriptors & panics() { return m_panics; }
private:
@@ -39,6 +40,7 @@ private:
descriptor m_init;
descriptors m_panics;
wchar_t const *m_initrd;
wchar_t const *m_symbols;
};
} // namespace boot

View File

@@ -72,7 +72,7 @@ load_program(
util::const_buffer data = load_file(disk, desc.path);
elf::file program(data.pointer, data.count);
elf::file program {data};
if (!program.valid()) {
auto *header = program.header();
console::print(L" progam size: %d\r\n", data.count);
@@ -91,7 +91,7 @@ load_program(
verify_kernel_header(program, data);
size_t num_sections = 0;
for (auto &seg : program.programs()) {
for (auto &seg : program.segments()) {
if (seg.type == elf::segment_type::load)
++num_sections;
}
@@ -99,7 +99,7 @@ load_program(
bootproto::program_section *sections = new bootproto::program_section [num_sections];
size_t next_section = 0;
for (auto &seg : program.programs()) {
for (auto &seg : program.segments()) {
if (seg.type != elf::segment_type::load)
continue;

View File

@@ -72,8 +72,8 @@ load_resources(bootproto::args *args, video::screen *screen, uefi::handle image,
status_line status {L"Loading programs"};
fs::file disk = fs::get_boot_volume(image, bs);
fs::file bc_data = disk.open(L"jsix\\boot.conf");
bootconfig bc {bc_data.load(), bs};
util::buffer bc_data = loader::load_file(disk, L"jsix\\boot.conf");
bootconfig bc {bc_data, bs};
args->kernel = loader::load_program(disk, L"kernel", bc.kernel(), true);
args->init = loader::load_program(disk, L"init server", bc.init());
@@ -85,6 +85,8 @@ load_resources(bootproto::args *args, video::screen *screen, uefi::handle image,
namespace bits = util::bits;
using bootproto::desc_flags;
bool has_panic = false;
if (screen) {
video::make_module(screen);
@@ -93,19 +95,25 @@ load_resources(bootproto::args *args, video::screen *screen, uefi::handle image,
for (const descriptor &d : bc.panics()) {
if (bits::has(d.flags, desc_flags::graphical)) {
args->panic = loader::load_program(disk, L"panic handler", d);
has_panic = true;
break;
}
}
}
if (!args->panic) {
if (!has_panic) {
for (const descriptor &d : bc.panics()) {
if (!bits::has(d.flags, desc_flags::graphical)) {
args->panic = loader::load_program(disk, L"panic handler", d);
has_panic = true;
break;
}
}
}
const wchar_t *symbol_file = bc.symbols();
if (has_panic && symbol_file && *symbol_file)
args->symbol_table = loader::load_file(disk, symbol_file).pointer;
}
memory::efi_mem_map

View File

@@ -158,6 +158,8 @@ status_line::do_fail(const wchar_t *message, uefi::status status)
void
status_line::do_blank()
{
m_level = level_ok; // Keep print_status_tag from happening in dtor
auto out = console::get().m_out;
int row = out->mode->cursor_row;