Kernel: Don't use multiboot2 explicitly. Parse it to common structure

This allows support of multiple different bootloaders
This commit is contained in:
2023-11-17 18:54:59 +02:00
parent 641a2dec00
commit 84040e64b8
10 changed files with 226 additions and 97 deletions

View File

@@ -13,11 +13,18 @@
#define MULTIBOOT2_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT2_MAGIC 0x36d76289
struct multiboot2_tag_t
{
uint32_t type;
uint32_t size;
multiboot2_tag_t* next() { return (multiboot2_tag_t*)((uintptr_t)this + ((size + 7) & ~7)); }
const multiboot2_tag_t* next() const
{
return reinterpret_cast<const multiboot2_tag_t*>(
reinterpret_cast<uintptr_t>(this) + ((size + 7) & ~7)
);
}
} __attribute__((packed));
struct multiboot2_cmdline_tag_t : public multiboot2_tag_t
@@ -62,14 +69,3 @@ struct multiboot2_info_t
uint32_t reserved;
multiboot2_tag_t tags[];
} __attribute__((packed));
extern "C" multiboot2_info_t* g_multiboot2_info;
extern "C" uint32_t g_multiboot2_magic;
inline multiboot2_tag_t* multiboot2_find_tag(uint32_t type)
{
for (auto* tag = g_multiboot2_info->tags; tag->type != MULTIBOOT2_TAG_END; tag = tag->next())
if (tag->type == type)
return tag;
return nullptr;
}