MushOS  0.1
A UNIX-like OS prototype, written from scratch
Loading...
Searching...
No Matches
kernel.c
Go to the documentation of this file.
1/**
2 * @file
3 *
4 * @brief Kernel entry point
5 */
6
7#include "kernel.h"
8
9#include "../../lib/base/generic.h"
10#include "../../lib/base/heap.h"
11#include "../../lib/base/stdio.h"
12#include "../../lib/base/exceptions.h"
13#include "../../lib/base/string.h"
14
15#include "../drivers/screen.h"
16#include "../drivers/keyboard.h"
17
18#include "interruption_tables.h"
19#include "timer.h"
20#include "pages.h"
21#include "task.h"
22#include "modules.h"
23
24extern void initialize_kernel_heap_handler();
25
26
27#define kernel_heap_start 0x50000
28#define kernel_heap_size 0x80000
29
30#define kernel_timer_step 100
31
32void* stack_pointer = (void*) 0x7000;
33u_dword stack_size = 0x5000;
34
35/**
36 * Make kernel constants:
37 *
38 *
39 * Divide boot loader into: loader, functions, GDT.
40 *
41 * First man: https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf
42 * Second man: https://web.archive.org/web/20160324232118/http://jamesmolloy.co.uk/tutorial_html/
43 * Third man: https://github.com/cfenollosa/os-tutorial
44 *
45 * Documentation! For each stage!
46 * 1. Kernel constants (root CS and root DS (passed from loader), booting device, kernel size, max RAM)
47 * -> define RAM positions everywhere (loader, interruptions).
48 * 2. Memory map -> positioning of kernel / stack + kernel loading size (written in boot sector, defined after compilation).
49 * 3. Shell + audio drivers.
50 * 4. File system + initrd.
51 * 6. Multitasking.
52 * 7. User mode.
53 * 8. Video mode.
54 * 9. Sample apps.
55 * 10. Und so weiter...
56 * Extra! Add testing in Travis CI with special QEMU target in console mode.
57 */
58
59void _start() {
60 initialize_heap((void*) kernel_heap_start, kernel_heap_size);
61 initialize_kernel_heap_handler();
62
63 init_interruptions();
64 init_timer(kernel_timer_step);
65 init_screen_io();
66
67 init_debug_handler();
68 good("Kernel started, build: %s - %s\n", __DATE__, __TIME__)
69
70 init_keyboard();
71 init_module_loading_driver();
72
73 initialise_paging();
74
75 initialise_tasking();
76
77 // Create a new process in a new address space which is a clone of this.
78 int ret = fork();
79
80 info("fork() returned %d, and getpid() returned %d\n", ret, getpid())
81}
void _start()
Definition: kernel.c:59
void initialize_heap(void *start_address, u_dword initial_size)