mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[bootproto] Create new bootproto lib
This is a rather large commit that is widely focused on cleaning things out of the 'junk drawer' that is src/include. Most notably, several things that were put in there because they needed somewhere where both the kernel, boot, and init could read them have been moved to a new lib, 'bootproto'. - Moved kernel_args.h and init_args.h to bootproto as kernel.h and init.h, respectively. - Moved counted.h and pointer_manipulation.h into util, renaming the latter to util/pointers.h. - Created a new src/include/arch for very arch-dependent definitions, and moved some kernel_memory.h constants like frame size, page table entry count, etc to arch/amd64/memory.h. Also created arch/memory.h which detects platform and includes the former. - Got rid of kernel_memory.h entirely in favor of a new, cog-based approach. The new definitions/memory_layout.csv lists memory regions in descending order from the top of memory, their sizes, and whether they are shared outside the kernel (ie, boot needs to know them). The new header bootproto/memory.h exposes the addresses of the shared regions, while the kernel's memory.h gains the start and size of all the regions. Also renamed the badly-named page-offset area the linear area. - The python build scripts got a few new features: the ability to parse the csv mentioned above in a new memory.py module; the ability to add dependencies to existing source files (The list of files that I had to pull out of the main list just to add them with the dependency on memory.h was getting too large. So I put them back into the sources list, and added the dependency post-hoc.); and the ability to reference 'source_root', 'build_root', and 'module_root' variables in .module files. - Some utility functions that were in the kernel's memory.h got moved to util/pointers.h and util/misc.h, and misc.h's byteswap was renamed byteswap32 to be more specific.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
init = module("srv.init",
|
||||
targets = [ "user" ],
|
||||
deps = [ "libc", "elf" ],
|
||||
deps = [ "libc", "elf", "bootproto" ],
|
||||
sources = [
|
||||
"loader.cpp",
|
||||
"main.cpp",
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bootproto/init.h>
|
||||
#include <elf/file.h>
|
||||
#include <elf/headers.h>
|
||||
#include <j6/errors.h>
|
||||
#include <j6/flags.h>
|
||||
#include <j6/syscalls.h>
|
||||
#include <init_args.h>
|
||||
#include <enum_bitfields.h>
|
||||
|
||||
using kernel::init::module_flags;
|
||||
using kernel::init::module_program;
|
||||
using bootproto::module_flags;
|
||||
using bootproto::module_program;
|
||||
|
||||
extern j6_handle_t handle_self;
|
||||
extern j6_handle_t handle_system;
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
/// \file loader.h
|
||||
/// Routines for loading and starting other programs
|
||||
|
||||
namespace kernel {
|
||||
namespace init {
|
||||
namespace bootproto {
|
||||
struct module_program;
|
||||
}}
|
||||
}
|
||||
|
||||
bool load_program(const kernel::init::module_program &prog, char *err_msg);
|
||||
bool load_program(const bootproto::module_program &prog, char *err_msg);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <j6/syscalls.h>
|
||||
#include <init_args.h>
|
||||
#include <bootproto/init.h>
|
||||
|
||||
#include "loader.h"
|
||||
#include "modules.h"
|
||||
|
||||
using kernel::init::module;
|
||||
using kernel::init::module_type;
|
||||
using kernel::init::module_program;
|
||||
using bootproto::module;
|
||||
using bootproto::module_type;
|
||||
using bootproto::module_program;
|
||||
|
||||
extern "C" {
|
||||
int main(int, const char **);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "modules.h"
|
||||
|
||||
using module = kernel::init::module;
|
||||
using modules_page = kernel::init::modules_page;
|
||||
using module = bootproto::module;
|
||||
using modules_page = bootproto::modules_page;
|
||||
|
||||
static const modules_page *
|
||||
get_page(const module *mod)
|
||||
@@ -20,7 +20,7 @@ const module *
|
||||
module_iterator::operator++()
|
||||
{
|
||||
do {
|
||||
m_mod = offset_ptr<module>(m_mod, m_mod->mod_length);
|
||||
m_mod = util::offset_pointer(m_mod, m_mod->mod_length);
|
||||
|
||||
if (m_mod->mod_type == type::none) {
|
||||
// We've reached the end of a page, see if there's another
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
/// \file modules.h
|
||||
/// Routines for loading initial argument modules
|
||||
|
||||
#include <bootproto/init.h>
|
||||
#include <j6/types.h>
|
||||
#include <init_args.h>
|
||||
#include <pointer_manipulation.h>
|
||||
#include <util/pointers.h>
|
||||
|
||||
|
||||
class module_iterator
|
||||
{
|
||||
public:
|
||||
using type = kernel::init::module_type;
|
||||
using module = kernel::init::module;
|
||||
using type = bootproto::module_type;
|
||||
using module = bootproto::module;
|
||||
|
||||
module_iterator(const module *m, type t = type::none) :
|
||||
m_mod {m}, m_type {t} {}
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
class modules
|
||||
{
|
||||
public:
|
||||
using type = kernel::init::module_type;
|
||||
using type = bootproto::module_type;
|
||||
using iterator = module_iterator;
|
||||
|
||||
static modules load_modules(
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
iterator end() const { return nullptr; }
|
||||
|
||||
private:
|
||||
using module = kernel::init::module;
|
||||
using module = bootproto::module;
|
||||
|
||||
modules(const module* root) : m_root {root} {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user