Temp branch for merging
This commit is contained in:
parent
1e7b5d9eb7
commit
0805a76f81
|
@ -183,7 +183,7 @@ $RECYCLE.BIN/
|
|||
#############
|
||||
## CLION
|
||||
#############
|
||||
CMakeLists.txt
|
||||
#CMakeLists.txt
|
||||
.idea/
|
||||
|
||||
#############
|
||||
|
|
|
@ -72,4 +72,5 @@ pushaq
|
|||
cld
|
||||
call hal_interrupt_handler_dummy
|
||||
popaq
|
||||
xchg bx,bx
|
||||
iretq
|
|
@ -1,5 +1,6 @@
|
|||
global hal_flush_gdt
|
||||
global hal_flush_tlb
|
||||
global hal_flush_idt
|
||||
global hal_cpuid
|
||||
;Functions preserve the registers rbx, rsp, rbp, r12, r13, r14, and 15
|
||||
;rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11 are scratch registers.
|
||||
|
@ -52,4 +53,9 @@ pop rcx
|
|||
mov [rcx],rdx
|
||||
ret
|
||||
|
||||
;flush_idt
|
||||
hal_flush_idt:
|
||||
lidt [rdi]
|
||||
ret
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
uint8_t g_gdt[8*9];
|
||||
uint8_t g_idt[21*16];
|
||||
gdt_ptr_t g_gdt_ptr;
|
||||
idt_ptr_t g_idt_ptr;
|
||||
|
||||
extern uint64_t text_pos;
|
||||
|
||||
void NATIVE64 hal_init(multiboot_info_t* m_info)
|
||||
|
@ -68,10 +70,14 @@ void NATIVE64 hal_init(multiboot_info_t* m_info)
|
|||
hal_printf("AIPC detected...");
|
||||
}
|
||||
|
||||
|
||||
for(uint64_t i = 0; i <= 21; i++)
|
||||
{
|
||||
hal_set_interrupt_handler(i, hal_interrupt_handler_wrapper);
|
||||
}
|
||||
g_idt_ptr.base = (uint64_t)g_idt;
|
||||
g_idt_ptr.limit = 21*16-1;
|
||||
hal_flush_idt(&g_idt_ptr);
|
||||
|
||||
return;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#include "io.h"
|
||||
#include "print.h"
|
||||
#include "hal.h"
|
||||
|
||||
void hal_interrupt_handler_dummy(void)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,12 @@ typedef struct __attribute__ ((packed))
|
|||
uint64_t base;
|
||||
} gdt_ptr_t;
|
||||
|
||||
typedef struct __attribute__ ((packed))
|
||||
{
|
||||
uint16_t limit;
|
||||
uint64_t base;
|
||||
} idt_ptr_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint64_t eax;
|
||||
|
@ -86,6 +92,8 @@ extern void NATIVE64 hal_flush_tlb();
|
|||
|
||||
extern void NATIVE64 hal_cpuid(uint64_t * eax, uint64_t * ebx, uint64_t* ecx, uint64_t* edx);
|
||||
|
||||
extern void NATIVE64 hal_flush_idt(idt_ptr_t* idt_ptr);
|
||||
|
||||
void NATIVE64 hal_write_segment_descriptor(void *const gdt, uint32_t const base, uint32_t const limit, uint64_t const attr);
|
||||
|
||||
void NATIVE64 hal_write_pml4_entry(void *const base, uint64_t const pdpt_addr, uint64_t const attr);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "../common/kdef.h"
|
||||
#include "../common/type.h"
|
||||
#include "../hal/hal.h"
|
||||
#include "../hal/print.h"
|
||||
#include "../hal/io.h"
|
||||
|
||||
extern char kernel_start[];
|
||||
extern char kernel_end[];
|
||||
|
@ -9,5 +9,6 @@ void NATIVE64 kmain(multiboot_info_t *multiboot_info)
|
|||
{
|
||||
hal_init(multiboot_info);
|
||||
hal_printf("Finished setting up HAL\n");
|
||||
HLT_CPU();
|
||||
hal_enable_interrupt();
|
||||
while(1);
|
||||
}
|
Loading…
Reference in New Issue