This commit is contained in:
Mathieu Maret 2018-07-18 01:41:10 +02:00
parent 37d772d1c7
commit 9756f3f3ce
3 changed files with 20 additions and 5 deletions

View File

@ -1,11 +1,13 @@
#include "interrupt.h"
#include "vga.h"
#include "io.h"
#include "pic.h"
#include "irq.h"
// Need GCC > 6
__attribute__((interrupt)) void keyboard_handler(struct interrupt_frame *frame)
{
printString("Keyboard!", RED, BLACK, 0, 7);
EOIIrq(IRQ_KEYBOARD);
char c = 0;
if (inb(0x60) != c) {
c = inb(0x60);
@ -17,6 +19,8 @@ __attribute__((interrupt)) void keyboard_handler(struct interrupt_frame *frame)
__attribute__((interrupt)) void timer_handler(struct interrupt_frame *frame)
{
printString("Timer!", RED, BLACK, 0, 9);
static int timeCnt = 0;
EOIIrq(IRQ_TIMER);
printInt(timeCnt++, RED, BLACK, 0, 9);
(void)frame;
}

8
pic.c
View File

@ -42,6 +42,14 @@ void initPic(void)
outb(PIC_SLAVE_DATA, 0xFF);
}
void EOIIrq(int irq)
{
if (irq >= 8)
outb(PIC_SLAVE_CMD, PIC_EOI);
outb(PIC_MASTER_CMD, PIC_EOI);
}
void disableIrq(int irq)
{
if (irq < 8) {

3
pic.h
View File

@ -12,7 +12,10 @@
#define PIC_SLAVE_CMD 0xa0
#define PIC_MASTER_DATA 0x21
#define PIC_SLAVE_DATA 0xa1
#define PIC_EOI 0x20 /* End-of-interrupt command code */
void EOIIrq(int irq);
void initPic(void);
void enableIrq(int irq);
void disableIrq(int irq);