aboutsummaryrefslogtreecommitdiff
path: root/kernel/include/boot
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-02-07 17:15:28 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-02-07 17:17:15 +0530
commitcca4e987ec30229a77a7cd4bf27c9d6670ad79db (patch)
tree1747ef03b987221e2c655f0fc42e1161a0e8958d /kernel/include/boot
parentd19eaaef708a51d1ac6a89a86c14745ad948e6c8 (diff)
IDT: Initialize IDT with a very basic exception handler that does nothing
Diffstat (limited to 'kernel/include/boot')
-rw-r--r--kernel/include/boot/gdt.h15
-rw-r--r--kernel/include/boot/idt.h55
2 files changed, 63 insertions, 7 deletions
diff --git a/kernel/include/boot/gdt.h b/kernel/include/boot/gdt.h
index ff87981..237628c 100644
--- a/kernel/include/boot/gdt.h
+++ b/kernel/include/boot/gdt.h
@@ -78,13 +78,12 @@
#define GDT_ENTRY(base, limit, access_flags, flags) \
{ \
- (limit & 0xffff), /* limit_low */ \
- (base & 0xffff), /* base_low */ \
- ((base >> 16) & 0xff), /* base_mid */ \
- access_flags, /* access_flags */ \
- FLAGS_LIMIT_HIGH(flags, \
- ((limit >> 16) & 0xff)), /* flags_limit_high */ \
- ((base >> 24) & 0xff) /* base_high */ \
+ (limit & 0xffff), /* limit_low */ \
+ (base & 0xffff), /* base_low */ \
+ ((base >> 16) & 0xff), /* base_mid */ \
+ access_flags, /* access_flags */ \
+ FLAGS_LIMIT_HIGH(flags, ((limit >> 16) & 0xff)), /* flags_limit_high */ \
+ ((base >> 24) & 0xff) /* base_high */ \
}
namespace GDT
@@ -105,6 +104,8 @@ typedef struct {
} PACKED descriptor_t;
extern "C" void _GDT_flush(descriptor_t *descriptor);
+
+void initialize(void);
void load(void);
}
diff --git a/kernel/include/boot/idt.h b/kernel/include/boot/idt.h
new file mode 100644
index 0000000..2eda86c
--- /dev/null
+++ b/kernel/include/boot/idt.h
@@ -0,0 +1,55 @@
+/*
+ * bubbl
+ * Copyright (C) 2024-2025 Raghuram Subramani <raghus2247@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __boot_idt_h
+#define __boot_idt_h
+
+#include <common.h>
+#include <stdint.h>
+
+#define IDT_ENTRY(isr, attributes) \
+ { \
+ (isr & 0xffff), /* isr_low */ \
+ 0, /* segment_selector */ \
+ 0, /* reserved */ \
+ attributes, /* attributes */ \
+ (isr >> 16) /* isr_high */ \
+ }
+
+namespace IDT
+{
+
+typedef struct {
+ uint16_t isr_low;
+ uint16_t segment_selector;
+ uint8_t reserved;
+ uint8_t attributes;
+ uint16_t isr_high;
+} PACKED entry_t;
+
+typedef struct {
+ uint16_t limit; /* sizeof(IDT) - 1 */
+ entry_t *ptr; /* Address of IDT */
+} PACKED descriptor_t;
+
+void load(void);
+extern "C" NORETURN void exception_handler(void);
+
+}
+
+#endif