wip: pic. sending to continue on main pc
This commit is contained in:
@@ -12,6 +12,8 @@ add_executable(kernel
|
||||
src/entry.asm
|
||||
src/asm/interrupts.asm
|
||||
src/kmain.c
|
||||
src/modules/io.c
|
||||
src/modules/pic.c
|
||||
src/modules/gdt.c
|
||||
src/modules/idt.c
|
||||
src/modules/interrupts.c
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef IO_H
|
||||
#define IO_H
|
||||
|
||||
static inline void outb(unsigned short port, unsigned char val) {
|
||||
__asm__ volatile(
|
||||
"outb %0, %1"
|
||||
@@ -16,3 +19,7 @@ static inline unsigned char inb(unsigned short port) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void io_wait();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef PIC_H
|
||||
#define PIC_H
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,6 @@
|
||||
#define PTE_GET_ADDR(entry) ((entry) & PTE_ADDR_MASK) // get physical address
|
||||
#define PTE_GET_FLAGS(entry) ((entry) & ~PTE_ADDR_MASK) // get flags
|
||||
|
||||
|
||||
#define VMM_PT_INDEX(virt) (((virt) >> 12) & 0x1FF) // Table Index (bits 12-20)
|
||||
#define VMM_PD_INDEX(virt) (((virt) >> 21) & 0x1FF) // Page Directory Index (bits 21-29)
|
||||
#define VMM_PDPT_INDEX(virt) (((virt) >> 30) & 0x1FF) // PDPT Index (bits 30-38)
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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