-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupt.cpp
38 lines (32 loc) · 1.04 KB
/
interrupt.cpp
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
#include "interrupt.h"
void Interrupt::exec_interrupt(PIC *pic, Emulator *emu) {
if (pic->interrupt_queue.empty())
return;
if (emu->eflags.IF == 0){
fprintf(stderr, "tttttttttttttttttttttttt \n");
return;
}
fprintf(stderr, "vvvvvvvvvvvvvvvvvvvvvvvvv %x\n", emu->eflags.IF);
auto q = pic->interrupt_queue.front();
if(pic->IMR[q]){
fprintf(stderr, "sssssssssssssssssssssssss \n");
return;
}
pic->IMR[q] = true;
IntGateDesc idt;
uint32_t idt_base;
uint16_t idt_limit, idt_offset;
idt_offset = pic->INT[q];
pic->interrupt_queue.pop();
idt_base = emu->dtregs[IDTR].base_addr;
emu->read_data(&idt, idt_base + idt_offset * 8, sizeof(IntGateDesc));
save_regs(emu);
emu->EIP = (idt.offset_h << 16) + idt.offset_l;
emu->set_interrupt(false);
fprintf(stderr, "6666666666666666666666666 %x \n", emu->EIP);
}
void Interrupt::save_regs(Emulator *emu){
emu->Push32(emu->get_eflags());
emu->Push32(emu->sreg[1].sreg);
emu->Push32(emu->EIP);
}