Renaming/Moving stuff into a different file structure
This commit is contained in:
62
src/kernel/pic/pic.cpp
Normal file
62
src/kernel/pic/pic.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "pic.h"
|
||||
|
||||
extern "C" void PIC_sendEOI (unsigned char irq){
|
||||
if(irq >= 8)
|
||||
outb(PIC2_COMMAND, PIC_EOI);
|
||||
outb(PIC1_COMMAND, PIC_EOI);
|
||||
}
|
||||
|
||||
/* Helper func */
|
||||
static uint16_t __pic_get_irq_reg(int ocw3)
|
||||
{
|
||||
/* OCW3 to PIC CMD to get the register values. PIC2 is chained, and
|
||||
* represents IRQs 8-15. PIC1 is IRQs 0-7, with 2 being the chain */
|
||||
outb(PIC1_COMMAND, ocw3);
|
||||
outb(PIC2_COMMAND, ocw3);
|
||||
return (inb(PIC2_COMMAND) << 8) | inb(PIC1_COMMAND);
|
||||
}
|
||||
|
||||
/* Returns the combined value of the cascaded PICs irq request register */
|
||||
uint16_t pic_get_irr(void)
|
||||
{
|
||||
return __pic_get_irq_reg(PIC_READ_IRR);
|
||||
}
|
||||
|
||||
/* Returns the combined value of the cascaded PICs in-service register */
|
||||
uint16_t pic_get_isr(void)
|
||||
{
|
||||
return __pic_get_irq_reg(PIC_READ_ISR);
|
||||
}
|
||||
|
||||
|
||||
void PIC_remap (int offset1, int offset2 ){
|
||||
unsigned char a1, a2;
|
||||
|
||||
a1 = inb(PIC1_DATA);
|
||||
a2 = inb(PIC2_DATA);
|
||||
|
||||
|
||||
// Start initialization
|
||||
|
||||
outb(PIC1_COMMAND, ICW1_INIT | ICW1_ICW4);
|
||||
io_wait();
|
||||
outb(PIC2_COMMAND, ICW1_INIT | ICW1_ICW4);
|
||||
io_wait();
|
||||
outb(PIC1_DATA, offset1);
|
||||
io_wait();
|
||||
outb(PIC2_DATA, offset2);
|
||||
io_wait();
|
||||
outb(PIC1_DATA, 4);
|
||||
io_wait();
|
||||
outb(PIC2_DATA, 2);
|
||||
io_wait();
|
||||
|
||||
outb(PIC1_DATA, ICW4_8086);
|
||||
io_wait();
|
||||
outb(PIC2_DATA, ICW4_8086);
|
||||
io_wait();
|
||||
|
||||
outb(PIC1_DATA, a1);
|
||||
outb(PIC2_DATA, a2);
|
||||
|
||||
}
|
Reference in New Issue
Block a user