diff --git a/src/impl/kernel/boot.cpp b/src/impl/kernel/boot.cpp index f2fc0cb..ac7d7b8 100644 --- a/src/impl/kernel/boot.cpp +++ b/src/impl/kernel/boot.cpp @@ -15,8 +15,6 @@ boot_framebuffer* BootInfo::get_framebuffer() const { memory_map_entry** BootInfo::get_memory_maps() { - if (memory_entry == nullptr) kernel_panic("BootInfo not parsed!", BootInfoNotParsed); - return memory_entry; } @@ -82,11 +80,11 @@ void BootInfo::log() } } -void BootInfo::parse(boot_info* boot_info) +BootInfo::BootInfo(boot_info* boot_info) { const auto start = reinterpret_cast(boot_info); this->size = boot_info->size; - const pt::uintptr_t end = start + size; + const pt::uintptr_t end = start + this->size; pt::uintptr_t ptr = start + 8; while (ptr < end) @@ -101,30 +99,30 @@ void BootInfo::parse(boot_info* boot_info) { case BOOT_CMDLINE: { - cmd_line = reinterpret_cast(ptr); + this->cmd_line = reinterpret_cast(ptr); break; } case BOOT_LOADER_NAME: { - loader_name = reinterpret_cast(ptr); + this->loader_name = reinterpret_cast(ptr); break; } case BOOT_BASIC_MEM: { - basic_mem = reinterpret_cast(ptr); + this->basic_mem = reinterpret_cast(ptr); break; } case BOOT_BIOS: { - bios = reinterpret_cast(ptr); + this->bios = reinterpret_cast(ptr); break; } case BOOT_MMAP: { - mmap = reinterpret_cast(ptr); + this->mmap = reinterpret_cast(ptr); auto mem_current = reinterpret_cast(&mmap->entries); const pt::uintptr_t mem_end = mem_current + mmap->size - 4*sizeof(pt::uint32_t); - for (auto & map_entry : memory_entry) + for (auto & map_entry : this->memory_entry) { map_entry = nullptr; } @@ -133,7 +131,7 @@ void BootInfo::parse(boot_info* boot_info) { if (i >= MEMORY_ENTRIES_LIMIT) kernel_panic("Memory entries limit reached", MemEntriesLimitReached); auto* entry = reinterpret_cast(mem_current); - memory_entry[i] = entry; + this->memory_entry[i] = entry; i++; mem_current += mmap->entry_size; } diff --git a/src/impl/kernel/main.cpp b/src/impl/kernel/main.cpp index b220584..db4a679 100644 --- a/src/impl/kernel/main.cpp +++ b/src/impl/kernel/main.cpp @@ -12,7 +12,6 @@ extern const char Logo[]; extern const unsigned char PotatoLogo[]; extern char get_char(); -static BootInfo bi; static IDT idt; VMM vmm; @@ -63,7 +62,7 @@ constexpr char pci_cmd[] = "pci"; ASMCALL void kernel_main(boot_info* boot_info, void* l4_page_table) { klog("[MAIN] Welcome to 64-bit potat OS\n"); - bi.parse(boot_info); + auto bi = BootInfo(boot_info); const auto boot_fb = bi.get_framebuffer(); diff --git a/src/intf/boot.h b/src/intf/boot.h index bc2956d..995bc76 100644 --- a/src/intf/boot.h +++ b/src/intf/boot.h @@ -139,7 +139,6 @@ struct boot_vbe_info } __attribute__((packed)); #define MEMORY_ENTRIES_LIMIT 7 - class BootInfo { pt::size_t size; @@ -154,10 +153,11 @@ class BootInfo boot_apm_table* apm_table; boot_acpi* acpi; boot_loader_physical_address* physical; - memory_map_entry* memory_entry[MEMORY_ENTRIES_LIMIT]; + memory_map_entry* memory_entry[MEMORY_ENTRIES_LIMIT]{}; void log(); + BootInfo() = default; public: - void parse(boot_info *boot_info); + explicit BootInfo(boot_info *boot_info); [[nodiscard]] boot_framebuffer* get_framebuffer() const; memory_map_entry** get_memory_maps(); }; \ No newline at end of file diff --git a/src/intf/framebuffer.h b/src/intf/framebuffer.h index 9d9b0c2..c6afb3d 100644 --- a/src/intf/framebuffer.h +++ b/src/intf/framebuffer.h @@ -27,7 +27,7 @@ class Framebuffer pt::uint32_t x, pt::uint32_t y) const; public: Framebuffer()=default; - Framebuffer(const boot_framebuffer *fb) : Framebuffer( + explicit Framebuffer(const boot_framebuffer *fb) : Framebuffer( fb->framebuffer_addr, fb->framebuffer_width, fb->framebuffer_height,