[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

@@ -4,6 +4,7 @@ bp = module("bootproto",
kind = "lib",
public_headers = [
"bootproto/bootconfig.h",
"bootproto/devices/framebuffer.h",
"bootproto/init.h",
"bootproto/kernel.h",
"bootproto/memory.h.cog",

View File

@@ -8,9 +8,9 @@
namespace bootproto {
enum class desc_flags : uint16_t {
graphical = 0x01,
panic = 0x02,
symbols = 0x04,
graphical = 0x0001,
panic = 0x0002,
symbols = 0x0004,
};
is_bitfield(desc_flags);

View File

@@ -0,0 +1,28 @@
#pragma once
/// \file bootproto/devices/uefi_fb.h
/// Data structures describing bootloader-passed framebuffer
#include <util/counted.h>
namespace bootproto {
namespace devices {
enum class fb_layout : uint8_t { rgb8, bgr8, unknown = 0xff };
struct video_mode
{
uint32_t vertical;
uint32_t horizontal;
uint32_t scanline;
fb_layout layout;
};
struct uefi_fb
{
util::buffer framebuffer;
video_mode mode;
};
} // namespace devices
} // namespace bootproto

View File

@@ -10,61 +10,30 @@
namespace bootproto {
enum class module_type : uint8_t {
none,
program,
framebuffer,
};
enum class module_flags : uint8_t {
none = 0x00,
/// This module was already handled by the bootloader,
/// no action is needed. The module is included for
/// informational purposes only.
no_load = 0x01,
};
is_bitfield(module_flags);
enum class module_type : uint8_t { none, initrd, device, };
enum class initrd_format : uint8_t { none, zstd, };
enum class device_type : uint16_t { none, uefi_fb, };
struct module
{
module_type mod_type;
module_flags mod_flags;
uint32_t mod_length;
module_type type;
// 1 byte padding
uint16_t subtype;
// 4 bytes padding
util::buffer data;
};
struct module_program :
public module
{
uintptr_t base_address;
size_t size;
char filename[];
};
enum class fb_layout : uint8_t { rgb8, bgr8, unknown = 0xff };
enum class fb_type : uint8_t { uefi };
struct video_mode
{
uint32_t vertical;
uint32_t horizontal;
uint32_t scanline;
fb_layout layout;
};
struct module_framebuffer :
public module
{
util::buffer framebuffer;
video_mode mode;
fb_type type;
};
struct modules_page
struct module_page_header
{
uint8_t count;
module *modules;
uintptr_t next;
};
struct modules_page :
public module_page_header
{
static constexpr unsigned per_page = (0x1000 - sizeof(module_page_header)) / sizeof(module);
module modules[per_page];
};
} // namespace bootproto