Added IDT Logic (Didn't actually add any IDTs)

This commit is contained in:
2024-03-08 21:57:53 +01:00
parent 78135e4c7e
commit 861d843dcc
12 changed files with 83 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
#ifndef BOOL_H
#define BOOL_H
#define bool _Bool
#define true 1
#define false 0
#endif
+32
View File
@@ -0,0 +1,32 @@
#include "idt.h"
#include "stdint.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;
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;
}
+10
View File
@@ -0,0 +1,10 @@
#ifndef IDT_H
#define IDT_H
#include "stdint.h"
void setupIdt();
void idtSetGate(uint8_t i, uint32_t offset, uint16_t selector, uint8_t typeAttr);
#endif
Binary file not shown.
Binary file not shown.
+3 -1
View File
@@ -1,6 +1,8 @@
#include "screen.h" #include "screen.h"
#include "idt.h"
void main() { void main() {
print("Hello, World!", 0x0f); setupIdt();
print("kern.\n", 0x0f);
} }
Binary file not shown.
+21
View File
@@ -0,0 +1,21 @@
#ifndef STDINT_H
#define STDINT_H
#define NULL ((void*)0)
// Signed ints
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;
// Unsigned ints
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
// Other
typedef unsigned int size_t;
#endif
+3
View File
@@ -0,0 +1,3 @@
#include "system.h"
+6
View File
@@ -0,0 +1,6 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#endif
Binary file not shown.
Binary file not shown.