mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Added IDT Logic (Didn't actually add any IDTs)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#ifndef BOOL_H
|
||||
#define BOOL_H
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,6 +1,8 @@
|
||||
#include "screen.h"
|
||||
#include "idt.h"
|
||||
|
||||
void main() {
|
||||
print("Hello, World!", 0x0f);
|
||||
setupIdt();
|
||||
print("kern.\n", 0x0f);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "system.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user