blob: c2d4a22a99ac857a5aeb9a9aab2f89b1ec8449d1 (
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 "aplos.h"
#define LIMINE_API_REVISION 3
#include "../external/limine/limine.h"
#define LIMINE(sec) \
__attribute__((used, section(sec))) \
static volatile
#define REQUEST LIMINE(".limine_requests")
static void bootmain(void);
REQUEST LIMINE_BASE_REVISION(3)
REQUEST struct limine_framebuffer_request framebuffer_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 0
};
REQUEST struct limine_memmap_request memmap_request = {
.id = LIMINE_MEMMAP_REQUEST,
.revision = 0
};
REQUEST struct limine_paging_mode_request paging_request = {
.id = LIMINE_PAGING_MODE_REQUEST,
.revision = 1,
.mode = LIMINE_PAGING_MODE_X86_64_4LVL,
.min_mode = LIMINE_PAGING_MODE_X86_64_4LVL,
.max_mode = LIMINE_PAGING_MODE_X86_64_4LVL
};
REQUEST struct limine_mp_request mp_request = {
.id = LIMINE_MP_REQUEST,
.revision = 0
};
REQUEST struct limine_entry_point_request entry_point_request = {
.id = LIMINE_ENTRY_POINT_REQUEST,
.revision = 0,
.entry = bootmain
};
LIMINE(".limine_requests_start") LIMINE_REQUESTS_START_MARKER
LIMINE(".limine_requests_end") LIMINE_REQUESTS_END_MARKER
uint64_t
cpu_count(void)
{
return mp_request.response->cpu_count;
}
static void
bootmain(void)
{
struct boot_info info;
assert(LIMINE_BASE_REVISION_SUPPORTED);
assert(framebuffer_request.response);
assert(memmap_request.response);
assert(paging_request.response);
assert(mp_request.response);
assert(framebuffer_request.response->framebuffer_count >= 1);
struct limine_framebuffer *framebuffer = framebuffer_request.response->framebuffers[0];
info.framebuffer.addr = framebuffer->address;
info.framebuffer.width = framebuffer->width;
info.framebuffer.height = framebuffer->height;
info.framebuffer.pitch = framebuffer->pitch;
struct memmap memmaps[memmap_request.response->entry_count];
info.memmap_count = 0;
struct memmap *m = memmaps;
for(uint64_t i = 0; i < memmap_request.response->entry_count; i++){
struct limine_memmap_entry *e = memmap_request.response->entries[i];
if(e->type != LIMINE_MEMMAP_USABLE)
continue;
m->start = e->base;
m->size = e->length;
m++;
info.memmap_count++;
}
info.memmaps = memmaps;
main(&info);
halt();
}
|