summaryrefslogtreecommitdiff
path: root/Source/Kernel/MemoryManager/GDT.ns.h
blob: d42587f282db520a1a8f6f75c8432bb49f163393 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef DEF_GDT_NS_H
#define DEF_GDT_NS_H

#include <common.h>

namespace GDT {
	struct gdt_entry_t {
		u16int limit_low;
		u16int base_low;
		u8int base_middle;
		u8int access;
		u8int granularity;
		u8int base_high;
	} __attribute__((packed));

	// A struct describing a Task State Segment.
	struct tss_entry_t {
		u32int prev_tss;   // The previous TSS - if we used hardware task switching this would form a linked list.
		u32int esp0;       // The stack pointer to load when we change to kernel mode.
		u32int ss0;        // The stack segment to load when we change to kernel mode.
		u32int esp1;       // Unused...
		u32int ss1;
		u32int esp2;
		u32int ss2;
		u32int cr3;
		u32int eip;
		u32int eflags;
		u32int eax;
		u32int ecx;
		u32int edx;
		u32int ebx;
		u32int esp;
		u32int ebp;
		u32int esi;
		u32int edi;
		u32int es;         // The value to load into ES when we change to kernel mode.
		u32int cs;         // The value to load into CS when we change to kernel mode.
		u32int ss;         // The value to load into SS when we change to kernel mode.
		u32int ds;         // The value to load into DS when we change to kernel mode.
		u32int fs;         // The value to load into FS when we change to kernel mode.
		u32int gs;         // The value to load into GS when we change to kernel mode.
		u32int ldt;        // Unused...
		u16int trap;
		u16int iomap_base;
		u8int ioports[8192];
	} __attribute__((packed));

	struct gdt_ptr_t {
		u16int limit;
		u32int base;
	} __attribute__((packed));

	void init();
	extern tss_entry_t tss_entry;	//Used for setting kernel stack
}

#endif