aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorNic Gaffney <gaffney_nic@protonmail.com>2023-12-10 09:48:53 -0600
committerNic Gaffney <gaffney_nic@protonmail.com>2023-12-10 09:48:53 -0600
commit8fcd0cf7d6a2c891422c7101840778043207a60d (patch)
tree5527b605fdaee1ad4404bef6418f1a5e34e31d52 /src/include
parent87d1e83a0ea5e20e535e3378e57f1fe0e9818a64 (diff)
downloadgftos-8fcd0cf7d6a2c891422c7101840778043207a60d.tar.gz
Changed to the based ASM syntax and implemented a rudementary GDT
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gdt.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/include/gdt.h b/src/include/gdt.h
new file mode 100644
index 0000000..05f426e
--- /dev/null
+++ b/src/include/gdt.h
@@ -0,0 +1,32 @@
+#pragma once
+#include <stdint.h>
+#define FLAG 0b1100
+typedef struct Segment_Descriptor {
+ uint16_t lim_low;
+ uint16_t base_low;
+ uint8_t base_mid;
+ uint8_t access;
+ uint8_t lim_flag;
+ uint8_t base_high;
+} __attribute__((packed)) Segment_Descriptor_t;
+
+typedef struct GDTR {
+ uint16_t size;
+ uint32_t offset;
+} __attribute__((packed)) GDTR_t;
+
+typedef struct GDT {
+ Segment_Descriptor_t nulldesc;
+ Segment_Descriptor_t codedesc;
+ Segment_Descriptor_t datadesc;
+} __attribute__((packed)) GDT_t;
+
+uint8_t make_access(uint8_t DPL, uint8_t type, uint8_t exec, uint8_t direction,
+ uint8_t read_write);
+
+uint16_t make_code(uint8_t priv, uint8_t dc, uint8_t rw);
+uint16_t make_data(uint8_t priv, uint8_t dc, uint8_t rw);
+
+Segment_Descriptor_t make_descriptor(uint32_t base, uint32_t limit,
+ uint16_t access_flag);
+void get_gdtr();