[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

@@ -2,11 +2,11 @@
/// Definitions for loading the kernel into memory
#pragma once
#include <bootproto/init.h>
#include <util/counted.h>
namespace bootproto {
struct program;
struct module;
}
namespace boot {
@@ -21,29 +21,35 @@ namespace loader {
/// Load a file from disk into memory.
/// \arg disk The opened UEFI filesystem to load from
/// \arg desc The program descriptor identifying the file
/// \arg path The path of the file to load
util::buffer
load_file(
fs::file &disk,
const descriptor &desc);
const wchar_t *path);
/// Parse and load an ELF file in memory into a loaded image.
/// \arg disk The opened UEFI filesystem to load from
/// \arg desc The descriptor identifying the program
/// \arg add_module Also create a module for this loaded program
/// \arg name The human-readable name of the program to load
bootproto::program *
load_program(
fs::file &disk,
const descriptor &desc,
bool add_module = false);
const wchar_t *name,
const descriptor &desc);
/// Load a file from disk into memory, creating an init args module
/// \arg disk The opened UEFI filesystem to load from
/// \arg desc The program descriptor identifying the file
/// \arg disk The opened UEFI filesystem to load from
/// \arg name The human-readable name of the module
/// \arg path The path of the file to load the module from
/// \arg type The major type to set on the module
/// \arg subtype The subtype to set on the module
void
load_module(
fs::file &disk,
const descriptor &desc);
const wchar_t *name,
const wchar_t *path,
bootproto::module_type type,
uint16_t subtype);
/// Verify that a loaded ELF has the j6 kernel header
/// \arg program The program to check for a header