aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/main.cpp
blob: 7463fc4ee22708c4315cba1a0e50aa6750f92872 (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
#include "arch/kernel/main.hpp"

#include "arch/memory/heap/bump_allocator.hpp"
#include "arch/memory/heap/concept.hpp"
#include "arch/memory/main.hpp"
#include "arch/memory/multiboot/reader.hpp"
#include "arch/video/vga/text.hpp"

namespace teachos::arch::kernel
{
  auto stack_overflow_test(int count) -> int
  {
    int test[5000] = {};
    if (test[0] == 0xFFFF)
    {
      return count;
    }
    count = stack_overflow_test(count);
    return count++;
  }

  auto heap_test() -> void
  {
    memory::heap::bump_allocator heap_allocator{memory::heap::HEAP_START,
                                                memory::heap::HEAP_START + memory::heap::HEAP_SIZE};
    auto test = heap_allocator.allocate(1024);
    auto test2 = new (test) memory::multiboot::memory_information{};
    test = static_cast<void *>(static_cast<memory::multiboot::memory_information *>(test) + 1);
    auto test3 = new (test) memory::multiboot::memory_information{};
    auto test4 = *test2;
    auto test5 = *test3;
    test4.kernel_end = 5000;
    test5.kernel_end = 3000;
    auto test6 = test4.kernel_end;
    auto test7 = test5.kernel_end;
    auto test8 = memory::multiboot::read_multiboot2();
    if (test6 && test7 && test8.kernel_end)
    {
      video::vga::text::write("Kernel remapping successfull", video::vga::text::common_attributes::green_on_black);
    }
  }

  auto main() -> void
  {
    video::vga::text::clear();
    video::vga::text::cursor(false);
    video::vga::text::write("TeachOS is starting up...", video::vga::text::common_attributes::green_on_black);

    memory::initialize_memory_management();

    // stack_overflow_test(0);
    // heap_test();
  }
}  // namespace teachos::arch::kernel