Kernel: IRQs are now working :)
This commit is contained in:
@@ -2,26 +2,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
union GateDescriptor
|
||||
constexpr uint8_t IRQ_VECTOR_BASE = 0x50;
|
||||
|
||||
namespace IDT
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16_t offset_lo;
|
||||
uint16_t selector;
|
||||
uint8_t reserved;
|
||||
uint8_t type : 4;
|
||||
uint8_t zero : 1;
|
||||
uint8_t dpl : 2;
|
||||
uint8_t present : 1;
|
||||
uint16_t offset_hi;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t low;
|
||||
uint32_t high;
|
||||
};
|
||||
|
||||
} __attribute__((packed));
|
||||
void initialize();
|
||||
void register_irq_handler(uint8_t irq, void (*f)());
|
||||
|
||||
void idt_initialize();
|
||||
}
|
||||
25
kernel/include/kernel/IO.h
Normal file
25
kernel/include/kernel/IO.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace IO
|
||||
{
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t val)
|
||||
{
|
||||
asm volatile("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint8_t inb(uint16_t port)
|
||||
{
|
||||
uint8_t ret;
|
||||
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void io_wait()
|
||||
{
|
||||
outb(0x80, 0);
|
||||
}
|
||||
|
||||
}
|
||||
15
kernel/include/kernel/PIC.h
Normal file
15
kernel/include/kernel/PIC.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace PIC
|
||||
{
|
||||
|
||||
void initialize();
|
||||
void eoi(uint8_t);
|
||||
void unmask(uint8_t);
|
||||
void mask(uint8_t);
|
||||
|
||||
uint16_t get_isr();
|
||||
|
||||
}
|
||||
12
kernel/include/kernel/PIT.h
Normal file
12
kernel/include/kernel/PIT.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace PIT
|
||||
{
|
||||
|
||||
uint64_t ms_since_boot();
|
||||
|
||||
void initialize();
|
||||
|
||||
}
|
||||
8
kernel/include/kernel/PS2.h
Normal file
8
kernel/include/kernel/PS2.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace PS2
|
||||
{
|
||||
|
||||
void initialize();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user