Skip to content

Internals: Memory map

Jens Nyberg edited this page Oct 2, 2013 · 5 revisions

Memory map

Fudge is very specific in how it handles memory. Because there is no memory allocation there has to be a precise map of what memory is used and for what purpose. In the current statte Fudge should run with just 16MB of memory but this might change in the future. With this layout Fudge can handle 64 running tasks.

x86

Overview

Base Limit Size Name
0×00000000 0×00100000 0×00100000 BIOS Reserved
0×00100000 0×00280000 0×00180000 Kernel code + Ramdisk
0×00280000 0×00300000 0×00080000 Kernel stack
0×00300000 0×00340000 0×00040000 Page directories
0×00340000 0×00380000 0×00040000 Page tables for kernel code
0×00380000 0×003C0000 0×00040000 Page tables for task code
0×003C0000 0×00400000 0×00040000 Page tables for task stack
0×00400000 0×00800000 0×00400000 Reserved for future use
0×00800000 0×00C00000 0×00400000 Task code
0×00C00000 0×01000000 0×00400000 Task stack

BIOS reserved

This memory is reserved by BIOS and should not be touched. There are some gaps you could use but I prefer just to leave it alone.

Kernel code + Ramdisk

This is where the Multiboot bootloader will place Fudge and the ramdisk during boot. I have reserved about 1.5MB of memory to hold them both.

Kernel stack

The reason why the kernel stack is pretty large is because this might need to change later when I add support for multiple CPUs which would require a seperate stack per CPU. For a 64 CPU system the stack would be 8192 bytes per CPU which should be enough.

Page directories

Holds page directories for paging. A page is 4096 bytes so this area can hold a total of 64 directories.

Page tables for kernel code

The kernel can reserve up to 64 locations in memory of 4MB each. These are mostly used by drivers to reserve memory mapped areas. These pages are mapped as read only for all tasks.

Page tables for task code

Each task gets one page table for its code but only 10 pages meaning a task code+data sections can not be larger than 64K.

Page tables for task stack

The same limitations as the previous. Only 64k of stack per task.

Reserved for future use

Multicode, SMP stuff in the future probably need this area.

Task code

The area where a programs code and data sections are copied before running. A program can not exceed 64k of memory.

Task stack

The task stack can be at most 64k.