[boot] Create bootconfig to tell boot what to load

While bonnibel already had the concept of a manifest, which controls
what goes into the built disk image, the bootloader still had filenames
hard-coded. Now bonnibel creates a 'jsix_boot.dat' file that tells the
bootloader what it should load.

Changes include:

- Modules have two new fields: location and description. location is
  their intended directory on the EFI boot volume. description is
  self-explanatory, and is used in log messages.
- New class, boot::bootconfig, implements reading of jsix_boot.dat
- New header, bootproto/bootconfig.h, specifies flags used in the
  manifest and jsix_boot.dat
- New python module, bonnibel/manifest.py, encapsulates reading of the
  manifest and writing jsix_boot.dat
- Syntax of the manifest changed slightly, including adding flags
- Boot and Kernel target ccflags unified a bit (this was partly due to
  trying to get enum_bitfields to work in boot)
- util::counted gained operator+= and new free function util::read<T>
This commit is contained in:
Justin C. Miller
2022-01-07 22:33:25 -08:00
parent 9f3e682b89
commit a3fff889d1
20 changed files with 356 additions and 82 deletions

View File

@@ -7,6 +7,7 @@
#include <util/pointers.h>
#include "allocator.h"
#include "bootconfig.h"
#include "console.h"
#include "error.h"
#include "fs.h"
@@ -23,7 +24,7 @@ using memory::alloc_type;
util::buffer
load_file(
fs::file &disk,
const program_desc &desc)
const descriptor &desc)
{
status_line status(L"Loading file", desc.path);
@@ -36,7 +37,7 @@ load_file(
static void
create_module(util::buffer data, const program_desc &desc, bool loaded)
create_module(util::buffer data, const descriptor &desc, bool loaded)
{
size_t path_len = wstrlen(desc.path);
bootproto::module_program *mod = g_alloc.allocate_module<bootproto::module_program>(path_len);
@@ -50,18 +51,20 @@ create_module(util::buffer data, const program_desc &desc, bool loaded)
// TODO: support non-ascii path characters and do real utf-16 to utf-8
// conversion
for (int i = 0; i < path_len; ++i)
mod->filename[i] = desc.path[i];
for (int i = 0; i < path_len; ++i) {
char c = desc.path[i];
mod->filename[i] = c == '\\' ? '/' : c;
}
mod->filename[path_len] = 0;
}
bootproto::program *
load_program(
fs::file &disk,
const program_desc &desc,
const descriptor &desc,
bool add_module)
{
status_line status(L"Loading program", desc.name);
status_line status(L"Loading program", desc.desc);
util::buffer data = load_file(disk, desc);
@@ -113,9 +116,9 @@ load_program(
void
load_module(
fs::file &disk,
const program_desc &desc)
const descriptor &desc)
{
status_line status(L"Loading module", desc.name);
status_line status(L"Loading module", desc.desc);
util::buffer data = load_file(disk, desc);
create_module(data, desc, false);