Kernel: VESA driver has now second buffer for fast scrolling
This allows us to not read from video memory, since it was very slow I also implemented fast path for graphics clearing and scrolling if bpp is 32
This commit is contained in:
@@ -33,7 +33,7 @@ struct ParsedCommandLine
|
||||
ParsedCommandLine ParseCommandLine(const char* command_line)
|
||||
{
|
||||
auto args = MUST(StringView(command_line).Split([](char c) { return c == ' ' || c == '\t'; }));
|
||||
|
||||
|
||||
ParsedCommandLine result;
|
||||
result.force_pic = args.Has("noapic");
|
||||
return result;
|
||||
@@ -52,7 +52,7 @@ extern "C" void kernel_main(multiboot_info_t* mbi, uint32_t magic)
|
||||
|
||||
s_multiboot_info = mbi;
|
||||
|
||||
if (!VESA::Initialize())
|
||||
if (!VESA::PreInitialize())
|
||||
{
|
||||
dprintln("Could not initialize VESA");
|
||||
return;
|
||||
@@ -61,6 +61,7 @@ extern "C" void kernel_main(multiboot_info_t* mbi, uint32_t magic)
|
||||
|
||||
kmalloc_initialize();
|
||||
|
||||
VESA::Initialize();
|
||||
|
||||
ParsedCommandLine cmdline;
|
||||
if (mbi->flags & 0x02)
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
#define MB (1 << 20)
|
||||
|
||||
|
||||
/*
|
||||
#### KMALLOC ################
|
||||
*/
|
||||
struct kmalloc_node
|
||||
{
|
||||
uint8_t* addr = nullptr;
|
||||
@@ -25,6 +29,17 @@ static uint8_t* const s_kmalloc_end = s_kmalloc_base + s_kmalloc_size;
|
||||
|
||||
static size_t s_kmalloc_available = 0;
|
||||
static size_t s_kmalloc_allocated = 0;
|
||||
/*
|
||||
#### KMALLOC ETERNAL ########
|
||||
*/
|
||||
static uint8_t* s_kmalloc_eternal_ptr = nullptr;
|
||||
|
||||
static uint8_t* const s_kmalloc_eternal_base = s_kmalloc_end;
|
||||
static constexpr size_t s_kmalloc_eternal_size = 2 * MB;
|
||||
static uint8_t* const s_kmalloc_eternal_end = s_kmalloc_eternal_base + s_kmalloc_eternal_size;
|
||||
/*
|
||||
#############################
|
||||
*/
|
||||
|
||||
void kmalloc_initialize()
|
||||
{
|
||||
@@ -39,7 +54,7 @@ void kmalloc_initialize()
|
||||
|
||||
if (mmmt->type == 1)
|
||||
{
|
||||
if (mmmt->base_addr <= (uint64_t)s_kmalloc_base && (uint64_t)s_kmalloc_end <= mmmt->base_addr + mmmt->length)
|
||||
if (mmmt->base_addr <= (uint64_t)s_kmalloc_base && (uint64_t)s_kmalloc_eternal_end <= mmmt->base_addr + mmmt->length)
|
||||
{
|
||||
dprintln("Total usable RAM: {} MB", (float)mmmt->length / MB);
|
||||
valid = true;
|
||||
@@ -51,7 +66,7 @@ void kmalloc_initialize()
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
Kernel::panic("Kmalloc: Could not find 1 MB of memory");
|
||||
Kernel::panic("Kmalloc: Could not find {} MB of memory", (double)(s_kmalloc_eternal_end - s_kmalloc_base));
|
||||
|
||||
s_kmalloc_node_count = 1;
|
||||
s_kmalloc_node_head = (kmalloc_node*)s_kmalloc_node_base;
|
||||
@@ -63,6 +78,8 @@ void kmalloc_initialize()
|
||||
head.addr = s_kmalloc_base;
|
||||
head.size = s_kmalloc_size;
|
||||
head.free = true;
|
||||
|
||||
s_kmalloc_eternal_ptr = s_kmalloc_eternal_base;
|
||||
}
|
||||
|
||||
void kmalloc_dump_nodes()
|
||||
@@ -77,6 +94,19 @@ void kmalloc_dump_nodes()
|
||||
}
|
||||
}
|
||||
|
||||
void* kmalloc_eternal(size_t size)
|
||||
{
|
||||
if (s_kmalloc_eternal_ptr + size > s_kmalloc_eternal_end)
|
||||
{
|
||||
dprintln("\e[33mKmalloc eternal: Could not allocate {} bytes\e[0m", size);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* result = (void*)s_kmalloc_eternal_ptr;
|
||||
s_kmalloc_eternal_ptr += size;
|
||||
return result;
|
||||
}
|
||||
|
||||
void* kmalloc(size_t size)
|
||||
{
|
||||
// Search for node with free memory and big enough size
|
||||
|
||||
Reference in New Issue
Block a user