diff --git a/bootloader/boot.S b/bootloader/boot.S index e5ae1f1818..1397c5b200 100644 --- a/bootloader/boot.S +++ b/bootloader/boot.S @@ -108,7 +108,16 @@ protected_mode: movw %bx, %fs movw %bx, %gs movw %bx, %ss - jmp *%eax + + movl %eax, %ecx + + movl $0xD3C60CFF, %eax + movl $banan_boot_info, %ebx + xorl %edx, %edx + xorl %esi, %esi + xorl %edi, %edi + + jmp *%ecx .code16 @@ -154,3 +163,9 @@ gdt: gdtr: .short . - gdt - 1 .quad gdt + +banan_boot_info: + boot_command_line: + .long command_line + boot_memory_map: + .long memory_map diff --git a/bootloader/command_line.S b/bootloader/command_line.S index 964790c8aa..8a04121185 100644 --- a/bootloader/command_line.S +++ b/bootloader/command_line.S @@ -68,6 +68,8 @@ command_line_enter_msg: .section .bss +.global command_line +command_line: # 100 character command line command_line_buffer: .skip 100 diff --git a/bootloader/memory_map.S b/bootloader/memory_map.S index ca1908c5de..55c7d71074 100644 --- a/bootloader/memory_map.S +++ b/bootloader/memory_map.S @@ -122,6 +122,8 @@ memory_map_error_msg: .section .bss +.global memory_map +memory_map: memory_map_entry_count: .skip 4 # 100 entries should be enough... diff --git a/kernel/include/kernel/BananBootloader.h b/kernel/include/kernel/BananBootloader.h new file mode 100644 index 0000000000..be595cc518 --- /dev/null +++ b/kernel/include/kernel/BananBootloader.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +#define BANAN_BOOTLOADER_MAGIC 0xD3C60CFF + +struct BananBootloaderMemoryMapEntry +{ + uint64_t address; + uint64_t length; + uint32_t type; +} __attribute__((packed)); + +struct BananBootloaderMemoryMapInfo +{ + uint32_t entry_count; + BananBootloaderMemoryMapEntry entries[]; +} __attribute__((packed)); + +struct BananBootloaderInfo +{ + uint32_t command_line_addr; + uint32_t memory_map_addr; +} __attribute__((packed)); diff --git a/kernel/kernel/BootInfo.cpp b/kernel/kernel/BootInfo.cpp index cf6420df8a..5193fa088a 100644 --- a/kernel/kernel/BootInfo.cpp +++ b/kernel/kernel/BootInfo.cpp @@ -1,5 +1,5 @@ #include - +#include #include namespace Kernel @@ -64,10 +64,36 @@ namespace Kernel return {}; } + void parse_boot_info_banan_bootloader(uint32_t info) + { + const auto& banan_bootloader_info = *reinterpret_cast(info); + + const char* command_line = reinterpret_cast(banan_bootloader_info.command_line_addr); + MUST(g_boot_info.command_line.append(command_line)); + + const auto& memory_map = *reinterpret_cast(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++) + { + const auto& mmap_entry = memory_map.entries[i]; + g_boot_info.memory_map_entries[i].address = mmap_entry.address; + g_boot_info.memory_map_entries[i].length = mmap_entry.length; + g_boot_info.memory_map_entries[i].type = mmap_entry.type; + } + } + + BAN::StringView get_early_boot_command_line_banan_bootloader(uint32_t info) + { + const auto& banan_bootloader_info = *reinterpret_cast(info); + return reinterpret_cast(banan_bootloader_info.command_line_addr); + } + bool validate_boot_magic(uint32_t magic) { if (magic == MULTIBOOT2_MAGIC) return true; + if (magic == BANAN_BOOTLOADER_MAGIC) + return true; return false; } @@ -77,6 +103,8 @@ namespace Kernel { case MULTIBOOT2_MAGIC: return parse_boot_info_multiboot2(info); + case BANAN_BOOTLOADER_MAGIC: + return parse_boot_info_banan_bootloader(info); } ASSERT_NOT_REACHED(); } @@ -87,6 +115,8 @@ namespace Kernel { case MULTIBOOT2_MAGIC: return get_early_boot_command_line_multiboot2(info); + case BANAN_BOOTLOADER_MAGIC: + return get_early_boot_command_line_banan_bootloader(info); } ASSERT_NOT_REACHED(); }