Change to limine bootloader
This commit is contained in:
+2
-1
@@ -20,8 +20,9 @@ stack_top:
|
||||
.section .text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
|
||||
_start:
|
||||
mov $stack_top, %esp
|
||||
mov $stack_top, %rsp
|
||||
|
||||
/* Initialize processor state here */
|
||||
|
||||
|
||||
+22
-2
@@ -6,10 +6,24 @@
|
||||
#if defined(__linux__)
|
||||
#error "Not using cross compiler"
|
||||
#endif
|
||||
#if !defined(__i386__)
|
||||
#error "Not using a ix86-elf compiler"
|
||||
#if !defined(__x86_64__)
|
||||
#error "Not using a x86_64-elf compiler"
|
||||
#endif
|
||||
|
||||
static inline uint64_t read_msr(uint32_t msr) {
|
||||
uint32_t lo, hi;
|
||||
__asm__ volatile("rdmsr" : "=a"(lo), "=d"(hi) : "c"(msr));
|
||||
return ((uint64_t)hi << 32) | lo;
|
||||
}
|
||||
|
||||
#define IA32_EFER 0xC0000080
|
||||
#define EFER_LMA (1 << 10)
|
||||
|
||||
int is_long_mode_active(void) {
|
||||
uint64_t efer = read_msr(IA32_EFER);
|
||||
return (efer & EFER_LMA) != 0;
|
||||
}
|
||||
|
||||
void kernel_main(void) {
|
||||
init_serial();
|
||||
if (!test_serial()) {
|
||||
@@ -17,4 +31,10 @@ void kernel_main(void) {
|
||||
return;
|
||||
}
|
||||
serial_log(S_LOG, "Init serial succesfully.");
|
||||
|
||||
if (!is_long_mode_active()) {
|
||||
serial_log(S_ERR, "Kernel is not in long mode!");
|
||||
return;
|
||||
}
|
||||
serial_log(S_LOG, "Kernel is in long mode.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
/SimpleKernel
|
||||
protocol: multiboot1
|
||||
kernel_path: boot():/boot/kernel
|
||||
Reference in New Issue
Block a user