MonkOS  v0.1
A simple 64-bit operating system (x86_64)
main.c
Go to the documentation of this file.
1 //============================================================================
2 /// @file main.c
3 /// @brief The kernel's main entry point.
4 /// @details This file contains the function kmain(), which is the first
5 /// function called by the kernel's start code in start.asm.
6 //
7 // Copyright 2016 Brett Vickers.
8 // Use of this source code is governed by a BSD-style license that can
9 // be found in the MonkOS LICENSE file.
10 //============================================================================
11 
12 #include <kernel/device/keyboard.h>
13 #include <kernel/device/pci.h>
14 #include <kernel/device/timer.h>
15 #include <kernel/device/tty.h>
18 #include <kernel/mem/acpi.h>
19 #include <kernel/mem/kmem.h>
20 #include <kernel/mem/paging.h>
21 #include <kernel/mem/pmap.h>
22 #include <kernel/syscall/syscall.h>
23 #include "shell.h"
24 
25 #if defined(__linux__)
26 # error "This code must be compiled with a cross-compiler."
27 #endif
28 
29 #define TTY_CONSOLE 0
30 
31 void
33 {
34  // Memory initialization
35  acpi_init();
36  pmap_init();
37  page_init();
38 
39  // Interrupt initialization
42 
43  // Device initialization
44  tty_init();
45  kb_init();
46  timer_init(20); // 20Hz
47 
48  // System call initialization
49  syscall_init();
50 
51  // Let the games begin
53 
54  // Display a welcome message on the virtual console.
57  tty_print(TTY_CONSOLE, "Welcome to \033[e]MonkOS\033[-] (v0.1).\n");
58 
59  // Launch the interactive test shell.
60  kshell();
61 }
Physical memory map describing usable and reserved regions of physical memory.
Simple kernel shell for testing purposes.
Advanced configuration and power interface (ACPI) tables.
void tty_set_textcolor(int id, textcolor_t fg, textcolor_t bg)
Set the foreground and background colors used to display text on the virtual console.
Definition: tty.c:122
void syscall_init()
Set up the CPU to handle system calls.
Definition: syscall.c:29
Keyboard input routines.
void page_init()
Initialize the page frame database.
Definition: paging.c:107
__forceinline void enable_interrupts()
Definition: cpu_inl.h:134
Kernel physical (and virtual) memory map.
void interrupts_init()
Initialize all interrupt tables.
Programmable interval timer (8253/8254) controller.
void exceptions_init()
Initialize all exception handling routines.
Definition: exception.c:107
CPU exceptions.
void kb_init()
Initialize the keyboard so that it can provide input to the kernel.
Definition: keyboard.c:268
void tty_init()
Initialize all virtual consoles.
Definition: tty.c:89
#define TTY_CONSOLE
Definition: main.c:29
void kmain()
Definition: main.c:32
Paged memory management.
void acpi_init()
Find and parse all available ACPI tables.
Definition: acpi.c:281
void kshell()
Definition: shell.c:314
PCI controller.
System call support.
void timer_init(uint32_t frequency)
Initialize the timer controller so that it interrupts the kernel at the requested frequency...
Definition: timer.c:37
Interrupt handling operations.
void tty_print(int id, const char *str)
Output a null-terminated string to the virtual console using the console&#39;s current text color and scr...
Definition: tty.c:343
void pmap_init()
Initialize the physical memory map using data installed by the BIOS during boot loading.
Definition: pmap.c:292
Teletype (console) screen text manipulation routines.
void tty_clear(int id)
Clear the virtual console screen&#39;s contents using the current text background color.
Definition: tty.c:174