[kernel] Add test mode, controlled by manifest

The manifest can now supply a list of boot flags, including "test".
Those get turned into the bootproto::args::flags field by the
bootloader. The kernel takes those and uses the test flag to control
enabling syscalls with the new "test" attribute, like the new
test_finish syscall, which lets automated tests call back to the kernel
to shut down the system.
This commit is contained in:
Justin C. Miller
2022-02-03 19:45:46 -08:00
parent 401e662f0b
commit 0e80c19d3d
12 changed files with 59 additions and 11 deletions

View File

@@ -10,6 +10,11 @@ class Manifest:
"symbols": 0x04,
}
boot_flags = {
"debug": 0x01,
"test": 0x02,
}
def __init__(self, path, modules):
from . import load_config
@@ -25,6 +30,8 @@ class Manifest:
self.programs = [self.__build_entry(modules, i)
for i in config.get("programs", tuple())]
self.flags = config.get("flags", tuple())
self.data = []
for d in config.get("data", tuple()):
self.add_data(**d)
@@ -65,10 +72,12 @@ class Manifest:
version = 0
reserved = 0
bootflags = sum([Manifest.boot_flags.get(s, 0) for s in self.flags])
outfile.write(struct.pack("<8sBBHHH",
magic, version, reserved,
len(self.programs), len(self.data),
reserved))
bootflags))
def write_str(s):
outfile.write(struct.pack("<H", (len(s)+1)*2))