Functions for reading/writing some special registers
This commit is contained in:
parent
96d2ebd977
commit
c1c3842ace
@ -6,7 +6,7 @@
|
|||||||
#include "interrupts.c"
|
#include "interrupts.c"
|
||||||
|
|
||||||
uintptr_t isr_table[] ={};
|
uintptr_t isr_table[] ={};
|
||||||
void load_idt(struct idtr *_)
|
void load_idt(void *_)
|
||||||
{
|
{
|
||||||
(void)_;
|
(void)_;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
.global load_idt
|
|
||||||
load_idt:
|
|
||||||
lidt [rdi]
|
|
||||||
ret
|
|
||||||
|
|
||||||
.extern int_handler
|
.extern int_handler
|
||||||
.global isr_common
|
.global isr_common
|
||||||
.global isr_return
|
.global isr_return
|
||||||
|
23
src/kernel/cpu/registers.S
Normal file
23
src/kernel/cpu/registers.S
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
.intel_syntax noprefix
|
||||||
|
|
||||||
|
.global load_idt
|
||||||
|
load_idt:
|
||||||
|
lidt [rdi]
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global read_cr0
|
||||||
|
read_cr0:
|
||||||
|
mov rax, cr0
|
||||||
|
ret
|
||||||
|
.global read_cr2
|
||||||
|
read_cr2:
|
||||||
|
mov rax, cr2
|
||||||
|
ret
|
||||||
|
.global read_cr3
|
||||||
|
read_cr3:
|
||||||
|
mov rax, cr3
|
||||||
|
ret
|
||||||
|
.global read_cr4
|
||||||
|
read_cr4:
|
||||||
|
mov rax, cr4
|
||||||
|
ret
|
@ -1,3 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
void cpu_init();
|
void cpu_init();
|
||||||
|
|
||||||
|
|
||||||
|
void load_idt(void *);
|
||||||
|
|
||||||
|
uint64_t read_cr0();
|
||||||
|
uint64_t read_cr2();
|
||||||
|
uint64_t read_cr3();
|
||||||
|
uint64_t read_cr4();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <cpu.h>
|
||||||
|
|
||||||
#define IDT_INTERRUPT 0xE
|
#define IDT_INTERRUPT 0xE
|
||||||
#define IDT_DPL0 0x0
|
#define IDT_DPL0 0x0
|
||||||
@ -57,9 +58,9 @@ debug("RAX=%016x RBX=%016x RCX=%016x RDX=%016x\n", r->rax, r->rbx, r->rcx, r->rd
|
|||||||
debug("RSI=%016x RDI=%016x RBP=%016x RSP=%016x\n", r->rsi, r->rdi, r->rbp, r->rsp); \
|
debug("RSI=%016x RDI=%016x RBP=%016x RSP=%016x\n", r->rsi, r->rdi, r->rbp, r->rsp); \
|
||||||
debug("R8 =%016x R9 =%016x R10=%016x R11=%016x\n", r->r8, r->r9, r->r10, r->r11); \
|
debug("R8 =%016x R9 =%016x R10=%016x R11=%016x\n", r->r8, r->r9, r->r10, r->r11); \
|
||||||
debug("R12=%016x R13=%016x R14=%016x R15=%016x\n", r->r12, r->r13, r->r14, r->r15); \
|
debug("R12=%016x R13=%016x R14=%016x R15=%016x\n", r->r12, r->r13, r->r14, r->r15); \
|
||||||
debug("RIP=%016x RFL=%016x\n", r->rip, r->rflags); \
|
debug("RIP=%016x RFL=%08x\n", r->rip, r->rflags); \
|
||||||
debug("CS=%016x SS=%016x\n", r->cs, r->ss);
|
debug("CS=%016x SS=%016x\n", r->cs, r->ss); \
|
||||||
|
debug("CR0=%08x CR2=%016x CR3=%016x CR4=%08x\n", read_cr0(), read_cr2(), read_cr3(), read_cr4());
|
||||||
|
|
||||||
void load_idt(struct idtr *);
|
|
||||||
|
|
||||||
void interrupt_init();
|
void interrupt_init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user