mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2024-10-27 20:34:19 +00:00
.. | ||
kernel | ||
libc | ||
boot | ||
cpu | ||
drivers | ||
Makefile | ||
README.md |
Concepts you may want to Google beforehand: malloc
Goal: Implement a memory allocator
We will add a kernel memory allocator to libc/mem.c
. It is
implemented as a simple pointer to free memory, which keeps
growing.
The kmalloc()
function can be used to request an aligned page,
and it will also return the real, physical address, for later use.
We'll change the kernel.c
leaving all the "shell" code there,
Let's just try out the new kmalloc()
, and check out that
our first page starts at 0x10000 (as hardcoded on mem.c
) and
subsequent kmalloc()
's produce a new address which is
aligned 4096 bytes or 0x1000 from the previous one.
The rest of the files are unchanged from last lesson.