Kernel: Start using multiboot2 instead of multiboot
This allows better compatibility with (U)EFI and gives RSDP location instead of me having to scan ram to find it.
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MULTIBOOT_FLAGS_FRAMEBUFFER (1 << 12)
|
||||
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_TEXT 2
|
||||
|
||||
struct framebuffer_info_t
|
||||
{
|
||||
uint64_t addr;
|
||||
uint32_t pitch;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint8_t bpp;
|
||||
uint8_t type;
|
||||
uint8_t color_info[6];
|
||||
};
|
||||
|
||||
struct multiboot_memory_map_t
|
||||
{
|
||||
uint32_t size;
|
||||
uint64_t base_addr;
|
||||
uint64_t length;
|
||||
uint32_t type;
|
||||
} __attribute__((packed));
|
||||
|
||||
// https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format
|
||||
struct multiboot_info_t
|
||||
{
|
||||
uint32_t flags;
|
||||
uint32_t mem_lower;
|
||||
uint32_t mem_upper;
|
||||
uint32_t boot_device;
|
||||
uint32_t cmdline;
|
||||
uint32_t mods_count;
|
||||
uint32_t mods_addr;
|
||||
uint32_t syms[4];
|
||||
uint32_t mmap_length;
|
||||
uint32_t mmap_addr;
|
||||
uint32_t drives_length;
|
||||
uint32_t drives_addr;
|
||||
uint32_t config_table;
|
||||
uint32_t boot_loader_name;
|
||||
uint32_t apm_table;
|
||||
uint32_t vbe_control_info;
|
||||
uint32_t vbe_mode_info;
|
||||
uint16_t vbe_mode;
|
||||
uint16_t vbe_interface_seg;
|
||||
uint16_t vbe_interface_off;
|
||||
uint16_t vbe_interface_len;
|
||||
framebuffer_info_t framebuffer;
|
||||
};
|
||||
|
||||
extern "C" multiboot_info_t* g_multiboot_info;
|
||||
extern "C" uint32_t g_multiboot_magic;
|
||||
75
kernel/include/kernel/multiboot2.h
Normal file
75
kernel/include/kernel/multiboot2.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#Boot-information
|
||||
|
||||
#define MULTIBOOT2_TAG_END 0
|
||||
#define MULTIBOOT2_TAG_CMDLINE 1
|
||||
#define MULTIBOOT2_TAG_MMAP 6
|
||||
#define MULTIBOOT2_TAG_FRAMEBUFFER 8
|
||||
#define MULTIBOOT2_TAG_OLD_RSDP 14
|
||||
#define MULTIBOOT2_TAG_NEW_RSDP 15
|
||||
|
||||
#define MULTIBOOT2_FRAMEBUFFER_TYPE_RGB 1
|
||||
|
||||
struct multiboot2_tag_t
|
||||
{
|
||||
uint32_t type;
|
||||
uint32_t size;
|
||||
multiboot2_tag_t* next() { return (multiboot2_tag_t*)((uintptr_t)this + ((size + 7) & ~7)); }
|
||||
} __attribute__((packed));
|
||||
|
||||
struct multiboot2_cmdline_tag_t : public multiboot2_tag_t
|
||||
{
|
||||
char cmdline[];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct multiboot2_mmap_entry_t
|
||||
{
|
||||
uint64_t base_addr;
|
||||
uint64_t length;
|
||||
uint32_t type;
|
||||
uint32_t reserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct multiboot2_mmap_tag_t : public multiboot2_tag_t
|
||||
{
|
||||
uint32_t entry_size;
|
||||
uint32_t entry_version;
|
||||
multiboot2_mmap_entry_t entries[];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct multiboot2_framebuffer_tag_t : public multiboot2_tag_t
|
||||
{
|
||||
uint64_t framebuffer_addr;
|
||||
uint32_t framebuffer_pitch;
|
||||
uint32_t framebuffer_width;
|
||||
uint32_t framebuffer_height;
|
||||
uint8_t framebuffer_bpp;
|
||||
uint8_t framebuffer_type;
|
||||
uint8_t reserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct multiboot2_rsdp_tag_t : public multiboot2_tag_t
|
||||
{
|
||||
uint8_t data[];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct multiboot2_info_t
|
||||
{
|
||||
uint32_t total_size;
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user