This commit is contained in:
quackerd 2020-07-09 23:54:12 +08:00
parent e573ec96b8
commit 8318ca688d
Signed by: d
GPG Key ID: 590A22374D0B819F
6 changed files with 19 additions and 51 deletions

View File

@ -3,5 +3,5 @@
ATTR_NORETURN void
arch_brute()
{
while(1) {}
while (1) {}
}

View File

@ -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

View File

@ -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);

View File

@ -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");
}

View File

@ -5,6 +5,7 @@
#include <arch/brute.h>
#include <arch/mlayout.h>
#include <arch/pmap.h>
#include <arch/intr.h>
#include <mm/phys.h>
#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

View File

@ -36,7 +36,7 @@ struct interrupt_context
* C declaration
*/
void
arch_intr_init(void);
archp_intr_init(void);
/**
* Exported Dispatchers for asm code