From 780c69c17e3668400bfdaaa84925de681e0d1ba7 Mon Sep 17 00:00:00 2001 From: Amelia Coutard Date: Tue, 28 Feb 2023 23:24:56 +0100 Subject: [PATCH] Added a doc.txt file to specify the kernel documentation, and added a corresponding assert in the code Currently, the documentation specifies how virtual memory is used. The added assert ensures that any loaded elf program's segments are within the specified bounds. --- doc.txt | 10 ++++++++++ kernel/src/kernel.cpp | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 doc.txt diff --git a/doc.txt b/doc.txt new file mode 100644 index 0000000..6e9714c --- /dev/null +++ b/doc.txt @@ -0,0 +1,10 @@ +(Virtual) memory map: + +0000'0000'0000'0000 ↔ 0000'0000'0000'1000 - unmapped: 4KiB ensure that nullptr causes a page fault if accessed. +0000'0000'0000'1000 ↔ 0000'0010'0000'0000 - program segments (.text, .data, .bss, etc.): 64GiB - 4KiB +0000'0010'0000'1000 ↔ 0000'7FFF'FFFF'0000 - heap: 128TiB - 64GiB - 64KiB +0000'7FFF'FFFF'0000 ↔ 0000'8000'0000'0000 - stack: 64KiB +-- Invalid addresses -- +FFFF'8000'0000'0000 ↔ FFFF'C000'0000'0000 - physical memory: 64TiB +FFFF'C000'0000'0000 ↔ FFFF'FFFF'8000'0000 - unmapped: 64TiB - 2GiB +FFFF'FFFF'8000'0000 ↔10000'0000'0000'0000 - kernel: 2GiB diff --git a/kernel/src/kernel.cpp b/kernel/src/kernel.cpp index e5c5b8b..478783d 100644 --- a/kernel/src/kernel.cpp +++ b/kernel/src/kernel.cpp @@ -201,6 +201,9 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr