Cucumber/Kernel/include/Tier0/interrupts.h

76 lines
1.9 KiB
C
Raw Normal View History

2011-02-22 17:09:58 +00:00
#include "types.h"
2011-03-16 07:33:27 +00:00
#ifndef __INTERRUPTS_H__
#define __INTERRUPTS_H__
2011-02-22 17:09:58 +00:00
struct S_IDT_PTR {
u16 Limit;
2012-04-21 18:06:00 +00:00
u64 Base;
2011-02-22 17:09:58 +00:00
} __attribute__ ((packed));
typedef struct S_IDT_PTR T_IDT_PTR;
struct S_IDT_ENTRY {
u16 OffsetLow;
u16 Selector;
2012-04-21 18:06:00 +00:00
u8 Zero1;
u8 Type : 4;
u8 Zero2 : 1;
u8 DPL : 2;
u8 Present : 1;
u16 OffsetMiddle;
u32 OffsetHigh;
u32 Reserved;
2011-02-22 17:09:58 +00:00
} __attribute__ ((packed));
typedef struct S_IDT_ENTRY T_IDT_ENTRY;
enum E_INTERRUPTS_RING {
E_INTERRUPTS_RING0 = 0,
E_INTERRUPTS_RING1,
E_INTERRUPTS_RING2,
E_INTERRUPTS_RING3
};
typedef enum E_INTERRUPTS_RING T_INTERRUPTS_RING;
// This is a structure that allows easy access to a 62-byte ASM stub which
2011-02-22 17:09:58 +00:00
// calls a stdcall handler. Not the best way and not the shortest stub,
// but hey, it works.
struct S_ISR_STUB {
u64 Code1;
u64 Code2;
u64 Code3;
u16 Code4;
2011-06-28 11:15:42 +00:00
u64 Handler;
u64 Code5;
u64 Code6;
u64 Code7;
u32 Code8;
2011-02-22 17:09:58 +00:00
} __attribute__ ((packed));
typedef struct S_ISR_STUB T_ISR_STUB;
2011-03-16 07:33:27 +00:00
typedef struct {
u64 r15, r14, r13, r12, r11, r10, r9, r8, rdi, rsi, rbp, rdx, rcx, rbx, rax;
u64 Error;
2012-05-08 12:57:44 +00:00
u64 rip, cs, rflags, rsp, ss;
} __attribute__((packed)) T_ISR_REGISTERS_ERR;
2011-03-16 07:33:27 +00:00
typedef struct {
u64 r15, r14, r13, r12, r11, r10, r9, r8, rdi, rsi, rbp, rdx, rcx, rbx, rax;
2012-05-08 12:57:44 +00:00
u64 rip, cs, rflags, rsp, ss;
} __attribute ((packed)) T_ISR_REGISTERS;
2011-03-16 07:33:27 +00:00
2011-02-22 17:09:58 +00:00
u8 interrupts_init_idt(void);
void interrupts_setup_irq(u8 IRQ, void *Handler);
2011-04-02 14:46:31 +00:00
void interrupts_delete_isr(u8 Interrupt);
void interrupts_setup_isr_raw(u8 Interrupt, void *ASMHandler, \
T_INTERRUPTS_RING Ring);
2011-02-22 17:09:58 +00:00
void interrupts_setup_isr(u8 Interrupt, void *Handler, T_INTERRUPTS_RING Ring);
void interrupts_init_simple(void);
2011-02-23 03:12:36 +00:00
void interrupts_irq_finish(u8 IRQ);
2011-02-22 17:09:58 +00:00
void interrupts_lidt(void);
void interrupts_dump_idt_entry(u8 Interrupt);
void interrupts_dump_idt_ptr(void);
2011-03-16 07:33:27 +00:00
#endif