diff --git a/arch/brute.c b/arch/brute.c index d418647..10cdb61 100644 --- a/arch/brute.c +++ b/arch/brute.c @@ -3,5 +3,5 @@ ATTR_NORETURN void arch_brute() { - while(1) {} + while (1) {} } diff --git a/arch/cpu.asm b/arch/cpu.asm index c1f6680..f2a291c 100644 --- a/arch/cpu.asm +++ b/arch/cpu.asm @@ -10,7 +10,7 @@ global arch_read_cr3 global arch_write_cr3 global arch_read_cr8 global arch_write_cr8 -global arch_cpuid +global archp_cpuid global arch_halt_cpu global arch_read_msr global arch_write_msr @@ -102,15 +102,15 @@ mov cr8,rdi ret ;====================== -global arch_halt -arch_halt: +global archp_halt +archp_halt: hlt ; ============================ -; extern void KAPI arch_cpuid(uint32* eax, uint32* ebx, uint32* ecx, uint32* edx); -global arch_cpuid -arch_cpuid: +; extern void KAPI archp_cpuid(uint32* eax, uint32* ebx, uint32* ecx, uint32* edx); +global archp_cpuid +archp_cpuid: push rbp mov rbp,rsp ; preserve rbx,rcx,rdx diff --git a/arch/cpu.h b/arch/cpu.h index 3b3f6ef..75629df 100644 --- a/arch/cpu.h +++ b/arch/cpu.h @@ -13,51 +13,12 @@ struct ATTR_PACKED hal_idt_ptr { uint64 base; }; -void KABI out_8(uint16 port, uint8 data); - -void KABI out_16(uint16 port, uint16 data); - -void KABI out_32(uint16 port, uint32 data); - -uint8 KABI in_8(uint16 port); - -uint16 KABI in_16(uint16 port); - -uint32 KABI in_32(uint16 port); - -void KABI flush_gdt(void *gdt_ptr, uint16 code_slct, uint16 data_slct); - -void KABI flush_idt(void *idt_ptr); - -void KABI flush_tss(uint16 tss_slct); - -void KABI cpuid(uint32 *eax, uint32 *ebx, uint32 *ecx, uint32 *edx); - -void KABI read_msr(uint32 *ecx, uint32 *edx, uint32 *eax); - -void KABI write_msr(uint32 *ecx, uint32 *edx, uint32 *eax); - -void KABI sti(); - -void KABI cli(); - -uint64 KABI read_cr8(); - -void KABI write_cr8(uint64 val); - -uint64 KABI read_cr3(); - -void KABI write_cr3(uint64 val); - -void KABI flush_tlb(); - - /** * ASM declaration */ -void KABI arch_cpuid(uint32 *eax, uint32 *ebx, uint32 *ecx, uint32 *edx); +void KABI archp_cpuid(uint32 *eax, uint32 *ebx, uint32 *ecx, uint32 *edx); -void KABI arch_halt(void); +void KABI archp_halt(void); void KABI arch_flush_gdt(struct hal_gdt_ptr *gdt_ptr, uint64 code_slct, uint64 data_slct); diff --git a/arch/intr.c b/arch/intr.c index 2a411a6..82b40ca 100644 --- a/arch/intr.c +++ b/arch/intr.c @@ -73,7 +73,7 @@ populate_idt(void) } void -arch_intr_init(void) +archp_intr_init(void) { uint32 coreid; uint32 eax; @@ -83,7 +83,7 @@ arch_intr_init(void) // detect APIC first eax = 1; - arch_cpuid(&eax, &ebx, &ecx, &edx); + archp_cpuid(&eax, &ebx, &ecx, &edx); if (!(edx & (1u << 9u))) { BRUTE("ERROR: APIC is not present.\n"); } diff --git a/arch/main.c b/arch/main.c index 13d4e89..08bceff 100644 --- a/arch/main.c +++ b/arch/main.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "multiboot2.h" @@ -60,6 +61,12 @@ proc_mbinfo(void *mb_info) if (!mmap_detected) { BRUTE("proc_mbinfo: could not find MMAP tag."); } + + // initialize interrupts + archp_intr_init(); + + // initialize memory + archp_mem_init(); } ATTR_USED void diff --git a/inc/arch/intr.h b/inc/arch/intr.h index 3a54a62..ba2ede5 100644 --- a/inc/arch/intr.h +++ b/inc/arch/intr.h @@ -36,7 +36,7 @@ struct interrupt_context * C declaration */ void -arch_intr_init(void); +archp_intr_init(void); /** * Exported Dispatchers for asm code