From 0529ecc2989e0e7988909a659f88e0723c1299b5 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 3 Dec 2021 09:08:06 +0100 Subject: [PATCH] Memory stuff --- kernel/kernel.c | 1 + kernel/memory.c | 14 ++++++++++++++ kernel/memory.h | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 kernel/memory.c create mode 100644 kernel/memory.h diff --git a/kernel/kernel.c b/kernel/kernel.c index d6219b9..b699ccc 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,4 +1,5 @@ #include "kernel.h" +#include "memory.h" #include "paging.h" #include "../drivers/vga.h" #include "../lib/str.h" diff --git a/kernel/memory.c b/kernel/memory.c new file mode 100644 index 0000000..bb577e4 --- /dev/null +++ b/kernel/memory.c @@ -0,0 +1,14 @@ +#include "memory.h" + +// https://wiki.osdev.org/Page_Frame_Allocation +// page = block + +// MAX_BLOCK_SIZE_IN_BITS/8 bytes +// i.e. : bit i of byte n define status of block 8n+i +// block = 8n+i + +int* alloc_cursor; // keep track of last location that was allocated (may improve speed) + +void init_pmm(unsigned int map_addr, unsigned int bsize) { + +} diff --git a/kernel/memory.h b/kernel/memory.h new file mode 100644 index 0000000..5d46f0b --- /dev/null +++ b/kernel/memory.h @@ -0,0 +1,5 @@ +#define BLOCK_SIZE 4 // 32 bits = 4 bytes +#define MEMSIZE_TO_BLOCKS(n) ((n*1024)/BLOCK_SIZE) + +void init_pmm(unsigned int map_addr, unsigned int bsize); // Initialize physical memory manager +