generated from limine-bootloader/limine-c-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#ifndef __KERNEL_H__ | ||
#error "This file should be included from Kernel.h" | ||
#endif | ||
|
||
VOID | ||
CommonStartupRoutine( | ||
PAGE_ALLOCATOR *BumpAllocator | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <RuntimeLib.h> | ||
#include <Kernel.h> | ||
|
||
PAGE_ALLOCATOR* g_PageAllocator; | ||
|
||
VOID | ||
CommonStartupRoutine( | ||
PAGE_ALLOCATOR *BumpAllocator | ||
) | ||
{ | ||
// TODO: g_PageAllocator = BuddyAllocatorInit (BumpAllocator); | ||
g_PageAllocator = BumpAllocator; | ||
|
||
KernelMain (); | ||
} | ||
|
||
// TODO: General purpose memory allocation functions using slab allocator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
#include <RuntimeLib.h> | ||
#include <Kernel.h> | ||
|
||
#include "limine.h" | ||
|
||
BUMP_ALLOCATOR g_BumpAllocator; | ||
|
||
// | ||
// Set the base revision to 1, this is recommended as this is the latest | ||
// base revision described by the Limine boot protocol specification. | ||
// See specification for further info. | ||
// | ||
|
||
LIMINE_BASE_REVISION(1); | ||
|
||
// | ||
// Memory map | ||
// | ||
|
||
struct limine_memmap_request g_LimineMemmap = { | ||
.id = LIMINE_MEMMAP_REQUEST, | ||
.revision = 0 | ||
}; | ||
|
||
VOID | ||
StartupRoutine ( | ||
VOID | ||
) | ||
{ | ||
// TODO: pass the correct arguments | ||
// TODO: init architecture | ||
UINTN BumperIdx; | ||
|
||
GDTInit (); | ||
IDTInit (); | ||
|
||
KernelMain (); | ||
BumperIdx = 0; | ||
for (UINT64 i = 0; i < g_LimineMemmap.response->entry_count; i++) | ||
{ | ||
if (g_LimineMemmap.response->entries[i]->type == LIMINE_MEMMAP_USABLE) | ||
{ | ||
BUMPER *bumper = &g_BumpAllocator.bumpers[BumperIdx++]; | ||
bumper->heap_start = g_LimineMemmap.response->entries[i]->base; | ||
bumper->heap_end = g_LimineMemmap.response->entries[i]->base + g_LimineMemmap.response->entries[i]->length; | ||
bumper->next = bumper->heap_start; | ||
|
||
if (BumperIdx == MAXIMUM_BUMPERS) | ||
{ | ||
// Memory is too fragmented, we can't continue. This is fine but we'll use | ||
// some usable memory. | ||
|
||
// TODO: log warning | ||
break; | ||
} | ||
} | ||
} | ||
|
||
CommonStartupRoutine ((PAGE_ALLOCATOR *)&g_BumpAllocator); | ||
} |