47 lines
950 B
C
47 lines
950 B
C
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include "io/io.h"
|
|
#include "intr/pic.h"
|
|
#include "intr/intr.h"
|
|
|
|
#define PIC1_CMD 0x0020
|
|
#define PIC1_DATA 0x0021
|
|
#define PIC2_CMD 0x00A0
|
|
#define PIC2_DATA 0x00A1
|
|
|
|
#define PIC_EOI 0x20
|
|
|
|
#define ICW1_ICW4 0x01
|
|
#define ICW1_SINGLE 0x02
|
|
#define ICW1_ADI 0x04
|
|
#define ICW1_LTIM 0x08
|
|
#define ICW1_INIT 0x10
|
|
|
|
#define ICW4_8086 0x01
|
|
#define ICW4_AUTO 0x02
|
|
#define ICW4_BUFSLAVE 0x04
|
|
#define ICW4_BUFMASTER 0x0C
|
|
#define ICW4_SFNM 0x10
|
|
|
|
void intr_pic_init(void) {
|
|
io_out8(PIC1_CMD, ICW1_INIT | ICW1_ICW4);
|
|
io_out8(PIC2_CMD, ICW1_INIT | ICW1_ICW4);
|
|
|
|
io_out8(PIC1_DATA, INTR_IRQBASE);
|
|
io_out8(PIC2_DATA, INTR_IRQBASE+8);
|
|
|
|
io_out8(PIC1_DATA, 2);
|
|
io_out8(PIC2_DATA, 2);
|
|
|
|
io_out8(PIC1_DATA, ICW4_8086);
|
|
io_out8(PIC2_DATA, ICW4_8086);
|
|
|
|
io_out8(PIC1_DATA, 0);
|
|
io_out8(PIC2_DATA, 0);
|
|
}
|
|
|
|
void intr_pic_eoi(void) {
|
|
io_out8(PIC2_CMD, PIC_EOI);
|
|
io_out8(PIC1_CMD, PIC_EOI);
|
|
}
|