wip: pic. sending to continue on main pc
This commit is contained in:
@@ -6,20 +6,20 @@
|
||||
#include "types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#define COLOR_RED 0xFF5555
|
||||
#define COLOR_VERYRED 0xFF0000
|
||||
#define COLOR_GREEN 0x08bf39
|
||||
#define COLOR_RED 0xFF5555
|
||||
#define COLOR_VERYRED 0xFF0000
|
||||
#define COLOR_GREEN 0x08bf39
|
||||
#define COLOR_VERYGREEN 0x00FF00
|
||||
#define COLOR_TURQUOISE 0x5effaf
|
||||
#define COLOR_BLUE 0x5555FF
|
||||
#define COLOR_VERYBLUE 0x0000FF
|
||||
#define COLOR_BLUE 0x5555FF
|
||||
#define COLOR_VERYBLUE 0x0000FF
|
||||
#define COLOR_LIGHTBLUE 0x3890e8
|
||||
#define COLOR_YELLOW 0xFFFF55
|
||||
#define COLOR_CYAN 0x55FFFF
|
||||
#define COLOR_MAGENTA 0xFF55FF
|
||||
#define COLOR_BLACK 0x000000
|
||||
#define COLOR_WHITE 0xFFFFFF
|
||||
#define COLOR_PINK 0xFFA3B1
|
||||
#define COLOR_YELLOW 0xFFFF55
|
||||
#define COLOR_CYAN 0x55FFFF
|
||||
#define COLOR_MAGENTA 0xFF55FF
|
||||
#define COLOR_BLACK 0x000000
|
||||
#define COLOR_WHITE 0xFFFFFF
|
||||
#define COLOR_PINK 0xFFA3B1
|
||||
|
||||
static SG_Context *ctx_ptr = nullptr;
|
||||
static SG_Point s_cursor_pos = {0};
|
||||
|
||||
@@ -72,4 +72,4 @@ void idt_init() {
|
||||
idt[14].ist = 1;
|
||||
|
||||
__asm__ volatile ("lidt %0" : : "m"(idt_ptr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "io.h"
|
||||
|
||||
// sending junk to unused port letting cpu skipping few tacts.
|
||||
// not ideal i know.
|
||||
void io_wait() {
|
||||
outb(0x80, 0x0);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "pic.h"
|
||||
#include "io.h"
|
||||
#include "types.h"
|
||||
|
||||
#define MASTER_COMMAND 0x20
|
||||
#define MASTER_DATA 0x21
|
||||
#define SLAVE_COMMAND 0xA0
|
||||
#define SLAVE_DATA 0xA1
|
||||
|
||||
static inline void send(unsigned short port, unsigned char val) {
|
||||
outb(port, val);
|
||||
io_wait();
|
||||
}
|
||||
|
||||
void pic_remap() {
|
||||
u64 curr_master = inb(MASTER_DATA);
|
||||
u64 curr_slave = inb(SLAVE_DATA);
|
||||
|
||||
// initialization
|
||||
send(MASTER_COMMAND, 0x11);
|
||||
send(SLAVE_COMMAND, 0x11);
|
||||
|
||||
send(MASTER_DATA, 0x20); // master now controlling idt[32..39]
|
||||
send(SLAVE_DATA, 0x28); // idt[40..47]
|
||||
|
||||
send(MASTER_DATA, 0x04); // slave on irq2
|
||||
send(SLAVE_DATA, 0x02); // assign id = 2 to slave
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user