Move args structure allocation to a function in memory.cpp

This commit is contained in:
Justin C. Miller
2020-02-24 02:18:14 -08:00
parent 36b3ad8154
commit 1a223d6ef5
3 changed files with 38 additions and 27 deletions

View File

@@ -233,5 +233,33 @@ memory_virtualize(EFI_RUNTIME_SERVICES *runsvc, struct memory_map *map)
}
*/
kernel::args::header *
allocate_args_structure(uefi::boot_services *bs, size_t max_modules)
{
status_line status(L"Setting up kernel args memory");
kernel::args::header *args = nullptr;
size_t args_size =
sizeof(kernel::args::header) + // The header itself
max_modules * sizeof(kernel::args::module); // The module structures
try_or_raise(
bs->allocate_pool(
uefi::memory_type::loader_data,
args_size,
reinterpret_cast<void**>(&args)),
L"Could not allocate argument memory");
bs->set_mem(args, args_size, 0);
args->modules =
reinterpret_cast<kernel::args::module*>(args + 1);
args->num_modules = 0;
return args;
}
} // namespace boot
} // namespace memory