interrupt service routines registered under init_idt, but not yet impl
This commit is contained in:
parent
377622d87c
commit
8b178f0992
@ -10,6 +10,8 @@
|
|||||||
; for consistency
|
; for consistency
|
||||||
|
|
||||||
extern interrupt_handler
|
extern interrupt_handler
|
||||||
|
extern cpu_reg_state
|
||||||
|
extern stack_state
|
||||||
|
|
||||||
%macro no_err_handler 1
|
%macro no_err_handler 1
|
||||||
global interrupt_handler_%1 ; defined in interrupts.h
|
global interrupt_handler_%1 ; defined in interrupts.h
|
||||||
@ -29,42 +31,40 @@ interrupt_handler_%1:
|
|||||||
|
|
||||||
common_int_handler:
|
common_int_handler:
|
||||||
; save thigns before do our C-call
|
; save thigns before do our C-call
|
||||||
push eax
|
pushad
|
||||||
push ebx
|
;push eax
|
||||||
push ecx
|
;push ecx
|
||||||
push edx
|
;push edx
|
||||||
|
;push ebx
|
||||||
|
|
||||||
push cs
|
;push esp
|
||||||
push ds
|
;push ebp
|
||||||
push es
|
;push esi
|
||||||
push fs
|
;push edi
|
||||||
push gs
|
|
||||||
push ss
|
|
||||||
|
|
||||||
push esi
|
;push ds
|
||||||
push edi
|
;push es
|
||||||
push ebp
|
;push fs
|
||||||
push esp
|
;push gs
|
||||||
|
|
||||||
call interrupt_handler
|
call interrupt_handler
|
||||||
; restore state to the function
|
|
||||||
pop eax
|
|
||||||
pop ebx
|
|
||||||
pop ecx
|
|
||||||
pop edx
|
|
||||||
|
|
||||||
pop cs
|
; segments
|
||||||
pop ds
|
|
||||||
pop es
|
|
||||||
pop fs
|
|
||||||
pop gs
|
pop gs
|
||||||
pop ss
|
pop fs
|
||||||
|
pop es
|
||||||
|
pop ds
|
||||||
|
|
||||||
pop esi
|
|
||||||
pop edi
|
pop edi
|
||||||
|
pop esi
|
||||||
pop ebp
|
pop ebp
|
||||||
pop esp
|
pop esp
|
||||||
|
|
||||||
|
pop ebx
|
||||||
|
pop edx
|
||||||
|
pop ecx
|
||||||
|
pop eax
|
||||||
|
|
||||||
add esp, 8
|
add esp, 8
|
||||||
; special instruction which lets us jump back to code
|
; special instruction which lets us jump back to code
|
||||||
; which was previously interrupted
|
; which was previously interrupted
|
||||||
@ -94,3 +94,18 @@ no_err_handler 16
|
|||||||
|
|
||||||
err_code_handler 17
|
err_code_handler 17
|
||||||
|
|
||||||
|
no_err_handler 18
|
||||||
|
no_err_handler 19
|
||||||
|
no_err_handler 20
|
||||||
|
no_err_handler 21
|
||||||
|
no_err_handler 22
|
||||||
|
no_err_handler 23
|
||||||
|
no_err_handler 24
|
||||||
|
no_err_handler 25
|
||||||
|
no_err_handler 26
|
||||||
|
no_err_handler 27
|
||||||
|
no_err_handler 28
|
||||||
|
no_err_handler 29
|
||||||
|
no_err_handler 30
|
||||||
|
no_err_handler 31
|
||||||
|
no_err_handler 32
|
||||||
|
84
interrupts.c
84
interrupts.c
@ -2,6 +2,46 @@
|
|||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
extern void no_err_handler_1();
|
||||||
|
extern void no_err_handler_2();
|
||||||
|
extern void no_err_handler_3();
|
||||||
|
extern void no_err_handler_4();
|
||||||
|
extern void no_err_handler_5();
|
||||||
|
extern void no_err_handler_6();
|
||||||
|
extern void no_err_handler_7();
|
||||||
|
|
||||||
|
extern void err_code_handler_8();
|
||||||
|
|
||||||
|
extern void no_err_handler_9();
|
||||||
|
|
||||||
|
extern void err_code_handler_10();
|
||||||
|
extern void err_code_handler_11();
|
||||||
|
extern void err_code_handler_12();
|
||||||
|
extern void err_code_handler_13();
|
||||||
|
extern void err_code_handler_14();
|
||||||
|
|
||||||
|
extern void no_err_handler_15();
|
||||||
|
extern void no_err_handler_16();
|
||||||
|
|
||||||
|
extern void err_code_handler_17();
|
||||||
|
|
||||||
|
extern void no_err_handler_18();
|
||||||
|
extern void no_err_handler_19();
|
||||||
|
extern void no_err_handler_20();
|
||||||
|
extern void no_err_handler_21();
|
||||||
|
extern void no_err_handler_22();
|
||||||
|
extern void no_err_handler_23();
|
||||||
|
extern void no_err_handler_24();
|
||||||
|
extern void no_err_handler_25();
|
||||||
|
extern void no_err_handler_26();
|
||||||
|
extern void no_err_handler_27();
|
||||||
|
extern void no_err_handler_28();
|
||||||
|
extern void no_err_handler_29();
|
||||||
|
extern void no_err_handler_30();
|
||||||
|
extern void no_err_handler_31();
|
||||||
|
extern void no_err_handler_32();
|
||||||
|
|
||||||
|
|
||||||
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs) {
|
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs) {
|
||||||
// Configuring a single given entry in the IDT table
|
// Configuring a single given entry in the IDT table
|
||||||
IDT[t_idx].offset_low = (base & 0xffff);
|
IDT[t_idx].offset_low = (base & 0xffff);
|
||||||
@ -17,8 +57,9 @@ void load_idt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generic interrupt handler to be used later on
|
// Generic interrupt handler to be used later on
|
||||||
//void interrupt_handler(struct cpu_reg_state cpu, struct stack_state stack, u32 interrupt_code) {
|
void interrupt_handler(struct cpu_reg_state cpu, struct stack_state stack, u32 interrupt_code) {
|
||||||
//}
|
// treating things on the stack like it were a cpu_reg_state
|
||||||
|
}
|
||||||
|
|
||||||
void init_idt() {
|
void init_idt() {
|
||||||
// setup special idt pointer
|
// setup special idt pointer
|
||||||
@ -27,7 +68,44 @@ void init_idt() {
|
|||||||
// clear table
|
// clear table
|
||||||
memset((u8*)IDT, 0x00, (sizeof(struct IDT_Entry) * IDT_SIZE) - 1);
|
memset((u8*)IDT, 0x00, (sizeof(struct IDT_Entry) * IDT_SIZE) - 1);
|
||||||
// add interrupt service routines here
|
// add interrupt service routines here
|
||||||
// TODO
|
setup_idt_entry(0,(u32)no_err_handler_1,0x08, 0x8e);
|
||||||
|
setup_idt_entry(1,(u32)no_err_handler_2,0x08, 0x8e);
|
||||||
|
setup_idt_entry(2,(u32)no_err_handler_3,0x08, 0x8e);
|
||||||
|
setup_idt_entry(3,(u32)no_err_handler_4,0x08, 0x8e);
|
||||||
|
setup_idt_entry(4,(u32)no_err_handler_5,0x08, 0x8e);
|
||||||
|
setup_idt_entry(5,(u32)no_err_handler_6,0x08, 0x8e);
|
||||||
|
setup_idt_entry(6,(u32)no_err_handler_7,0x08, 0x8e);
|
||||||
|
|
||||||
|
setup_idt_entry(7,(u32)err_code_handler_8,0x08, 0x8e);
|
||||||
|
|
||||||
|
setup_idt_entry(8,(u32)no_err_handler_9,0x08, 0x8e); // err
|
||||||
|
|
||||||
|
setup_idt_entry(9,(u32)err_code_handler_10,0x08, 0x8e); // no err
|
||||||
|
setup_idt_entry(0,(u32)err_code_handler_11,0x08, 0x8e); // err
|
||||||
|
setup_idt_entry(11,(u32)err_code_handler_12,0x08, 0x8e);
|
||||||
|
setup_idt_entry(12,(u32)err_code_handler_13,0x08, 0x8e);
|
||||||
|
setup_idt_entry(13,(u32)err_code_handler_14,0x08, 0x8e);
|
||||||
|
|
||||||
|
setup_idt_entry(14,(u32)no_err_handler_15,0x08, 0x8e);
|
||||||
|
setup_idt_entry(15,(u32)no_err_handler_16,0x08, 0x8e); // no err
|
||||||
|
|
||||||
|
setup_idt_entry(16,(u32)err_code_handler_17,0x08, 0x8e);
|
||||||
|
|
||||||
|
setup_idt_entry(17,(u32)no_err_handler_18,0x08, 0x8e); // err
|
||||||
|
setup_idt_entry(18,(u32)no_err_handler_19,0x08, 0x8e); // no err
|
||||||
|
setup_idt_entry(19,(u32)no_err_handler_20,0x08, 0x8e);
|
||||||
|
setup_idt_entry(20,(u32)no_err_handler_21,0x08, 0x8e);
|
||||||
|
setup_idt_entry(21,(u32)no_err_handler_22,0x08, 0x8e);
|
||||||
|
setup_idt_entry(22,(u32)no_err_handler_23,0x08, 0x8e);
|
||||||
|
setup_idt_entry(23,(u32)no_err_handler_24,0x08, 0x8e);
|
||||||
|
setup_idt_entry(24,(u32)no_err_handler_25,0x08, 0x8e);
|
||||||
|
setup_idt_entry(25,(u32)no_err_handler_26,0x08, 0x8e);
|
||||||
|
setup_idt_entry(26,(u32)no_err_handler_27,0x08, 0x8e);
|
||||||
|
setup_idt_entry(27,(u32)no_err_handler_28,0x08, 0x8e);
|
||||||
|
setup_idt_entry(28,(u32)no_err_handler_29,0x08, 0x8e);
|
||||||
|
setup_idt_entry(29,(u32)no_err_handler_30,0x08, 0x8e);
|
||||||
|
setup_idt_entry(30,(u32)no_err_handler_31,0x08, 0x8e);
|
||||||
|
setup_idt_entry(31,(u32)no_err_handler_32,0x08, 0x8e);
|
||||||
|
|
||||||
// Load IDT with all the new information in place, ready to use
|
// Load IDT with all the new information in place, ready to use
|
||||||
load_idt();
|
load_idt();
|
||||||
|
15
interrupts.h
15
interrupts.h
@ -3,22 +3,19 @@
|
|||||||
|
|
||||||
struct cpu_reg_state {
|
struct cpu_reg_state {
|
||||||
u32 eax;
|
u32 eax;
|
||||||
u32 ebx;
|
|
||||||
u32 ecx;
|
u32 ecx;
|
||||||
u32 edx;
|
u32 edx;
|
||||||
|
u32 ebx;
|
||||||
|
|
||||||
|
u32 esp;
|
||||||
|
u32 ebp;
|
||||||
|
u32 esi;
|
||||||
|
u32 edi;
|
||||||
|
|
||||||
u16 cs;
|
|
||||||
u16 ds;
|
u16 ds;
|
||||||
u16 es;
|
u16 es;
|
||||||
u16 fs;
|
u16 fs;
|
||||||
u16 gs;
|
u16 gs;
|
||||||
u16 ss;
|
|
||||||
|
|
||||||
u32 esi;
|
|
||||||
u32 edi;
|
|
||||||
u32 ebp;
|
|
||||||
u32 eip;
|
|
||||||
u32 esp;
|
|
||||||
|
|
||||||
u32 eflags;
|
u32 eflags;
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
Loading…
Reference in New Issue
Block a user