[init] Go back to boot modules having inline data
In order to pass along arguments like the framebuffer, it's far simpler to have that data stored along with the modules than mapping new pages for every structure. Also now optionally pass a module's data to a driver as init starts it.
This commit is contained in:
@@ -71,10 +71,10 @@ allocator::add_modules()
|
||||
allocate_pages(1, alloc_type::init_args, true));
|
||||
|
||||
if (m_modules)
|
||||
m_modules->next = reinterpret_cast<uintptr_t>(mods);
|
||||
m_modules->next = mods;
|
||||
|
||||
m_modules = mods;
|
||||
m_next_mod = mods->modules;
|
||||
m_next_mod = reinterpret_cast<module*>(mods+1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,9 +109,9 @@ allocator::allocate_pages(size_t count, alloc_type type, bool zero)
|
||||
}
|
||||
|
||||
module *
|
||||
allocator::allocate_module()
|
||||
allocator::allocate_module(size_t extra)
|
||||
{
|
||||
static constexpr size_t size = sizeof(module);
|
||||
size_t size = sizeof(module) + extra;
|
||||
|
||||
size_t remaining =
|
||||
reinterpret_cast<uintptr_t>(m_modules) + page_size
|
||||
@@ -120,8 +120,8 @@ allocator::allocate_module()
|
||||
if (size > remaining)
|
||||
add_modules();
|
||||
|
||||
++m_modules->count;
|
||||
module *m = m_next_mod;
|
||||
m->bytes = size;
|
||||
m_next_mod = util::offset_pointer(m_next_mod, size);
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
void * allocate_pages(size_t count, alloc_type type, bool zero = false);
|
||||
|
||||
module * allocate_module();
|
||||
module * allocate_module(size_t extra = 0);
|
||||
|
||||
void memset(void *start, size_t size, uint8_t value);
|
||||
void copy(void *to, const void *from, size_t size);
|
||||
|
||||
@@ -167,15 +167,15 @@ load_module(
|
||||
fs::file &disk,
|
||||
const wchar_t *name,
|
||||
const wchar_t *path,
|
||||
bootproto::module_type type,
|
||||
uint16_t subtype)
|
||||
bootproto::module_type type)
|
||||
{
|
||||
status_line status(L"Loading module", name);
|
||||
|
||||
bootproto::module *mod = g_alloc.allocate_module();
|
||||
bootproto::module *mod = g_alloc.allocate_module(sizeof(util::buffer));
|
||||
mod->type = type;
|
||||
mod->subtype = subtype;
|
||||
mod->data = load_file(disk, path);
|
||||
|
||||
util::buffer *data = mod->data<util::buffer>();
|
||||
*data = load_file(disk, path);
|
||||
}
|
||||
|
||||
} // namespace loader
|
||||
|
||||
@@ -60,14 +60,12 @@ load_program(
|
||||
/// \arg name The human-readable name of the module
|
||||
/// \arg path The path of the file to load the module from
|
||||
/// \arg type The major type to set on the module
|
||||
/// \arg subtype The subtype to set on the module
|
||||
void
|
||||
load_module(
|
||||
fs::file &disk,
|
||||
const wchar_t *name,
|
||||
const wchar_t *path,
|
||||
bootproto::module_type type,
|
||||
uint16_t subtype);
|
||||
bootproto::module_type type);
|
||||
|
||||
} // namespace loader
|
||||
} // namespace boot
|
||||
|
||||
@@ -125,7 +125,7 @@ load_resources(
|
||||
loader::parse_program(L"init server", init, args->init);
|
||||
|
||||
loader::load_module(disk, L"initrd", bc.initrd(),
|
||||
bootproto::module_type::initrd, 0);
|
||||
bootproto::module_type::initrd);
|
||||
|
||||
return reinterpret_cast<bootproto::entrypoint>(kentry);
|
||||
}
|
||||
@@ -194,6 +194,7 @@ efi_main(uefi::handle image, uefi::system_table *st)
|
||||
|
||||
change_pointer(args);
|
||||
change_pointer(args->pml4);
|
||||
change_pointer(args->symbol_table.pointer);
|
||||
change_pointer(args->init.sections.pointer);
|
||||
|
||||
//status.next();
|
||||
|
||||
@@ -109,20 +109,15 @@ make_module(screen *s)
|
||||
{
|
||||
using bootproto::module;
|
||||
using bootproto::module_type;
|
||||
using bootproto::device_type;
|
||||
using bootproto::devices::uefi_fb;
|
||||
namespace devices = bootproto::devices;
|
||||
|
||||
uefi_fb *fb = new uefi_fb;
|
||||
module *mod = g_alloc.allocate_module(sizeof(devices::uefi_fb));
|
||||
mod->type = module_type::device;
|
||||
mod->type_id = devices::type_id_uefi_fb;
|
||||
|
||||
devices::uefi_fb *fb = mod->data<devices::uefi_fb>();
|
||||
fb->framebuffer = s->framebuffer;
|
||||
fb->mode = s->mode;
|
||||
|
||||
module *mod = g_alloc.allocate_module();
|
||||
mod->type = module_type::device;
|
||||
mod->subtype = static_cast<uint16_t>(device_type::uefi_fb);
|
||||
mod->data = {
|
||||
.pointer = fb,
|
||||
.count = sizeof(uefi_fb),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace video
|
||||
|
||||
Reference in New Issue
Block a user