kernel/inc/platform/interrupts.h

75 lines
1.7 KiB
C
Raw Normal View History

// This file is part of noxos and licensed under the MIT open source license
2023-02-05 13:39:35 +00:00
#ifndef NOX_INTERRUPTS_H
#define NOX_INTERRUPTS_H
#include "utils/stdtypes.h"
#define IDT_ENTRY_INTR_GATE 0b10001110
#define IDT_ENTRY_CALL_GATE 0b10001100
#define IDT_ENTRY_TRAP_GATE 0b10001111
#define PIC_MASTER_PORT 0x20
#define PIC_MASTER_COMMAND 0x20
#define PIC_MASTER_DATA 0x21
#define PIC_SLAVE_PORT 0xA0
#define PIC_SLAVE_COMMAND 0xA0
#define PIC_SLAVE_DATA 0xA1
#define PIC_END_OF_INTERRUPT 0x20
#define ICW1_ICW4 0x01
#define ICW1_INIT 0x10
#define ICW4_8086 0x01
#define IRQ_MASTER_OFFSET 0x20
#define IRQ_SLAVE_OFFSET 0x28
typedef enum {
// Master PIC
IRQ_PIT,
IRQ_KEYBOARD,
IRQ_CASCADE,
IRQ_COM2,
IRQ_COM1,
IRQ_LPT2,
IRQ_FLOPPY,
IRQ_SPURIOUS,
// Slave PIC
IRQ_CMOS_RTC,
IRQ_FREE_0,
IRQ_FREE_1,
IRQ_FREE_2,
IRQ_PS2_MOUSE,
IRQ_FPU,
IRQ_ATA_PRIMARY,
IRQ_ATA_SECONDARY
} pic_irq_E;
2023-02-05 13:39:35 +00:00
typedef struct {
uint16_t limit;
uint64_t offset;
} __attribute__((packed)) idt_register_T;
typedef struct {
uint16_t offset0;
uint16_t selector;
uint8_t ist;
uint8_t type_attribute;
uint16_t offset1;
uint32_t offset2;
uint32_t ignore;
} idt_descriptor_entry_T;
extern idt_register_T g_idt_register;
extern uint8_t g_handling_interrupt;
void idt_init ();
void pic_init ();
void pic_remap ();
void pic_send_end_of_interrupt (pic_irq_E irq);
void pic_mask_irq (pic_irq_E irq);
void pic_unmask_irq (pic_irq_E irq);
2023-02-05 13:39:35 +00:00
#endif //NOX_INTERRUPTS_H