summaryrefslogtreecommitdiff
path: root/kernel/vmem.h
blob: 73f9ce66b1aeb89b231d9e73f78c16bffc5e0d14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * @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:
 * TODO: update, this is not true anumore!
 * 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 private-cpu and shared)
 *                |
 * 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)
 * 0x00006fff smp entry stacks (growing down)
 * 0x00000500
 * 0x00000000 RESERVED
 *
 */

#include <stdint.h>
#include "multiboot.h"
#include "acpi.h"

struct pdirectory_struct;

void vmem_init(multiboot_information *cfg_multiboot, acpi_information *cfg_acpi,uint32_t e1000_addr);
void vmem_free_dir(struct pdirectory_struct *dir);
struct pdirectory_struct* vmem_new_space_dir(struct pdirectory_struct *copy_dir,bool stack_only);
void vmem_free_space_dir(struct pdirectory_struct *dir,bool stack_only);
void vmem_add_framebuffer(struct pdirectory_struct *dir);
struct pdirectory_struct* vmem_kernel_dir();