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

#include "arch/exception_handling/assert.hpp"
#include "arch/memory/frame_allocator.hpp"
#include "arch/memory/multiboot/reader.hpp"
#include "arch/video/vga/text.hpp"

#include <algorithm>

namespace teachos::arch::kernel
{
  auto main() -> void
  {
    using namespace video::vga;

    text::clear();
    text::cursor(false);
    text::write("TeachOS is starting up...", text::common_attributes::green_on_black);

    auto memory_information = memory::multiboot::read_multiboot2();
    auto allocator = memory::area_frame_allocator(memory_information);

    auto last_allocated = allocator.allocate_frame();
    auto allocated = last_allocated;
    do
    {
      last_allocated = allocated;
      allocated = allocator.allocate_frame();
    } while (allocated.has_value());
    video::vga::text::write("Allocated Frames", video::vga::text::common_attributes::green_on_black);
    video::vga::text::write_number(allocated.value().frame_number, video::vga::text::common_attributes::green_on_black);
  }
}  // namespace teachos::arch::kernel