[boot] Build, load, and pass initrd from boot to init

The initrd image is now created by the build system, loaded by the
bootloader, and passed to srv.init, which loads it (but doesn't do
anything with it yet, so this is actually a functional regression).

This simplifies a lot of the modules code between boot and init as well:
Gone are the many subclasses of module and all the data being inline
with the module structs, except for any loaded files. Now the only
modules loaded and passed will be the initrd, and any devices only the
bootloader has knowledge of, like the UEFI framebuffer.
This commit is contained in:
Justin C. Miller
2023-01-17 19:12:40 -07:00
parent 6ef15a2721
commit 66abcc57a2
26 changed files with 399 additions and 296 deletions

View File

@@ -75,48 +75,36 @@ load_resources(bootproto::args *args, video::screen *screen, uefi::handle image,
fs::file bc_data = disk.open(L"jsix_boot.dat");
bootconfig bc {bc_data.load(), bs};
args->kernel = loader::load_program(disk, bc.kernel(), true);
args->init = loader::load_program(disk, bc.init());
args->kernel = loader::load_program(disk, L"kernel", bc.kernel());
args->init = loader::load_program(disk, L"init server", bc.init());
args->flags = static_cast<bootproto::boot_flags>(bc.flags());
loader::load_module(disk, L"initrd", bc.initrd(),
bootproto::module_type::initrd, bc.initrd_format());
namespace bits = util::bits;
using bootproto::desc_flags;
if (screen) {
video::make_module(screen);
// Go through the screen-specific descriptors first to
// give them priority
for (const descriptor &d : bc.programs()) {
if (!bits::has(d.flags, desc_flags::graphical))
continue;
if (bits::has(d.flags, desc_flags::panic))
args->panic = loader::load_program(disk, d);
else
loader::load_module(disk, d);
// Find the screen-specific panic handler first to
// give it priority
for (const descriptor &d : bc.panics()) {
if (bits::has(d.flags, desc_flags::graphical)) {
args->panic = loader::load_program(disk, L"panic handler", d);
break;
}
}
}
// Load the non-graphical descriptors
for (const descriptor &d : bc.programs()) {
if (bits::has(d.flags, desc_flags::graphical))
continue;
if (bits::has(d.flags, desc_flags::panic) && !args->panic)
args->panic = loader::load_program(disk, d);
else
loader::load_module(disk, d);
}
// For now the only data we load is the symbol table
for (const descriptor &d : bc.data()) {
if (!bits::has(d.flags, desc_flags::symbols))
continue;
util::buffer symbol_table = loader::load_file(disk, d);
args->symbol_table = symbol_table.pointer;
break;
if (!args->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);
break;
}
}
}
loader::verify_kernel_header(*args->kernel);