[srv.init] Create init server and read init args

Create a new usermode program, srv.init, and have it read the initial
module_page args sent to it by the bootloader. Doesn't yet do anything
useful but sets up the way for loading the rest of the programs from
srv.init.

Other (mostly) related changes:

- bootloader: The allocator now has a function for allocating init
  modules out of a modules_page slab. Also changed how the allocator is
  initialized and passes the allocation register and modules_page list
  to efi_main().
- bootloader: Expose the simple wstrlen() to the rest of the program
- bootloader: Move check_cpu_supported() to hardware.cpp
- bootloader: Moved program_desc to loader.h and made the loader
  functions take it as an argument instead of paths.
- kernel: Rename the system_map_mmio syscall to system_map_phys, and
  stop having it default those VMAs to having the vm_flags::mmio flag.
  Added a new flag mask, vm_flags::driver_mask, so that drivers can be
  allowed to ask for the MMIO flag.
- kernel: Rename load_simple_process() to load_init_server() and got rid
  of all the stack setup routines in memory_bootstrap.cpp and task.s
- Fixed formatting in config/debug.toml, undefined __linux and other
  linux-specific defines, and got rid of _LIBCPP_HAS_THREAD_API_EXTERNAL
  because that's just not true.
This commit is contained in:
Justin C. Miller
2021-07-31 10:00:08 -07:00
parent 1802c5ea2e
commit 5524ca5b25
28 changed files with 464 additions and 270 deletions

View File

@@ -2,12 +2,18 @@
/// \file allocator.h
/// Page allocator class definition
#include "kernel_args.h"
namespace uefi {
class boot_services;
}
namespace kernel {
namespace init {
enum class allocation_type : uint8_t;
struct allocation_register;
struct module;
struct modules_page;
}}
namespace boot {
namespace memory {
@@ -17,6 +23,8 @@ class allocator
{
public:
using allocation_register = kernel::init::allocation_register;
using module = kernel::init::module;
using modules_page = kernel::init::modules_page;
allocator(uefi::boot_services &bs);
@@ -25,25 +33,37 @@ public:
void * allocate_pages(size_t count, alloc_type type, bool zero = false);
template <typename M>
M * allocate_module(size_t extra = 0) {
return static_cast<M*>(allocate_module_untyped(sizeof(M) + extra));
}
void memset(void *start, size_t size, uint8_t value);
void copy(void *to, void *from, size_t size);
inline void zero(void *start, size_t size) { memset(start, size, 0); }
allocation_register * get_register() { return m_register; }
/// Initialize the global allocator
/// \arg allocs [out] Poiinter to the initial allocation register
/// \arg modules [out] Pointer to the initial modules_page
/// \arg bs UEFI boot services
static void init(
allocation_register *&allocs,
modules_page *&modules,
uefi::boot_services *bs);
private:
void add_register();
void add_modules();
module * allocate_module_untyped(size_t size);
uefi::boot_services &m_bs;
allocation_register *m_register;
allocation_register *m_current;
modules_page *m_modules;
module *m_next_mod;
};
/// Initialize the global allocator
void init_allocator(uefi::boot_services *bs);
} // namespace memory
extern memory::allocator &g_alloc;