-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterrupt.h
50 lines (40 loc) · 997 Bytes
/
interrupt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdint.h>
#include <stdbool.h>
#include "asm_functions.h"
#ifndef INTERRUPT_H
#define INTERRUPT_H
struct InterruptDescriptor {
uint16_t offset_0_15;
uint16_t selector;
uint8_t ist:2;
uint8_t reserved0:6;
uint8_t type:4;
uint8_t zero:1;
uint8_t protection_level:2;
uint8_t present:1;
uint16_t offset_16_31;
uint32_t offset_32_64;
uint32_t reserved1;
} __attribute__ ((packed));
extern "C" void PIC_sendEOI(unsigned char irq);
void IRQ_set_mask(unsigned char IRQline);
void IRQ_clear_mask(unsigned char IRQline);
void register_isr(void (*isr_entry_pt)(void), uint8_t int_num);
bool init_interrupts();
static bool interrupts_enabled;
inline void sti() {
asm volatile ("sti" : : );
}
inline void cli() {
asm volatile ("cli" : : );
}
inline void cli_st() {
bool int_state = are_interrupts_enabled();
cli();
interrupts_enabled = int_state;
}
inline void sti_cond() {
if (interrupts_enabled)
sti();
}
#endif