apsun / loliOS

Lightweight & operational Linux-inspired OS.
33 stars 1 forks source link

Support 4KB granularity pages #20

Open apsun opened 5 years ago

apsun commented 5 years ago

Because I was lazy, pages obtained via sbrk are given out in increments of 4MB so that we didn't have to maintain page tables. However this is fairly inefficient (and I foresee issues with ELF r/w/x support since the linker script seems to assume a page size of 4KB) so we should do this properly.

apsun commented 3 years ago

It will probably be necessary to implement a buddy allocator/some other hierarchical page tracking data structure as opposed to the flat bitmap we use today, so we don't have to scan a 64KB bitmap (256MB physical memory / 4KB pages) to find free pages.

Although, on the other hand, the bitmap is only 64KB, so....

apsun commented 3 years ago

Another issue we will have to deal with: avoiding reserved (i.e. DMA) memory regions. According to the multiboot info:

0-639KB is free 639KB-640KB is reserved 640KB-1MB is reserved 1MB-256MB is free

We should mark all of the reserved memory regions as allocated on startup. Today we do this for the entire first 4MB because a bunch of stuff is there, but when we start allocating 4KB pages we should do it on a more granular fashion.