forked from PoliEcho-holding-org/kern
Moved all header files into include/ and removed their C counterparts -> code inside .h files Also added a kernel.ld linker file since we don't have many code files in src/ now, i removed src/kernel/ only real code change is that i moved memcopy() and memset() into string.h from system.h
50 lines
1.0 KiB
C
50 lines
1.0 KiB
C
#ifndef IDT_H
|
|
#define IDT_H
|
|
|
|
#include "stdint.h"
|
|
#include "system.h"
|
|
|
|
struct idtEntry {
|
|
uint16_t offsetLow;
|
|
uint16_t selector;
|
|
uint8_t zero;
|
|
uint8_t typeAttr;
|
|
uint16_t offsetHigh;
|
|
} __attribute__((packed));
|
|
|
|
struct idtPointer {
|
|
uint16_t limit;
|
|
uint32_t base;
|
|
} __attribute__((packed));
|
|
|
|
struct idtEntry idt[256] = { 0 };
|
|
struct idtPointer idtp;
|
|
|
|
extern void idtLoad();
|
|
|
|
void idtSetGate(uint8_t i, uint32_t offset, uint16_t selector, uint8_t typeAttr) {
|
|
idt[i].offsetLow = (uint16_t)offset;
|
|
idt[i].selector = selector;
|
|
idt[i].zero = 0;
|
|
idt[i].typeAttr = typeAttr;
|
|
idt[i].offsetHigh = (uint16_t)(offset >> 16);
|
|
}
|
|
|
|
void setupIdt() {
|
|
idtp.limit = sizeof(struct idtEntry) * 256;
|
|
idtp.base = (uint32_t)&idt;
|
|
|
|
idtLoad();
|
|
}
|
|
|
|
// Contains values of registers and exception info from isrs
|
|
struct regs {
|
|
unsigned int gs, fs, es, ds;
|
|
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
|
|
unsigned int intNo, errCode;
|
|
unsigned int eip, cs, eflags, useresp, ss;
|
|
};
|
|
|
|
#endif
|
|
|