Compare commits
3 Commits
d018c72200
...
e5cf785097
| Author | SHA1 | Date |
|---|---|---|
|
|
e5cf785097 | |
|
|
95ac2d439a | |
|
|
499e25d23d |
|
|
@ -3,7 +3,7 @@ ENTRY(stivale2_main)
|
|||
SECTIONS
|
||||
{
|
||||
kernel_phys_offset = 0xffffffff80000000;
|
||||
. = kernel_phys_offset + 0x100000;
|
||||
. = kernel_phys_offset + 1M;
|
||||
|
||||
.stivale2hdr ALIGN(4K) :
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
/* An Arena allocator is a very basic allocator that simply discards free() calls. */
|
||||
|
||||
#include "arena.h"
|
||||
#include <hal/ops.h>
|
||||
|
||||
void* arena_alloc(struct arena_allocator* alloc, size_t len, size_t align) {
|
||||
if(alloc->begin % align) {
|
||||
alloc->begin += (align - alloc->begin % align);
|
||||
}
|
||||
if(alloc->length < len) {
|
||||
PANIC("Attempt to allocate more memory than is available");
|
||||
}
|
||||
void* retval = (void*)alloc->begin;
|
||||
alloc->begin += len;
|
||||
alloc->length -= len;
|
||||
return retval;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#include <stddef.h>
|
||||
|
||||
struct arena_allocator {
|
||||
size_t begin;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
void *arena_alloc(struct arena_allocator* alloc, size_t length, size_t align);
|
||||
|
|
@ -2,8 +2,10 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../main.h"
|
||||
#include "arch/x86/stivale2-parse.h"
|
||||
#include <arch/x86/stivale2-parse.h>
|
||||
#include <print/print.h>
|
||||
|
||||
#include <main.h>
|
||||
|
||||
static uint8_t stack[4096] = {0};
|
||||
void stivale2_main(struct stivale2_struct *info);
|
||||
|
|
@ -28,6 +30,15 @@ void stivale2_main(struct stivale2_struct *info) {
|
|||
parse_stivale2(info);
|
||||
print_stivale2_memmap(info);
|
||||
|
||||
uint64_t* cr3;
|
||||
__asm__ __volatile__ (
|
||||
"movq %%cr3, %0\n\t"
|
||||
: "=r" (cr3)
|
||||
: /* no input */
|
||||
: /* no clobbers */
|
||||
);
|
||||
printf("PAGE TABLE AT: %x\n", cr3);
|
||||
|
||||
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
|
||||
kmain(3, argv);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue