summaryrefslogtreecommitdiff
path: root/kernel/entry.cxx
blob: 643fbc0211f7fc9a04269f08b393483f63f02192 (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
55
56
57
58
59
60
61
62
63
64
#include "../vendor/limine/limine.h"
#include "../version.h"

#include <io/logger/base.h>
#include <cstdint>

#if defined (__x86_64__)
#include <amd64/io/com1.h>
#endif

using namespace hos::io;

__attribute__ ((used, section(".requests")))
static volatile LIMINE_BASE_REVISION(3);

__attribute__ ((used, section(".requests")))
static volatile limine_framebuffer_request framebuffer_request = {
    .id = LIMINE_FRAMEBUFFER_REQUEST,
    .revision = 0,
    .response = nullptr
};

__attribute__ ((used, section(".requests_start")))
static volatile LIMINE_REQUESTS_START_MARKER;

__attribute__ ((used, section(".requests_end")))
static volatile LIMINE_REQUESTS_END_MARKER;

static void hcf (void)
{
    for (;;)
    {
        asm ("hlt");
    }
}

void init (void);

extern "C" void _launch (void);
void _launch (void)
{
    // Global C++ Constructors
    init();

    logger<com_logger> logger(log_level::DEBUG);
    logger.write(log_level::INFO, "Welcome to HinterOS %s!", HOS_CORE_VERSION);

    if (LIMINE_BASE_REVISION_SUPPORTED == false)
    {
        logger.write(log_level::FATAL, "Limine revision mismatch.");
        hcf();
    }

    logger.write(log_level::DEBUG, "Limine... ok");

    struct limine_framebuffer *fb = framebuffer_request.response->framebuffers[0];
    for (std::size_t i = 0; i < (fb->width - 1) * (fb->height - 1); i += 2)
    {
        volatile std::uint32_t *fbptr = static_cast<std::uint32_t *>(fb->address);
        fbptr[i] = 0xffffff00;
    }

    hcf();
}