Commit 9756f3f3 authored by Mathieu Maret's avatar Mathieu Maret

Fix irq

parent 37d772d1
#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;
}
......@@ -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) {
......
#pragma once
//2 PIC 8259 are available on x86
// 2 PIC 8259 are available on x86
//
// Master - command: 0x20, data: 0x21
// Slave - command: 0xA0, data: 0xA1
......@@ -9,10 +9,13 @@
// http://wiki.osdev.org/PIC
#define PIC_MASTER_CMD 0x20
#define PIC_SLAVE_CMD 0xa0
#define PIC_SLAVE_CMD 0xa0
#define PIC_MASTER_DATA 0x21
#define PIC_SLAVE_DATA 0xa1
#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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment