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
|
#include <yotk32.h>
typedef struct registers
{
long ds;
long edi, esi, ebp, esp, ebx, edx, ecx, eax;
long int_no, err_code;
long eip, cs, eflags, useresp, ss;
} registers_t;
void int_isr_handler(registers_t regs){
chv_putchar(regs.int_no);
chv_sync_cursor();
}
void timer_sleep_msg(void){
static int count = 0;
count++;
if(count % 100 == 0){
putstr("...");
putint(count / 100);
chv_sync_cursor();
}
}
void int_irq_handler(registers_t regs){
asm(".intel_syntax noprefix\n");
if(regs.int_no > 31 + 8){ /* Send reset signal to slave PIC (PIC2) */
asm volatile(
"mov dx, 0xA0\n"
"mov al, 0x20\n"
"out dx, al");
}
/* Send reset signal to master PIC (PIC1) */
asm volatile(
"mov dx, 0x20\n"
"mov al, 0x20\n"
"out dx, al");
if(regs.int_no == 32){ /* IRQ0 == Timer */
timer_sleep_msg();
}
}
|