Rework architecture
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
1 parent
7ceec0ee06
commit
ac1b1f5376
8 files changed
+9
-7
No files matched your search
@@ -0,0 +1,54 @@
|
||||
#include "events/idt.h"
|
||||
#include "io.h"
|
||||
#include "pic.h"
|
||||
#include "stdio.h"
|
||||
|
||||
static void send_icw1(void)
|
||||
{
|
||||
outb(MASTER_PIC_A, ICW1);
|
||||
outb(SLAVE_PIC_A, ICW1);
|
||||
}
|
||||
|
||||
static void send_icw2(void)
|
||||
{
|
||||
outb(MASTER_PIC_B, IDT_RESERVED_ENTRIES);
|
||||
outb(SLAVE_PIC_B, IDT_RESERVED_ENTRIES + 8);
|
||||
}
|
||||
|
||||
static void send_icw3(void)
|
||||
{
|
||||
outb(MASTER_PIC_B, 0x4);
|
||||
outb(SLAVE_PIC_B, 0x2);
|
||||
}
|
||||
|
||||
|
||||
static void send_icw4(void)
|
||||
{
|
||||
outb(MASTER_PIC_B, 0x1);
|
||||
outb(SLAVE_PIC_B, 0x1);
|
||||
}
|
||||
|
||||
static void mask_irqs(void)
|
||||
{
|
||||
outb(MASTER_PIC_B, 0xff ^ 0x2);
|
||||
outb(SLAVE_PIC_B, 0xff);
|
||||
}
|
||||
|
||||
void init_pic(void)
|
||||
{
|
||||
send_icw1();
|
||||
send_icw2();
|
||||
send_icw3();
|
||||
send_icw4();
|
||||
mask_irqs();
|
||||
asm volatile("sti");
|
||||
}
|
||||
|
||||
void acknowledge(uint32_t int_vector)
|
||||
{
|
||||
printf("acknowledging %d\r\n", int_vector);
|
||||
uint8_t ocw2 = 0x20;
|
||||
if (int_vector >= IDT_RESERVED_ENTRIES + 8)
|
||||
outb(SLAVE_PIC_A, ocw2);
|
||||
outb(MASTER_PIC_A, ocw2);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef PIC_H
|
||||
#define PIC_H
|
||||
|
||||
#define MASTER_PIC_A 0x20
|
||||
#define MASTER_PIC_B 0x21
|
||||
#define SLAVE_PIC_A 0xa0
|
||||
#define SLAVE_PIC_B 0xa1
|
||||
|
||||
#define ICW1 0x11
|
||||
|
||||
void init_pic(void);
|
||||
void acknowledge(uint32_t int_vector);
|
||||
|
||||
#endif /* !PIC_H */
|
||||