mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 02:23:10 +00:00
MAJOR RESTRUCTURE
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#ifndef _CPU_IDT_H
|
||||
#define _CPU_IDT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define IDT_ENTRIES 256
|
||||
|
||||
#define TRAP_GATE_FLAGS 0x8f // P = 1, DPL = 00, S = 0, Type = 1111 (32-bit Trap gate)
|
||||
#define INT_GATE_FLAGS 0x8e // P = 1, DPL = 00, S = 0, Type = 1110 (32-bit Int gate)
|
||||
#define USR_INT_GATE_FLAGS 0xee // P = 1, DPL = 11, S = 0, Type = 1110 (32-bit Int gate)
|
||||
|
||||
typedef struct {
|
||||
uint16_t offsetLow;
|
||||
uint16_t selector;
|
||||
uint8_t zero;
|
||||
uint8_t typeAttr;
|
||||
uint16_t offsetHigh;
|
||||
} __attribute__ ((packed)) idtEntry_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t limit;
|
||||
uint32_t base;
|
||||
} __attribute__ ((packed)) idtp_t;
|
||||
|
||||
void idtSetGate(uint8_t i, void* handler, uint8_t flags);
|
||||
void setupIdt();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef _CPU_ISR_H
|
||||
#define _CPU_ISR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
// Pushed by OS
|
||||
uint32_t esp, ebx, ecx, edx, esi, edi, ebp;
|
||||
uint32_t ds, es, fs, gs, eax;
|
||||
uint32_t interrupt, error;
|
||||
|
||||
// Pushed by CPU
|
||||
uint32_t eip, cs, eflags, user_esp, user_ss;
|
||||
} intFrame_t;
|
||||
typedef void (*HandlerPtr)(intFrame_t* iframe);
|
||||
|
||||
void setupIsrs();
|
||||
void registerIrq(uint8_t id, HandlerPtr handler);
|
||||
int handleInterrupt(intFrame_t iframe);
|
||||
|
||||
// ISR Table
|
||||
extern void* asm_isrRedirectTable[48];
|
||||
|
||||
// Int 0x80 - Syscall
|
||||
extern void isr128();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _CPU_SYSTEM_H
|
||||
#define _CPU_SYSTEM_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void cpuid(uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx);
|
||||
|
||||
void outb(uint16_t port, uint8_t data);
|
||||
void outw(uint16_t port, uint16_t data);
|
||||
void outl(uint16_t port, uint32_t data);
|
||||
|
||||
uint8_t inb(uint16_t port);
|
||||
uint16_t inw(uint16_t port);
|
||||
uint32_t inl(uint16_t port);
|
||||
|
||||
void ioWait();
|
||||
void panic();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user