SayoriOS 0.3.3

grub_modules.c
1 //
2 // Created by ndraey on 2/10/24.
3 //
4
5 #include "sys/grub_modules.h"
6 #include "multiboot.h"
7 #include "io/ports.h"
8 #include "lib/string.h"
9 #include "drv/disk/initrd.h"
10
11 size_t grub_last_module_end = 0;
12
13 // Needed to configure physical memory manager
14 void grub_modules_prescan(multiboot_header_t* hdr) {
15 multiboot_module_t *mod = ((multiboot_module_t *)hdr->mods_addr) + hdr->mods_count - 1;
16
17 grub_last_module_end = mod->mod_end;
18 }
19
20
21 void grub_modules_init(multiboot_header_t* hdr) {
22 qemu_log("Initializing kernel modules...");
23
24 if(hdr->mods_count == 0) {
25 qemu_err("No modules were connected!");
26 return;
27 }
28
29 qemu_log("Found %d modules", hdr->mods_count);
30
31 multiboot_module_t* module_list = (multiboot_module_t*)hdr->mods_addr;
32
33 for (size_t i = 0; i < hdr->mods_count; i++) {
34 multiboot_module_t *mod = module_list + i;
35
36 size_t mod_size = mod->mod_end - mod->mod_start;
37
38 qemu_log("[kModules] Found module #%d. (Start: %x | End: %x | Size: %d); CMD: %s (at %x)",
39 i,
40 mod->mod_start,
41 mod->mod_end,
42 mod_size,
43 (char*)mod->cmdline,
44 (size_t)mod->cmdline
45 );
46
47 if (strcmp((const char *) mod->cmdline, "initrd_tarfs") == 0) {
48 initrd_tarfs(mod->mod_start, mod->mod_end);
49 }
50 }
51 }
strcmp
int strcmp(const char *s1, const char *s2)
Сравнение строк
Definition: string.c:253
multiboot_header
Definition: multiboot.h:24
multiboot_mod_list
Definition: multiboot.h:77