while I tried to make a memory manager I wanted to use the mbs_mmap_* tags of the multiboot structure.
But there is something problematic in it.
While using the folowing code I got a mysterious output.
start.S
Code: Select all
.section multiboot
#define MB_MAGIC 0x1badb002
#define MB_FLAGS 0x0
#define MB_CHECKSUM -(MB_MAGIC + MB_FLAGS)
// Der Multiboot-Header
.align 4
.int MB_MAGIC
.int MB_FLAGS
.int MB_CHECKSUM
.section .text
.extern main
.global _start
_start:
mov $kernel_stack, %esp
call main
_stop:
cli
hlt
jmp _stop
.section .bss
.space 8192
kernel_stack:
Code: Select all
#include "descriptor_tables.h"
static void init(void);
int main(void)
{
init();
while(1);
return 0;
}
static void init(void)
{
asm volatile("push %ebx");
init_gdt();
init_idt();
asm volatile("pop %ebx");
clear();
asm volatile("int $0x30");
}
memory_manager.c
Code: Select all
#include "memory_manager.h"
#include "console.h"
struct map_entry
{
uint32_t size;
uint64_t base_addr;
uint64_t length;
uint32_t type;
}__attribute__((packed));
void init_memory(void *pointer)
{
uint32_t flags;
uint32_t length;
struct map_entry *map;
uint8_t i;
flags = *(uint32_t *)pointer;
if(flags | 0x40)
{
length = *(uint32_t *)(pointer + 0x2c);
map = *(struct map_entry **)(pointer + 0x30);
kprintf("%d\n\r", map->length);
do
{
kprintf("%d\n\r", map->size);
kprintf("0x%x-0x%x-%d\n\r", map->base_addr, map->length, map->type);
map++;
i++;
}
while(i<7);
}
while(1);
}
Code: Select all
654336
20
0x0-0x0-654336
20
0x9fc00-0x0-1024
20
0xf0000-0x0-65536
20
0x100000-0x0-133160960
20
0x7ffe000-0x0-8192
20
0xfffc0000-0x0-262144
0
0x0-0x0-0