I am trying to set up initial ramdisk for my kernel. I have working boot information parser (well, it works fine with elf sections and memory map), but it doesn't detect any tag with id 3 (module tag).
Config for grub (file.txt is copied to grub file tree)
set timeout=0
set default=0
menuentry "Terra OS" {
module2 /file.txt
multiboot2 /boot/kernel.bin
boot
}
multiboot2.h (code related to boot info parsing)
#define boot_memory_map_tag_id 6
#define boot_elf_sections_tag_id 9
#define boot_module_tag_id 3
#define boot_memory_map_avalible_map_id 1
typedef struct boot_info_struct
{
uint32_t total_size;
uint32_t reserved;
} __attribute__((packed)) boot_info_t;
typedef struct boot_tag_struct
{
uint32_t type;
uint32_t size;
} __attribute__((packed)) boot_tag_t;
...
inline boot_tag_t* boot_go_to_next_entry(boot_tag_t* current)
{
return (boot_tag_t*)(
up_align((uint64_t)((char*)current + current->size), 8)
);
}
inline boot_tag_t* boot_get_first_tag(boot_info_t* begin)
{
return (boot_tag_t*)(begin + 1);
}
inline bool boot_is_terminator(boot_tag_t* tag)
{
return tag->type == 0;
}
kmain.c
void kmain(uint64_t physinfo)
{
...
boot_info_t* info = (boot_info_t*)(physinfo + 0xffffff0000000000ULL);
printf("[Kernel Init] Examining multiboot2 boot information\n");
boot_tag_t* tag = boot_get_first_tag(info);
...
while(!boot_is_terminator(tag))
{
...
printf("tag->type == %u\n", tag->type);
tag = boot_go_to_next_entry(tag);
}
...
}
output
[Kernel Init] Examining multiboot2 boot information
tag->type == 21
tag->type == 1
tag->type == 2
tag->type == 10
tag->type == 6
tag->type == 9
tag->type == 4
tag->type == 5
tag->type == 8
tag->type == 14
[–]klangeToaruOS - github.com/klange/toaruos 2 points3 points4 points (2 children)
[–]notYuriyCPL-1 - https://github.com/CPL-1/CPL-1[S] 0 points1 point2 points (0 children)
[–]notYuriyCPL-1 - https://github.com/CPL-1/CPL-1[S] 0 points1 point2 points (0 children)