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

#include "arch/context_switching/syscall/main.hpp"
#include "arch/memory/heap/global_heap_allocator.hpp"

// TODO: Disallow these imports
#include "arch/kernel/cpu/if.hpp"
#include "arch/video/vga/text.hpp"

namespace teachos::arch::user
{
  auto main() -> void
  {
    char constexpr syscall_message[] = "Successfully entered user mode and wrote to VGA buffer via syscall!";
    context_switching::syscall::syscall(context_switching::syscall::type::WRITE,
                                        {reinterpret_cast<uint64_t>(&syscall_message)});

    // kernel::cpu::clear_interrupt_flag();  // Causes crash Kernel Code (.text) is not mapped in User mMde

    auto address = memory::heap::global_heap_allocator::malloc(8U);
    (void)address;

    // auto test = new int{20};  // Causes crash Heap is not mapped in User Mode
    // (void)test;

    // if (!error)
    // {
    //   // Causes crash vga is not mapped in User Mode
    //   video::vga::text::write("Successfully made a SYSCALL and returned with SYSRETQ!",
    //                           video::vga::text::common_attributes::green_on_black);
    // }

    for (;;)
    {
    }
  }
}  // namespace teachos::arch::user