9#include <system/multiboot.h>
14using namespace MaxOS::system;
15using namespace MaxOS::memory;
16using namespace MaxOS::common;
25: start_address(address)
29 ASSERT(magic == MULTIBOOT2_BOOTLOADER_MAGIC,
"Multiboot2 Bootloader Not Detected");
30 Logger::DEBUG() <<
"Multiboot2 Bootloader Detected at 0x" << (uint64_t) address <<
"\n";
42 case MULTIBOOT_TAG_TYPE_END:
46 case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
48 Logger::DEBUG() <<
"Framebuffer: addr=0x" << (uint64_t) m_framebuffer -> common.framebuffer_addr <<
", screen=" << (uint64_t) m_framebuffer -> common.framebuffer_height<<
"x" << (uint64_t) m_framebuffer -> common.framebuffer_width <<
"\n";
51 case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
55 case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
60 case MULTIBOOT_TAG_TYPE_BOOTDEV:
63 Logger::DEBUG() <<
"Boot device: drive=0x" << (uint64_t) bootdev->
biosdev <<
", partition=0x" << (uint64_t) bootdev->
part <<
"\n";
66 case MULTIBOOT_TAG_TYPE_MMAP:
69 if (m_mmap ==
nullptr)
74 case MULTIBOOT_TAG_TYPE_ACPI_OLD:
79 case MULTIBOOT_TAG_TYPE_ACPI_NEW:
83 case MULTIBOOT_TAG_TYPE_MODULE:
85 module = (multiboot_tag_module*) tag;
86 Logger::DEBUG() <<
"Module: start=0x" << (uint64_t) module->mod_start <<
", end=0x" << (uint64_t)
module->mod_end << ", cmdline=" << module->cmdline << "\n";
92 tag = (
struct multiboot_tag*) ((multiboot_uint8_t*) tag + ((tag->
size + 7) & ~7));
96Multiboot::~Multiboot() =
default;
104 return m_framebuffer;
113 return m_basic_meminfo;
122 return m_bootloader_name;
163 if (tag->type != MULTIBOOT_TAG_TYPE_MODULE && tag->type != MULTIBOOT_TAG_TYPE_MMAP)
167 auto*
module = (struct multiboot_tag_module*) tag;
170 if (address >= module->mod_start && address < module->mod_end)
static LogRecord DEBUG()
Gets the active logger for debug logs.
static void * to_lower_region(uintptr_t virtual_address)
Converts a virtual address to a lower region address if it is in the higher region using the higher h...
bool is_reserved(multiboot_uint64_t address) const
Check if an address is reserved by a multiboot module.
unsigned long end_address
The end address of the multiboot info struct.
multiboot_tag * start_tag() const
multiboot_tag_basic_meminfo * basic_meminfo()
Get the basic memory info tag.
multiboot_tag_string * bootloader_name()
Get the bootloader name tag.
multiboot_tag_framebuffer * framebuffer()
Get the framebuffer tag.
Multiboot(unsigned long address, unsigned long magic)
Constructor for the Multiboot class. Parses the multiboot info struct and loads the tags.
multiboot_tag_old_acpi * old_acpi()
Get the old ACPI tag.
multiboot_tag_new_acpi * new_acpi()
Get the new ACPI tag.
multiboot_tag_mmap * mmap()
Get the module tag.
unsigned long start_address
The start address of the multiboot info struct.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
Defines a MemoryManager class for handling memory allocation and deallocation.
constexpr uint64_t HIGHER_HALF_KERNEL_OFFSET
Where the kernel is mapped in higher half memory.
A tag containing basic (legacy) memory information.
A tag containing information about the device the OS image was loaded from.
multiboot_uint32_t biosdev
The BIOS disk device the OS image was loaded from.
multiboot_uint32_t part
The partition number of the disk device.
A tag containing information about the framebuffer.
A tag containing the collection of memory map entries that outline the memory layout.
A tag containing information about a loaded module.
A tag containing information about the new ACPI RSDP.
A tag containing information about the old ACPI RSDP.
A tag containing a null-terminated string.
char string[0]
The string.
Common header for all multiboot info tags.
multiboot_uint32_t size
The size of the tag including this header.
multiboot_uint32_t type
The type of the tag.