annotate cos/kernel/kernel.h @ 29:7e3bdcb391dc

Added get_page function to mm
author windel
date Thu, 29 Dec 2011 19:34:01 +0100
parents 47b7df514243
children 0148f55bfe24
rev   line source
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
1 #ifndef KERNEL_H
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
2 #define KERNEL_H
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
3
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
4 // Include common functions, available to all!
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
5 #define NULL ((void*)0)
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
6
29
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
7 /* Types */
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
8
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
9 // Type defs:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
10 typedef unsigned char uint8_t;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
11 typedef unsigned short uint16_t;
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
12 typedef unsigned int uint32_t;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
13 typedef unsigned long int uint64_t;
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
14
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
15 // IDT related structures:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
16 typedef struct {
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
17 uint16_t baseLow;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
18 uint16_t selector;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
19 uint8_t reserved1;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
20 uint8_t flags;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
21 uint16_t baseMid;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
22 uint32_t baseHigh;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
23 uint32_t reserved2;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
24 } __attribute__((packed)) IDT_entry;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
25
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
26 typedef struct {
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
27 uint16_t limit;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
28 uint64_t base;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
29 } __attribute__((packed)) idtPointer;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
30
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 17
diff changeset
31 // Multiboot structs:
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
32 struct multiboot_aout_symbol_table {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
33 uint32_t tabsize;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
34 uint32_t strsize, addr, reserved;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
35 };
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
36
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
37 struct multiboot_info {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
38 uint32_t flags; // Multiboot flags / version
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
39 uint32_t mem_lower; // available memory from BIOS
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
40 uint32_t mem_upper;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
41 uint32_t boot_device;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
42 uint32_t cmdline; // COmmand line
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
43 uint32_t mods_count;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
44 uint32_t mods_addr;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
45 union {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
46 struct multiboot_aout_symbol_table aout_sym;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
47 } u;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
48
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
49 uint32_t mmap_length;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
50 uint32_t mmap_addr;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
51 };
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
52
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
53 struct memory_map {
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
54 uint32_t size;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
55 uint32_t baselow, basehigh;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
56 uint32_t lenlow, lenhigh;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
57 uint32_t type;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
58 };
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
59
29
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
60 // Memory manager structures:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
61 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
62 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
63 uint64_t present : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
64 uint64_t rw : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
65 uint64_t us : 1; // user or supervisor
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
66 uint64_t pwt : 1; // page level write-through
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
67 uint64_t pcd : 1; // page cache disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
68 uint64_t accessed : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
69 uint64_t ignored : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
70 uint64_t ps : 1; // must be 0.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
71 uint64_t ignored2 : 4;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
72 // 12 bits so far
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
73 uint64_t address : 48; // address of page directory pointer table.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
74 uint64_t ignored3 : 11;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
75 uint64_t xd : 1; // execute disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
76 } PML4E_t; // 64 bits wide, PML4 table must be 4096 byte aligned.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
77
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
78 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
79 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
80 // Must be 12 bits aligned!
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
81 PML4E_t table[512];
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
82 uint64_t physicalAddress; // Physical address of the table above
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
83 } PML4_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
84
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
85 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
86 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
87 uint64_t present : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
88 uint64_t rw : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
89 uint64_t us : 1; // user or supervisor
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
90 uint64_t pwt : 1; // page level write-through
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
91 uint64_t pcd : 1; // page cache disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
92 uint64_t accessed : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
93 uint64_t ignored : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
94 uint64_t ps : 1; // page size, must be 0, otherwise maps a 1 GB page.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
95 uint64_t ignored2 : 4;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
96 // 12 bits so far
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
97 uint64_t address : 48; // address of page directory table.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
98 uint64_t ignored3 : 11;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
99 uint64_t xd : 1; // execute disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
100 } PDPTE_t; // Page directory pointer table entry, 64 bits wide. 4-kB aligned.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
101
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
102 // Page directory pointer table:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
103 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
104 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
105 PDPTE_t table[512];
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
106 uint64_t physicalAddress;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
107 } PDPT_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
108
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
109 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
110 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
111 uint64_t present : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
112 uint64_t rw : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
113 uint64_t us : 1; // user or supervisor
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
114 uint64_t pwt : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
115 uint64_t pcd : 1; // page cache disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
116 uint64_t accessed : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
117 uint64_t ignored : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
118 uint64_t ps : 1; // page size, must be 0, otherwise maps a 2-MB page.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
119 uint64_t ignored2 : 4;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
120 // 12 bits so far
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
121 uint64_t address : 48; // address of page table.
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
122 uint64_t ignored3 : 11;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
123 uint64_t xd : 1; // execute disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
124 } PDE_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
125
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
126 // Page directory:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
127 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
128 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
129 PDE_t table[512];
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
130 uint64_t physicalAddress;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
131 } PD_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
132
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
133 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
134 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
135 uint64_t present : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
136 uint64_t rw : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
137 uint64_t us : 1; // user or supervisor
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
138 uint64_t pwt : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
139 uint64_t pcd : 1; // page cache disable
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
140 uint64_t accessed : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
141 uint64_t dirty : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
142 uint64_t pat : 1; // memory type?
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
143 uint64_t g : 1; // Global?
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
144 uint64_t ignored : 3;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
145
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
146 uint64_t address : 48;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
147 uint64_t ignored2 : 11;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
148 uint64_t xd : 1;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
149 } page_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
150
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
151 // Page table:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
152 typedef struct
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
153 {
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
154 page_t table[512];
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
155 uint64_t physicalAddress;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
156 } PT_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
157
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
158 // Make memmap a PML4 type:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
159 typedef PML4_t memmap_t;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
160
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
161 // Task related types:
24
d8627924d40d Split up in more files and reboot command
windel
parents: 20
diff changeset
162 typedef struct
d8627924d40d Split up in more files and reboot command
windel
parents: 20
diff changeset
163 {
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
164 char name[32]; // Name of the console
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
165 unsigned char screendata[80*25]; // All chars in the console!
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
166 } console_t;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
167
25
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
168 typedef struct task_t {
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
169 struct task_t* next;
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
170 uint32_t kstack;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
171 uint32_t ustack;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
172
29
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
173 // For task switching:
25
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
174 uint64_t cr3;
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
175 uint64_t rip;
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
176 uint64_t rsp;
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
177 uint64_t rbp;
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
178
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
179 uint32_t pid;
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
180 uint32_t parent;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
181 uint32_t owner;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
182 uint32_t groups;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
183 uint32_t timetorun;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
184 uint32_t sleep;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
185 uint32_t priority;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
186 uint32_t filehandle;
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
187 char naam[32];
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
188
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
189 console_t *console;
25
d3c4bf3720a3 Beginning of multitasking
windel
parents: 24
diff changeset
190 } task_t;
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
191
29
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
192 // Variable argument list things:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
193 #define va_start(v,l) __builtin_va_start(v,l)
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
194 #define va_end(v) __builtin_va_end(v)
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
195 #define va_arg(v,l) __builtin_va_arg(v,l)
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
196 typedef __builtin_va_list va_list;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
197
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
198 /* Global variables */
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
199 extern uint64_t kernel_end;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
200 extern uint64_t placement_address;
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
201
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
202 /* Procedures */
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
203
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
204 // memory functions:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
205 // TODO: remove some redundant API functions:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
206 void init_heap();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
207 void init_memory(uint64_t total_mem_size);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
208 page_t* get_page(uint64_t address, memmap_t*);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
209 void* kmalloc(uint64_t size);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
210 void kfree(void* ptr);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
211 void* kmalloc_int(uint64_t size);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
212 void* kmalloc_aligned_int(uint64_t size);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
213 void mappage(uint64_t address);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
214 void loadPageTable(void* tableAddress);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
215 void switch_mapping(memmap_t* mapping);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
216 void enablePaging();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
217
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
218 // task related functions:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
219 void initialize_tasking();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
220 void new_task();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
221 void task_scheduler();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
222
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
223 // STDout funcs:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
224 void printf(const char* fmt, ... );
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
225 void memset(void* ptr, uint8_t value, uint64_t num);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
226 void memcpy(void* dst, void* src, uint64_t num);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
227 int strncmp(const char* s1, const char* s2, int size);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
228
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
229 // Screen related:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
230 void clear_screen();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
231 void init_screen();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
232 void print_string(const char *);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
233 void set_cursor(int newrow, int newcol);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
234 void get_cursor(int *therow, int *thecol);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
235 void set_color(int forecolor, int backcolor);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
236
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
237 // For IO ports:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
238 uint8_t inb(uint16_t);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
239 uint16_t inw(uint16_t);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
240 void outb(uint16_t, uint8_t);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
241
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
242 // Interrupt functions:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
243 void setupIDT(void);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
244 void PICremap(void);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
245 void loadIDT(void);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
246
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
247 // ASM helper:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
248 uint64_t read_rip();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
249
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
250 // Helpers:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
251 void halt(void);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
252 void panic(char *msg);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
253 void reboot(void);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
254 void magicBochsBreak();
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
255 void doCPUID(int eax, int *ebx, int *ecx, int *edx);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
256
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
257 // Keyboard driver:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
258 void keyboardDriverUpdate(unsigned char scancode);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
259 void getline(char *buffer, int len);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
260
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
261 // Timer:
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
262 void timerDriverUpdate(void);
7e3bdcb391dc Added get_page function to mm
windel
parents: 28
diff changeset
263 uint64_t getTimeMS();
28
47b7df514243 Moved Makefiles
windel
parents: 26
diff changeset
264
9
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
265 #endif
92ace1ca50a8 64 bits kernel without interrupts but with printf in C
windel
parents:
diff changeset
266