forked from PoliEcho-holding-org/kern
Got IDT & ISRs working!
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#ifndef _IDT_H
|
||||
#define _IDT_H
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#define IDT_ENTRIES 256
|
||||
#define IDT_FLAG_TRAP 0x8f // P = 1, Priv = 00, S = 0, Type = 1111 (32-bit trap)
|
||||
#define IDT_FLAG_INT 0x8e // P = 1, Priv = 00, S = 0, Type = 1110 (32-bit int)
|
||||
#define IDT_FLAG_USER 0xee // P = 1, Priv = 11, S = 0, Type = 1110 (32-bit int)
|
||||
|
||||
struct idt_entry {
|
||||
uint16_t offsetLow;
|
||||
uint16_t selector;
|
||||
uint8_t __unused;
|
||||
uint8_t flags;
|
||||
uint16_t offsetHigh;
|
||||
} __packed;
|
||||
|
||||
struct idt_pointer {
|
||||
uint16_t limit;
|
||||
uint32_t base;
|
||||
} __packed;
|
||||
|
||||
int idt_init(void);
|
||||
void idt_setGate(uint8_t i, void* handler, uint8_t flags);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef _ISR_H
|
||||
#define _ISR_H
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
// Interrupt frame (ie. what's on the stack on interrupt)
|
||||
struct isr_intFrame {
|
||||
// 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;
|
||||
};
|
||||
typedef void (*isr_handlerPtr)(struct isr_intFrame* iframe);
|
||||
|
||||
int isr_init(void);
|
||||
void isr_registerIRQ(uint8_t i, isr_handlerPtr handler);
|
||||
int isr_handleInterrupt(struct isr_intFrame iframe);
|
||||
|
||||
// Assembly definitions (isr.s)
|
||||
extern void* isr_redirectTable[48]; // ISR Table
|
||||
extern void isr128(); // int 0x80 - syscall
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _SYSCALL_H
|
||||
#define _SYSCALL_H
|
||||
|
||||
#include <isr.h>
|
||||
|
||||
int syscallHandler(struct isr_intFrame* iframe) { return 1; }
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,8 @@
|
||||
void cpuid(uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx);
|
||||
|
||||
// Ports
|
||||
uint8_t inb(uint16_t port);
|
||||
void iowait(void);
|
||||
uint8_t inb(uint16_t port);
|
||||
void outb(uint16_t port, uint8_t data);
|
||||
uint16_t inw(uint16_t port);
|
||||
void outw(uint16_t port, uint16_t data);
|
||||
|
||||
Reference in New Issue
Block a user