old-trainOS/include/interrupts.h

57 lines
1 KiB
C
Raw Permalink Normal View History

2015-08-09 00:42:56 +00:00
#pragma once
2015-08-13 12:56:50 +00:00
#include "cpustate.h"
#if defined(__cplusplus)
extern "C" {
#endif
2015-08-09 00:42:56 +00:00
#define GDTF_DATASEG 0x02
#define GDTF_CODESEG 0x0a
#define GDTF_TSS 0x09
#define GDTF_SEGMENT 0x10
#define GDTF_RING0 0x00
#define GDTF_RING3 0x60
#define GDTF_PRESENT 0x80
#define GDTF_4K_GRAN 0x800
#define GDTF_32_BIT 0x400
#define INTR_GATE 6
#define INTR_TRAP_GATE 7
#define INTR_TASK_GATE 5
2015-08-13 12:56:50 +00:00
typedef void (*InterruptHandler)(CpuState *);
2015-08-09 00:42:56 +00:00
/**
* Initializes interrupt handling and the global descriptor table.
*/
void intr_init();
2015-08-13 12:56:50 +00:00
/**
* @brief Sets the handler for the given interrupt.
* @param interrupt The number of the interrupt.
* @param handler The function that should handle this interrupt
*/
void intr_set_handler(uint32_t interrupt, InterruptHandler handler);
2015-08-09 00:42:56 +00:00
/**
* @brief Enables physical interrupts.
*/
static inline void irq_enable(void)
{
__asm__ volatile("sti");
}
/**
* @brief Disables physical interrupts.
*/
static inline void irq_disable(void)
{
__asm__ volatile("cli");
}
2015-08-13 12:56:50 +00:00
#if defined(__cplusplus)
}
#endif