Big code refactor, get rid of HAL entirely
This commit is contained in:
46
kernel/intr/pic.c
Normal file
46
kernel/intr/pic.c
Normal file
@ -0,0 +1,46 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user