summaryrefslogtreecommitdiffstats
path: root/boot/limine/start.c
blob: 803c1def0c3e901bf10e4ac2e9da461313ac97d9 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdint.h>
#include <stddef.h>

#include "api/init.h"
#include "boot/cmdline.h"
#include "limine.h"

void _start(void);

#define LIMINE_REQUEST_SECTION __attribute__((section(".limine_requests")))

LIMINE_REQUEST_SECTION
static volatile uint64_t limine_base_revision[] = LIMINE_BASE_REVISION(4);

LIMINE_REQUEST_SECTION
static volatile uint64_t limine_requests_start_marker[] = LIMINE_REQUESTS_START_MARKER;

LIMINE_REQUEST_SECTION
static volatile struct limine_executable_cmdline_request cmdline_req = {
    .id = LIMINE_EXECUTABLE_CMDLINE_REQUEST_ID,
    .revision = 0, .response = NULL
};

LIMINE_REQUEST_SECTION
static volatile struct limine_entry_point_request entry_point_req = {
    .id = LIMINE_ENTRY_POINT_REQUEST_ID,
    .revision = 0, .response = NULL,
    .entry = _start
};

LIMINE_REQUEST_SECTION
static volatile struct limine_executable_address_request executable_address_req = {
    .id = LIMINE_EXECUTABLE_ADDRESS_REQUEST_ID,
    .revision = 0, .response = NULL
};

LIMINE_REQUEST_SECTION
static volatile struct limine_memmap_request memmap_req = {
    .id = LIMINE_MEMMAP_REQUEST_ID,
    .revision = 0, .response = NULL
};

LIMINE_REQUEST_SECTION
static volatile struct limine_module_request module_req = {
    .id = LIMINE_MODULE_REQUEST_ID,
    .revision = 0, .response = NULL
};

LIMINE_REQUEST_SECTION
static volatile struct limine_framebuffer_request framebuffer_request = {
    .id = LIMINE_FRAMEBUFFER_REQUEST_ID,
    .revision = 0, .response = NULL
};

LIMINE_REQUEST_SECTION
static volatile struct limine_rsdp_request rsdp_request = {
    .id = LIMINE_RSDP_REQUEST_ID,
    .revision = 0, .response = NULL
};

LIMINE_REQUEST_SECTION
static volatile uint64_t limine_requests_end_marker[] = LIMINE_REQUESTS_END_MARKER;

void *_kernel_physptr = NULL;
void *_initrd_module = NULL;
struct limine_framebuffer_response *_limine_framebuffers;
struct limine_memmap_response *_limine_memmap_resp = NULL;

__attribute__((noreturn))
void
_start(void)
{
    _kernel_physptr = (void*)executable_address_req.response->physical_base;
    _limine_memmap_resp = memmap_req.response;
    _limine_framebuffers = framebuffer_request.response;

    extern struct init_payload _init_payload;
    _init_payload.rsdp = (void*)((uintptr_t)rsdp_request.response->address & 0xFFFFFFFF);
    
    if(module_req.response->module_count > 0) {
        _initrd_module = module_req.response->modules[0]->address;
    }

    cmdline_init(cmdline_req.response->cmdline);

    __attribute__((noreturn))
    extern void kernel_entry(void);

    kernel_entry();
}