aboutsummaryrefslogtreecommitdiff
path: root/src/kernel.cc
blob: 456910791a67df98dc9d7b65c8fd6fc234122603 (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
/* Check if the compiler thinks you are targeting the wrong operating system. */
#if defined(__linux__)
#error "You are not using a cross-compiler"
#endif

/* This tutorial will only work for the 32-bit ix86 targets. */
#if !defined(__i386__)
#error "This tutorial needs to be compiled with a ix86-elf compiler"
#endif

#include <stdlib.h>
#include <types.h>
#include "gdt.h"
#include "vga.h"

extern "C" {
void dump_multiboot(uint32_t mb_magic, uint32_t mb_addr);
void dump_gdt();

void kernel_main([[maybe_unused]] uint32_t mb_magic, [[maybe_unused]] uint32_t mb_addr) {
  VGA terminal;
  Console::set(&terminal);

  printk("Hello, kernel World!\n");

  // dump_multiboot(mb_magic, mb_addr);
  dump_gdt();

  printk("GDT::SegmentDescriptor tests\n");
  auto x = GDT::SegmentDescriptor::make<0xffff>(0xdeadbeef, {});
  printk("x.base(): ", uhex{x.base()}, '\n');

  printk("Setting new GDT\n");
  GDT gdt;
  dump_gdt();

  abort();
}
}  // extern "C"