E. Almqvist 3 years ago
parent 33ca252719
commit 7f90abb200
  1. 3
      kernel/io.c
  2. 2
      kernel/io.h
  3. 8
      kernel/pic.c
  4. 30
      kernel/pic.h

@ -24,3 +24,6 @@ unsigned short port_inw(unsigned short port) {
void port_outw(unsigned short port, unsigned short data) { void port_outw(unsigned short port, unsigned short data) {
__asm__("out %%ax, %%dx" : :"a" (data), "d" (port)); __asm__("out %%ax, %%dx" : :"a" (data), "d" (port));
} }
static inline void io_wait() { port_outb(0x80, 0); }

@ -3,3 +3,5 @@ void port_outb();
unsigned short port_inw(); unsigned short port_inw();
void port_outw(); void port_outw();
static inline void io_wait();

@ -0,0 +1,8 @@
#include "pic.h"
void PIC_sendEOI(uint8 irq) {
if( irq >= 8 )
port_outb(PIC2_CMD, PIC_EOI);
port_outb(PIC1_CMD, PIC_EOI);
}

@ -0,0 +1,30 @@
#include "../lib/types.h"
#include "io.h"
// master
#define PIC1 0x20
#define PIC1_CMD PIC1
#define PIC1_DATA (PIC1+1)
// slave
#define PIC2 0xa0
#define PIC2_CMD PIC2
#define PIC2_DATA (PIC2+1)
#define ICW1_ICW4 0x01
#define ICW1_SINGLE 0x02
#define ICW1_INTERVAL4 0x04
#define ICW1_LEVEL 0x08
#define ICW1_INIT 0x10
#define ICW4_8086 0x01
#define ICW4_AUTO 0x02
#define ICW4_BUF_SLAVE 0x08
#define ICW4_BUF_MASTER 0x0C
#define ICW4_SFNM 0x10
// Ints
#define PIC_EOI 0x20 // End-of-interupt
void PIC_sendEOI(uint8);
void PIC_remap(uint, uint);
Loading…
Cancel
Save