limine: Honour LIMINE_INTERNAL_MODULE_REQUIRED flag

This commit is contained in:
mintsuki 2023-03-24 10:18:18 +01:00
parent 830251e68e
commit 698ca1a665
2 changed files with 24 additions and 9 deletions

View File

@ -647,9 +647,11 @@ FEAT_START
struct limine_file *modules = ext_mem_alloc(module_count * sizeof(struct limine_file));
size_t final_module_count = 0;
for (size_t i = 0; i < module_count; i++) {
char *module_path;
char *module_cmdline;
bool module_required = true;
if (i < module_request->internal_module_count) {
uint64_t *internal_modules = (void *)get_phys_addr(module_request->internal_modules);
@ -657,6 +659,8 @@ FEAT_START
module_path = (char *)get_phys_addr(internal_module->path);
module_cmdline = (char *)get_phys_addr(internal_module->cmdline);
module_required = internal_module->flags & LIMINE_INTERNAL_MODULE_REQUIRED;
} else {
struct conf_tuple conf_tuple =
config_get_tuple(config, i - module_request->internal_module_count,
@ -673,21 +677,26 @@ FEAT_START
print("limine: Loading module `%#`...\n", module_path);
struct file_handle *f;
if ((f = uri_open(module_path)) == NULL)
panic(true, "limine: Failed to open module with path `%#`. Is the path correct?", module_path);
if ((f = uri_open(module_path)) == NULL) {
if (module_required) {
panic(true, "limine: Failed to open module with path `%#`. Is the path correct?", module_path);
}
print("limine: Warning: Non-required internal module `%#` not found\n", module_path);
continue;
}
struct limine_file *l = &modules[i];
struct limine_file *l = &modules[final_module_count++];
*l = get_file(f, module_cmdline);
fclose(f);
}
uint64_t *modules_list = ext_mem_alloc(module_count * sizeof(uint64_t));
for (size_t i = 0; i < module_count; i++) {
uint64_t *modules_list = ext_mem_alloc(final_module_count * sizeof(uint64_t));
for (size_t i = 0; i < final_module_count; i++) {
modules_list[i] = reported_addr(&modules[i]);
}
module_response->module_count = module_count;
module_response->module_count = final_module_count;
module_response->modules = reported_addr(modules_list);
module_request->response = reported_addr(module_response);

View File

@ -56,19 +56,25 @@ __attribute__((section(".limine_reqs")))
void *kf_req = &kf_request;
struct limine_internal_module internal_module1 = {
.path = "boot:///boot/test.elf",
.path = "/boot/test.elf",
.cmdline = "First internal module"
};
struct limine_internal_module internal_module2 = {
.path = "test.elf",
.cmdline = "Second internal module"
};
struct limine_internal_module *internal_modules[] = {
&internal_module1
&internal_module1,
&internal_module2
};
struct limine_module_request module_request = {
.id = LIMINE_MODULE_REQUEST,
.revision = 1, .response = NULL,
.internal_module_count = 1,
.internal_module_count = 2,
.internal_modules = internal_modules
};