blob: 4f42491872c83382e9dec42cb9c514f1b4ae99ee (
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
|
#include "limine.h"
#include "boot.h"
#include "string.h"
char s_kernel_stack_initial[8192];
char *jove_bootargs;
int jove_bootargs_len;
void *_boot_initrd_base;
size_t _boot_initrd_size;
uintptr_t _boot_kernel_phys_base;
struct limine_kernel_file_request s_kernel_file_req = {
.id = LIMINE_KERNEL_FILE_REQUEST
};
static struct limine_kernel_address_request s_kaddr_req = {
.id = LIMINE_KERNEL_ADDRESS_REQUEST
};
#ifdef ENABLE_INITRD
static struct limine_module_request s_module_request = {
.id = LIMINE_MODULE_REQUEST
};
#endif
static void
e9_putc(char c)
{
__asm__ volatile("outb %0, %1":: "a"(c), "Nd"(0xe9): "memory");
}
static void
e9_puts(char *s)
{
for(; *s; s++) e9_putc(*s);
}
void
_start(void)
{
__asm__ volatile("movq %0, %%rsp":: "r"((uintptr_t)&s_kernel_stack_initial + 8191));
struct limine_kernel_file_response *kernel_file_response = s_kernel_file_req.response;
jove_bootargs = kernel_file_response->kernel_file->cmdline;
jove_bootargs_len = strlen(jove_bootargs);
#ifdef ENABLE_INITRD
struct limine_module_response *initrd_module_response = s_module_request.response;
if(initrd_module_response->module_count == 0) {
e9_puts("Missing kernel modules\n");
for(;;);
}
_boot_initrd_base = initrd_module_response->modules[0]->address;
_boot_initrd_size = initrd_module_response->modules[0]->size;
#endif
_boot_kernel_phys_base = s_kaddr_req.response->physical_base;
//Zero all spaces in bootargs not enclosed with quotes.
for(char *c = jove_bootargs; *c; c++) {
if(*c == '"') {
*c = 0;
for(++c; *c && *c != '"'; c++);
*(c++) = 0;
continue;
}
if(*c == ' ') *c = 0;
}
extern void _jove_main(void);
__asm__ volatile("movq $0, %%rbp"::);
_jove_main();
}
|