Bootloader: Implement VESA video mode query and pass it to kernel

Kernel now gets framebuffer from bootloader. Framebuffer dimensions
and bpp are hardcoded in bootloader, but will probably be read from
config file at some point.
This commit is contained in:
2023-11-17 22:45:35 +02:00
parent ac96ea3370
commit c9e9cfd361
6 changed files with 187 additions and 8 deletions

View File

@@ -2,7 +2,18 @@
#include <stdint.h>
#define BANAN_BOOTLOADER_MAGIC 0xD3C60CFF
#define BANAN_BOOTLOADER_MAGIC 0xD3C60CFF
#define BANAN_BOOTLOADER_FB_RGB 1
struct BananBootFramebufferInfo
{
uint32_t address;
uint32_t pitch;
uint32_t width;
uint32_t height;
uint8_t bpp;
uint8_t type;
};
struct BananBootloaderMemoryMapEntry
{
@@ -20,5 +31,6 @@ struct BananBootloaderMemoryMapInfo
struct BananBootloaderInfo
{
uint32_t command_line_addr;
uint32_t framebuffer_addr;
uint32_t memory_map_addr;
} __attribute__((packed));

View File

@@ -71,6 +71,17 @@ namespace Kernel
const char* command_line = reinterpret_cast<const char*>(banan_bootloader_info.command_line_addr);
MUST(g_boot_info.command_line.append(command_line));
const auto& framebuffer = *reinterpret_cast<BananBootFramebufferInfo*>(banan_bootloader_info.framebuffer_addr);
if (framebuffer.type == BANAN_BOOTLOADER_FB_RGB)
{
g_boot_info.framebuffer.address = framebuffer.address;
g_boot_info.framebuffer.width = framebuffer.width;
g_boot_info.framebuffer.height = framebuffer.height;
g_boot_info.framebuffer.pitch = framebuffer.pitch;
g_boot_info.framebuffer.bpp = framebuffer.bpp;
g_boot_info.framebuffer.type = FramebufferType::RGB;
}
const auto& memory_map = *reinterpret_cast<BananBootloaderMemoryMapInfo*>(banan_bootloader_info.memory_map_addr);
MUST(g_boot_info.memory_map_entries.resize(memory_map.entry_count));
for (size_t i = 0; i < memory_map.entry_count; i++)