aboutsummaryrefslogtreecommitdiff
path: root/arch/i686/gdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i686/gdt.c')
-rw-r--r--arch/i686/gdt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/i686/gdt.c b/arch/i686/gdt.c
new file mode 100644
index 0000000..fe0bfc9
--- /dev/null
+++ b/arch/i686/gdt.c
@@ -0,0 +1,20 @@
+#include <gdt.h>
+
+void
+SegmentDescriptor(struct SegmentDescriptor_t *self, unsigned base, unsigned limit, uint8_t access)
+{
+ self->base_15_0 = base & 0xffff;
+ self->base_23_16 = (base >> 16) & 0xff;
+ self->base_31_24 = (base >> 24) & 0xff;
+
+ self->limit_15_0 = (limit <= 0xffff) ? (limit & 0xffff) : ((limit >> 12) & 0xffff);
+ self->limit_19_16 = (limit <= 0xffff) ? 0 : ((limit >> 28) & 0xf);
+
+ self->access = access;
+
+ self->a = 0;
+ self->rsv = 0;
+ self->db = (limit > 0xffff) ? 1 : 0;
+ self->granularity = (limit > 0) ? 1 : 0;
+}
+