Kernel: Multiboot data and kernel command lines are now global variables

This commit is contained in:
Bananymous
2023-01-10 17:50:24 +02:00
parent 1a65ea977d
commit c6467b8ebc
8 changed files with 117 additions and 24 deletions

View File

@@ -1,3 +1,4 @@
#include <BAN/Memory.h>
#include <kernel/kmalloc.h>
#include <kernel/Panic.h>
#include <kernel/Serial.h>

View File

@@ -4,6 +4,7 @@
#include <kernel/Input.h>
#include <kernel/kmalloc.h>
#include <kernel/kprint.h>
#include <kernel/MMU.h>
#include <kernel/multiboot.h>
#include <kernel/Paging.h>
#include <kernel/PIC.h>
@@ -17,8 +18,7 @@
#define DISABLE_INTERRUPTS() asm volatile("cli")
#define ENABLE_INTERRUPTS() asm volatile("sti")
multiboot_info_t* s_multiboot_info;
extern "C" const char g_kernel_cmdline[];
using namespace BAN;

View File

@@ -9,6 +9,8 @@
#define ALIGN (alignof(max_align_t))
extern "C" uintptr_t g_kernel_end;
/*
#### KMALLOC ################
*/
@@ -47,14 +49,17 @@ static bool s_initialized = false;
void kmalloc_initialize()
{
if (!(s_multiboot_info->flags & (1 << 6)))
if (!(g_multiboot_info->flags & (1 << 6)))
Kernel::Panic("Kmalloc: Bootloader didn't provide a memory map");
if (g_kernel_end > s_kmalloc_node_base)
Kernel::Panic("Kmalloc: Kernel end is over kmalloc base");
// Validate kmalloc memory
bool valid = false;
for (size_t i = 0; i < s_multiboot_info->mmap_length;)
for (size_t i = 0; i < g_multiboot_info->mmap_length;)
{
multiboot_memory_map_t* mmmt = (multiboot_memory_map_t*)(s_multiboot_info->mmap_addr + i);
multiboot_memory_map_t* mmmt = (multiboot_memory_map_t*)(g_multiboot_info->mmap_addr + i);
if (mmmt->type == 1)
{