summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/start.h1
-rw-r--r--asm/start.s4
-rw-r--r--kernel/vmem.c2
-rw-r--r--kernel/vmem.h49
-rw-r--r--linker.ld24
5 files changed, 70 insertions, 10 deletions
diff --git a/asm/start.h b/asm/start.h
index 7b31b76..4b2db16 100644
--- a/asm/start.h
+++ b/asm/start.h
@@ -4,6 +4,7 @@
* specific addresses in the final ELF kernel binary.
* This is specified in the _linker.ld_ file.
*
+ * TODO: THIS IS NOT TRUE ANYMORE (SINCE IT KILLED THE MEMORY IN BETWEEN PROABBLY)
* * 0x007000 .smp - entry point for application processors (16bit code)
* * 0x100000 .multiboot - the multiboot header
*
diff --git a/asm/start.s b/asm/start.s
index 26464a7..ca99c20 100644
--- a/asm/start.s
+++ b/asm/start.s
@@ -15,12 +15,14 @@
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
-# entry point for application processors at 0x7000
+# entry point for application processors we will copy this to 0x7000 later
+
.section .smp
.code16
_start_smp:
call smp_start # TODO: align later before going C
+
# Declare a header as in the Multiboot Standard. We put this into a special
# section so we can force the header to be in the start of the final program.
# You don't need to understand all these details as it is just magic values that
diff --git a/kernel/vmem.c b/kernel/vmem.c
index 2d3a5e4..542b3a2 100644
--- a/kernel/vmem.c
+++ b/kernel/vmem.c
@@ -1,5 +1,3 @@
-// http://www.brokenthorn.com/Resources/OSDev18.html
-//
#include <stdlib.h>
#include "kernel.h"
diff --git a/kernel/vmem.h b/kernel/vmem.h
index b7e9cd3..8e538bb 100644
--- a/kernel/vmem.h
+++ b/kernel/vmem.h
@@ -1,3 +1,52 @@
+/**
+ * @file
+ * http://www.brokenthorn.com/Resources/OSDev18.html
+ * https://wiki.osdev.org/Memory_Map_(x86)
+ *
+ * Paging
+ * ======
+ *
+ * The Smallest Managable Unit is a Page containing 4096 (0x1000) bytes.
+ *
+ * A Page Directory holds 1024 tables each mapping 1024 pages, totaling
+ * in 0x100000000 bytes of addressable space (4gigs).
+ *
+ * The first 32megs will get ALWAYS identity mapped (hold kernel code/kernel stack etc)
+ * This are the first 8 page-tables
+ *
+ * Layout
+ * ======
+ *
+ * We are aiming for the following layout:
+ *
+ * 0xFFFFFFFF
+ * 0xC0000000 RESERVED
+ *
+ * 0xB0000000 User Stack TOP (Grows down) |
+ * env, argc, argv ... |
+ * | alltogether ~2.5gigs
+ * .......... User Heap (brk()) |
+ * 0x08000000 User Code |
+ * |
+ * | almost 100 megs (in kernel alloc/free?)
+ * |
+ * 0x02000000 FoolOS TSS Stack TOP (max ~8mb) GROWS DOWN
+ * leave few empty pages under stack as guard.
+ *
+ * 0x01800000 FoolOS Stack TOP (max ~8mb) GROWS DOWN
+ * leave few empty pages under stack as guard.
+ *
+ * 0x01000000
+ * 0x00EFFFFF RESERVED
+ * 0x00100000 FoolOS Kernel (max ~14mb)
+ * 0x00007BFF RESERVED
+ * 0x00007000 16-bit SMP entry (max ~3kb)
+ * 0x00000500
+ * 0x00000000 RESERVED
+ *
+ */
+
+
//! i86 architecture defines 1024 entries per table--do not change
#define PAGES_PER_TABLE 1024
#define PAGES_PER_DIR 1024
diff --git a/linker.ld b/linker.ld
index 4d61b48..7f10731 100644
--- a/linker.ld
+++ b/linker.ld
@@ -3,19 +3,29 @@ ENTRY(_start)
SECTIONS
{
/* 0x00000500 - 0x00007BFF : guaranteed free to use */
- . = 0x7000;
- kernel_start = .;
/* smp code at 0x7000*/
- .text BLOCK(4K) : ALIGN(4K)
+ . = 0x00007000;
+ kernel_start = .;
+
+ .multiboot BLOCK(4K) : ALIGN(4K)
{
- *(.smp)
+ asm/start.o(.smp)
+ asm/asm_mp.o
+ *(.multiboot)
}
+
+
+ /*
+ 0x00007E00 0x0007FFFF 480.5 KiB RAM (guaranteed free for use) Conventional memory
+ 0x00080000 0x0009FBFF approximately 120 KiB, depending on EBDA size RAM (free for use, if it exists) Conventional memory
+ */
+ /* 0x00100000 - 0x00EFFFFF : free for use (if it exists) 14Mib */
+
+ . = 0x00100000;
- /* 0x00100000 - 0x00EFFFFF : free for use (if it exists) */
- . = 0x100000;
/* _start code as 0x100000 and rest of code*/
- .text BLOCK(4K) : ALIGN(4K)
+ .text BLOCK(4K): ALIGN(4K)
{
*(.multiboot)
*(.text)