[srv.init] Load initial programs in srv.init

Add a simple ELF loader to srv.init to load and start any module_program
parameters passed from the bootloader. Also creates stacks for newly
created threads.

Also update thread creation in testapp to create stacks.
This commit is contained in:
Justin C. Miller
2021-12-26 15:42:12 -08:00
parent 300bf9c2c5
commit 25522a8450
6 changed files with 183 additions and 22 deletions

View File

@@ -1,7 +1,8 @@
#include <stdio.h>
#include "j6/syscalls.h"
#include "init_args.h"
#include "j6/syscalls.h"
#include "loader.h"
#include "modules.h"
using kernel::init::module;
@@ -24,11 +25,17 @@ main(int argc, const char **argv)
modules mods = modules::load_modules(_arg_modules_phys, handle_system, handle_self);
char message[100];
for (auto &mod : mods.of_type(module_type::program)) {
auto &prog = static_cast<const module_program&>(mod);
sprintf(message, " program module '%s' at %lx", prog.filename, prog.base_address);
char message[100];
sprintf(message, " loading program module '%s' at %lx", prog.filename, prog.base_address);
j6_log(message);
if (!load_program(prog, message)) {
j6_log(message);
return 1;
}
}
return 0;