multiboot2: use config_get_tuple when appropriate

This commit is contained in:
Nathan Royer 2022-05-28 05:05:11 +02:00 committed by mintsuki
parent dd0790a5e0
commit 67b75fa059

View File

@ -251,14 +251,11 @@ bool multiboot2_load(char *config, char* cmdline) {
size_t n_modules;
for (n_modules = 0;; n_modules++) {
if (config_get_value(config, modules_size, "MODULE_PATH") == NULL)
break;
char *module_cmdline = config_get_value(config, modules_size, "MODULE_STRING");
if (module_cmdline == NULL) {
module_cmdline = "";
}
struct conf_tuple conf_tuple = config_get_tuple(config, n_modules, "MODULE_PATH", "MODULE_STRING");
if (!conf_tuple.value1) break;
char *module_cmdline = conf_tuple.value2;
if (!module_cmdline) module_cmdline = "";
modules_size += sizeof(struct multiboot_tag_module) + strlen(module_cmdline) + 1;
}
@ -291,9 +288,9 @@ bool multiboot2_load(char *config, char* cmdline) {
// Create modules tag
//////////////////////////////////////////////
for (size_t i = 0; i < n_modules; i++) {
char *module_path = config_get_value(config, i, "MODULE_PATH");
if (module_path == NULL)
panic(true, "multiboot2: Module disappeared unexpectedly");
struct conf_tuple conf_tuple = config_get_tuple(config, i, "MODULE_PATH", "MODULE_STRING");
char *module_path = conf_tuple.value1;
if (!module_path) panic(true, "multiboot2: Module disappeared unexpectedly");
print("multiboot2: Loading module `%s`...\n", module_path);
@ -301,14 +298,12 @@ bool multiboot2_load(char *config, char* cmdline) {
if ((f = uri_open(module_path)) == NULL)
panic(true, "multiboot2: Failed to open module with path `%s`. Is the path correct?", module_path);
char *module_cmdline = config_get_value(config, i, "MODULE_STRING");
void *module_addr = (void *)(uintptr_t)ALIGN_UP(kernel_top, 4096);
// Module commandline can be null, so we guard against that and make the
// string "".
if (module_cmdline == NULL) {
module_cmdline = "";
}
char *module_cmdline = conf_tuple.value2;
if (!module_cmdline) module_cmdline = "";
while (!memmap_alloc_range((uintptr_t)module_addr, f->size, MEMMAP_KERNEL_AND_MODULES,
true, false, false, false)) {