mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
x86_64 interrupts: gpf isr and add support for the user safe memops
This commit is contained in:
@@ -56,6 +56,8 @@ void idt_bspinit(){
|
|||||||
|
|
||||||
idt_setentry(&idt[VECTOR_PF], asmisr_pagefault, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
idt_setentry(&idt[VECTOR_PF], asmisr_pagefault, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
||||||
|
|
||||||
|
idt_setentry(&idt[VECTOR_GPF], asmisr_gpf, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
||||||
|
|
||||||
idt_setentry(&idt[VECTOR_DEVUNAVAILABLE], asmisr_nm, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
idt_setentry(&idt[VECTOR_DEVUNAVAILABLE], asmisr_nm, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
||||||
|
|
||||||
idt_setentry(&idt[VECTOR_PANIC], asmisr_panic, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
idt_setentry(&idt[VECTOR_PANIC], asmisr_panic, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ extern void asmisr_ps2kbd();
|
|||||||
extern void asmisr_timer();
|
extern void asmisr_timer();
|
||||||
extern void asmisr_simd();
|
extern void asmisr_simd();
|
||||||
extern void asmisr_nm();
|
extern void asmisr_nm();
|
||||||
|
extern void asmisr_gpf();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ asmisr_panic:
|
|||||||
jmp .hlt ; NMI stuff
|
jmp .hlt ; NMI stuff
|
||||||
|
|
||||||
except asmisr_pagefault, isr_pagefault, 0xE
|
except asmisr_pagefault, isr_pagefault, 0xE
|
||||||
|
except asmisr_gpf, isr_gpf, 0xD
|
||||||
except asmisr_nm, isr_except, 0x7
|
except asmisr_nm, isr_except, 0x7
|
||||||
isr asmisr_general, isr_general, 0xFF
|
isr asmisr_general, isr_general, 0xFF
|
||||||
except asmisr_except, isr_except, 0xFF
|
except asmisr_except, isr_except, 0xFF
|
||||||
|
|||||||
+27
-2
@@ -3,6 +3,9 @@
|
|||||||
#include <kernel/vmm.h>
|
#include <kernel/vmm.h>
|
||||||
#include <arch/apic.h>
|
#include <arch/apic.h>
|
||||||
#include <kernel/timer.h>
|
#include <kernel/timer.h>
|
||||||
|
#include <arch/cls.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
void isr_simd(arch_regs *reg){
|
void isr_simd(arch_regs *reg){
|
||||||
|
|
||||||
@@ -21,14 +24,36 @@ void isr_general(arch_regs *reg, int n){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void isr_except(arch_regs *reg, int n){
|
void isr_except(arch_regs *reg, int n){
|
||||||
|
|
||||||
printf("exception %d", n);
|
printf("exception %d", n);
|
||||||
_panic("CPU Exception", reg);
|
_panic("CPU Exception", reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void isr_pagefault(arch_regs *reg){
|
void isr_gpf(arch_regs* reg){
|
||||||
|
|
||||||
if(!vmm_dealwithrequest(reg->cr2, reg->error, reg->cs == 0x3b))
|
arch_getcls()->thread->umemoperror = EFAULT;
|
||||||
|
|
||||||
|
if(arch_getcls()->thread->umemopfailaddr == NULL)
|
||||||
|
_panic("General protection fault!", reg);
|
||||||
|
else
|
||||||
|
reg->rip = (uint64_t)arch_getcls()->thread->umemopfailaddr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void isr_pagefault(arch_regs *reg){
|
||||||
|
int error = vmm_dealwithrequest(reg->cr2, reg->error, reg->cs == 0x3b);
|
||||||
|
|
||||||
|
if(error){
|
||||||
|
if(arch_getcls()->thread->umemopfailaddr == NULL){
|
||||||
_panic("Page fault!", reg);
|
_panic("Page fault!", reg);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
reg->rip = (uint64_t)arch_getcls()->thread->umemopfailaddr;
|
||||||
|
arch_getcls()->thread->umemoperror = error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user