limine: Move module request to using SoA

This commit is contained in:
mintsuki 2022-03-18 08:48:48 +01:00
parent 82627d8693
commit f39578f4e3
3 changed files with 39 additions and 41 deletions

View File

@ -186,20 +186,15 @@ struct limine_entry_point_request {
#define LIMINE_MODULE_REQUEST { LIMINE_COMMON_MAGIC, 0x3e7e279702be32af, 0xca1c4f3bd1280cee } #define LIMINE_MODULE_REQUEST { LIMINE_COMMON_MAGIC, 0x3e7e279702be32af, 0xca1c4f3bd1280cee }
struct limine_module {
uint64_t base;
uint64_t length;
LIMINE_PTR(char *) path;
LIMINE_PTR(char *) cmdline;
LIMINE_PTR(struct limine_file_location *) file_location;
uint8_t reserved[256];
};
struct limine_module_response { struct limine_module_response {
uint64_t flags; uint64_t flags;
uint64_t modules_count; uint64_t module_count;
LIMINE_PTR(struct limine_module *) modules; LIMINE_PTR(uint64_t *) module_base;
LIMINE_PTR(uint64_t *) module_length;
LIMINE_PTR(LIMINE_PTR(char *) *) module_path;
LIMINE_PTR(LIMINE_PTR(char *) *) module_cmdline;
LIMINE_PTR(LIMINE_PTR(struct limine_file_location *) *) module_file_location;
}; };
struct limine_module_request { struct limine_module_request {

View File

@ -324,50 +324,55 @@ FEAT_START
struct limine_module_response *module_response = struct limine_module_response *module_response =
ext_mem_alloc(sizeof(struct limine_module_response)); ext_mem_alloc(sizeof(struct limine_module_response));
struct limine_module *modules = ext_mem_alloc(module_count * sizeof(struct limine_module)); uint64_t *module_base = ext_mem_alloc(sizeof(uint64_t) * module_count);
uint64_t *module_length = ext_mem_alloc(sizeof(uint64_t) * module_count);
uint64_t *module_path = ext_mem_alloc(sizeof(uint64_t) * module_count);
uint64_t *module_cmdline = ext_mem_alloc(sizeof(uint64_t) * module_count);
uint64_t *module_file_location = ext_mem_alloc(sizeof(uint64_t) * module_count);
modules[0].base = reported_addr(kernel); module_base[0] = reported_addr(kernel);
modules[0].length = kernel_file_size; module_length[0] = kernel_file_size;
modules[0].path = reported_addr(kernel_path); module_path[0] = reported_addr(kernel_path);
modules[0].cmdline = reported_addr(cmdline); module_cmdline[0] = reported_addr(cmdline);
module_file_location[0] = reported_addr(kl);
modules[0].file_location = reported_addr(kl);
for (size_t i = 1; i < module_count; i++) { for (size_t i = 1; i < module_count; i++) {
struct conf_tuple conf_tuple = struct conf_tuple conf_tuple =
config_get_tuple(config, i - 1, config_get_tuple(config, i - 1,
"MODULE_PATH", "MODULE_CMDLINE"); "MODULE_PATH", "MODULE_CMDLINE");
char *module_path = conf_tuple.value1; char *m_path = conf_tuple.value1;
char *module_cmdline = conf_tuple.value2; char *m_cmdline = conf_tuple.value2;
struct limine_module *m = &modules[i]; if (m_cmdline == NULL) {
m_cmdline = "";
if (module_cmdline == NULL) {
module_cmdline = "";
} }
print("limine: Loading module `%s`...\n", module_path); print("limine: Loading module `%s`...\n", module_path);
struct file_handle *f; struct file_handle *f;
if ((f = uri_open(module_path)) == NULL) if ((f = uri_open(m_path)) == NULL)
panic(true, "limine: Failed to open module with path `%s`. Is the path correct?", module_path); panic(true, "limine: Failed to open module with path `%s`. Is the path correct?", module_path);
m->base = reported_addr(freadall(f, MEMMAP_KERNEL_AND_MODULES)); module_base[i] = reported_addr(freadall(f, MEMMAP_KERNEL_AND_MODULES));
m->length = f->size; module_length[i] = f->size;
m->path = reported_addr(module_path); module_path[i] = reported_addr(m_path);
m->cmdline = reported_addr(module_cmdline); module_cmdline[i] = reported_addr(m_cmdline);
struct limine_file_location *l = ext_mem_alloc(sizeof(struct limine_file_location)); struct limine_file_location *l = ext_mem_alloc(sizeof(struct limine_file_location));
*l = get_file_loc(f); *l = get_file_loc(f);
m->file_location = reported_addr(l); module_file_location[i] = reported_addr(l);
fclose(f); fclose(f);
} }
module_response->modules_count = module_count; module_response->module_count = module_count;
module_response->modules = reported_addr(modules); module_response->module_base = reported_addr(module_base);
module_response->module_length = reported_addr(module_length);
module_response->module_path = reported_addr(module_path);
module_response->module_cmdline = reported_addr(module_cmdline);
module_response->module_file_location = reported_addr(module_file_location);
module_request->response = reported_addr(module_response); module_request->response = reported_addr(module_response);
FEAT_END FEAT_END

View File

@ -182,16 +182,14 @@ FEAT_START
} }
e9_printf(""); e9_printf("");
struct limine_module_response *module_response = module_request.response; struct limine_module_response *module_response = module_request.response;
e9_printf("%d module(s)", module_response->modules_count); e9_printf("%d module(s)", module_response->module_count);
for (size_t i = 0; i < module_response->modules_count; i++) { for (size_t i = 0; i < module_response->module_count; i++) {
struct limine_module *m = &module_response->modules[i]; e9_printf("Base: %x", module_response->module_base[i]);
e9_printf("Length: %x", module_response->module_length[i]);
e9_printf("Path: %s", module_response->module_path[i]);
e9_printf("Cmdline: %s", module_response->module_cmdline[i]);
e9_printf("Base: %x", m->base); print_file_loc(module_response->module_file_location[i]);
e9_printf("Length: %x", m->length);
e9_printf("Path: %s", m->path);
e9_printf("Cmdline: %s", m->cmdline);
print_file_loc(m->file_location);
} }
FEAT_END FEAT_END