[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

@@ -0,0 +1,17 @@
#pragma once
/// \file bootproto/bootconfig.h
/// Data structures for reading jsix_boot.dat
#include <stdint.h>
#include <util/enum_bitfields.h>
namespace bootproto {
enum class desc_flags : uint16_t {
graphical = 0x01,
panic = 0x02,
symbols = 0x04,
};
is_bitfield(desc_flags);
} // namespace bootproto

View File

@@ -2,7 +2,6 @@
libc = module("libc",
kind = "lib",
output = "libc.a",
includes = [ "include" ],
deps = [ "j6" ],
sources = [

View File

@@ -35,6 +35,14 @@ struct counted
/// Return an iterator to the end of the array
inline const_iterator end() const { return offset_pointer<const T>(pointer, sizeof(T)*count); }
/// Advance the pointer by N items
inline counted<T> & operator+=(unsigned i) {
if (i > count) i = count;
pointer += i;
count -= i;
return *this;
}
};
/// Specialize for `void` which cannot be indexed or iterated
@@ -43,8 +51,24 @@ struct counted<void>
{
void *pointer;
size_t count;
/// Advance the pointer by N bytes
inline counted<void> & operator+=(unsigned i) {
if (i > count) i = count;
pointer = offset_pointer(pointer, i);
count -= i;
return *this;
}
};
using buffer = counted<void>;
template <typename T>
const T * read(buffer &b) {
const T *p = reinterpret_cast<const T*>(b.pointer);
b.pointer = offset_pointer(b.pointer, sizeof(T));
b.count -= sizeof(T);
return p;
}
} // namespace util