feature: memory limit with multiboot (wip, still crashing)
This commit is contained in:
55
src/kernel.c
55
src/kernel.c
@ -5,6 +5,7 @@
|
||||
#include "idt.h"
|
||||
#include "kprintf.h"
|
||||
#include "memory.h"
|
||||
#include "multiboot.h"
|
||||
#include "power.h"
|
||||
#include "shell.h"
|
||||
#include "string.h"
|
||||
@ -25,40 +26,48 @@
|
||||
#error "This tutorial needs to be compiled with a ix86-elf compiler"
|
||||
#endif
|
||||
|
||||
void kernel_main(void)
|
||||
/* Par contre je me dois d'être honnête avec toi, j'ai passé un très bon moment
|
||||
* hier soir c'était vraiment posé et tout mais j'ai pas trop ressenti de
|
||||
* feeling qui me donnerait envie de continuer dans une relation "couple" sur le
|
||||
* long terme. Je sais pas trop comment le dire sans que ça te blesse, c'est pas
|
||||
* personnel ou quoi c'est cool quand on parle et tout mais juste je ne pense
|
||||
* pas pouvoir faire marcher une relation comme celle là :( */ /* Voilà je voulais juste te le dire pour pas que tu te mettes quelque chose en
|
||||
* tête qui n'arrivera pas, je trouve ça plus correct */
|
||||
|
||||
static void set_mem_size(multiboot_info_t *mbd, uint32_t magic)
|
||||
{
|
||||
/* Make sure the magic number matches for memory mapping */
|
||||
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
|
||||
kpanic("invalid magic number!");
|
||||
|
||||
/* Check bit 6 to see if we have a valid memory map */
|
||||
if (!(mbd->flags >> 6 & 0x1))
|
||||
kpanic("invalid memory map given by GRUB bootloader");
|
||||
|
||||
/* Loop through the memory map and display the values */
|
||||
for (uint32_t i = 0; i < mbd->mmap_length;
|
||||
i += sizeof(multiboot_memory_map_t)) {
|
||||
multiboot_memory_map_t *mmmt =
|
||||
(multiboot_memory_map_t *)(mbd->mmap_addr + i);
|
||||
if (mmmt->type == MULTIBOOT_MEMORY_AVAILABLE)
|
||||
mem_size += mmmt->len;
|
||||
}
|
||||
}
|
||||
|
||||
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
{
|
||||
terminal_initialize();
|
||||
init_gdt();
|
||||
init_idt();
|
||||
init_memory();
|
||||
load_drivers();
|
||||
set_mem_size(mbd, magic);
|
||||
kprintf(KERN_ALERT
|
||||
"I see no way to confuse an array of 256 seg:off pairs with a "
|
||||
"complex 8*unknown quantity -byte descriptor table. -- Troy "
|
||||
"Martin 03:50, 22 March 2009 (UTC)\n");
|
||||
for (uint16_t i = 0;; i++) {
|
||||
void *ptr = alloc_pages(4096);
|
||||
PRINT_PTR(ptr);
|
||||
memset(ptr, ~0, 4096);
|
||||
free_pages(ptr, 4096);
|
||||
}
|
||||
/* int i = 0; */
|
||||
/* vmalloc(10); */
|
||||
/* while (vmalloc(10)) */
|
||||
/* ; */
|
||||
/* if (i++ > 70000) */
|
||||
/* kprintf("%d\n", i); */
|
||||
/* void *tab[1024]; */
|
||||
/* for (int i = 0; i < 1023; i++) { */
|
||||
/* tab[i] = alloc_pages(1, NULL); */
|
||||
/* PRINT_INT(i); */
|
||||
/* PRINT_PTR(tab[i]); */
|
||||
/* if (!tab[i]) */
|
||||
/* break; */
|
||||
/* memset(tab[i], i, 4096); */
|
||||
/* } */
|
||||
/* PRINT_UINT(((uint8_t *)tab[0])[0]); */
|
||||
/* for (int i = 0; i < 10; i++) */
|
||||
/* PRINT_UINT(((uint8_t *)tab[i])[0]); */
|
||||
/* PRINT_PTR(tab[i]); */
|
||||
shell_init();
|
||||
}
|
||||
|
Reference in New Issue
Block a user