43 #include "maldefines.h" 76 #define GRANULARITY_1 0 77 #define GRANULARITY_4096 1 87 #define SEG_DATA_READONLY_EXPANDUP_TYPE 0b0000 88 #define SEG_DATA_READWRITE_EXPANDUP_TYPE 0b0010 89 #define SEG_DATA_READONLY_EXPANDDOWN_TYPE 0b0100 90 #define SEG_DATA_READWRITE_EXPANDDOWN_TYPE 0b0110 92 #define SEG_CODE_EXECONLY_NONCONFORMING_TYPE 0b1000 93 #define SEG_CODE_EXECREAD_NONCONFORMING_TYPE 0b1010 94 #define SEG_CODE_EXECONLY_CONFORMING_TYPE 0b1100 95 #define SEG_CODE_EXECREAD_CONFORMING_TYPE 0b1110 104 unsigned offset_low : 16;
105 unsigned segment : 16;
107 unsigned reserved : 3;
112 unsigned offset_high : 16;
115 #define GDT_CALLGATE_TYPE 0b1100 143 #define GDT_TSS_INACTIVE_TYPE 0b1001 //inactive task 144 #define GDT_TSS_BUSY_TYPE 0b1011 //running or suspended task (interrupted state) unsigned ds
Segment selector DS (prior to task switch)
Definition: gdt.h:201
unsigned es
Segment selector ES (prior to task switch)
Definition: gdt.h:195
Pointer to the GDT.
Definition: gdt.h:161
unsigned esp2
Ring-2 ESP (static)
Definition: gdt.h:181
unsigned eip
Execution pointer (prior to task switch)
Definition: gdt.h:185
unsigned int base
Base address.
Definition: gdt.h:164
unsigned ss
Segment selector SS (prior to task switch)
Definition: gdt.h:199
unsigned reserved4
Definition: gdt.h:196
unsigned reserved0
Definition: gdt.h:174
unsigned base_high
Definition: gdt.h:140
unsigned ebx
General register EBX (prior to task switch)
Definition: gdt.h:190
uint32_t zero(void)
Returns zero.
Definition: armv7/MAL/malinternal.c:79
unsigned fs
Segment selector FS (prior to task switch)
Definition: gdt.h:203
unsigned cr3
Page directory address (static)
Definition: gdt.h:184
unsigned trap
Flag to raise an exception when a task switch to this task occurs (static)
Definition: gdt.h:209
unsigned edi
General register EDI (prior to task switch)
Definition: gdt.h:194
unsigned type
See below defines.
Definition: gdt.h:64
callgate_descriptor_t callgate_desc
Definition: gdt.h:150
unsigned s
0 => system segment, 1 => code or data segment (see 3/)
Definition: gdt.h:65
Meant to be written inside the GDT. Provides the processor with the size and location of a segment...
Definition: gdt.h:59
unsigned edx
General register EDX (prior to task switch)
Definition: gdt.h:189
unsigned reserved9
Definition: gdt.h:206
unsigned reserved2
Definition: gdt.h:180
unsigned avl
Available for use by system software.
Definition: gdt.h:69
unsigned reserved10
Definition: gdt.h:208
unsigned reserved6
Definition: gdt.h:200
unsigned ss2
Ring-2 stack segment (static)
Definition: gdt.h:182
unsigned cs
Segment selector CS (prior to task switch)
Definition: gdt.h:197
unsigned eax
General register EAX (prior to task switch)
Definition: gdt.h:187
A callgate descriptor for the GDT/LDT Intel 64 and IA-32 Architectures Software Developer's Manual -...
Definition: gdt.h:103
unsigned prev_tss
Pointer to the previous TSS entry (updated on a task switch)
Definition: gdt.h:173
segment_descriptor_t segment_desc
Definition: gdt.h:149
unsigned base_middle
Middle bits of base address (bits 23..16)
Definition: gdt.h:63
unsigned reserved11
Definition: gdt.h:210
unsigned granularity
granularity (see 2/ in above comment)
Definition: gdt.h:72
unsigned reserved7
Definition: gdt.h:202
tss_descriptor_t tss_desc
Definition: gdt.h:151
unsigned ss0
Kernel-mode stack segment (static)
Definition: gdt.h:176
unsigned ss1
Ring-1 stack segment (static)
Definition: gdt.h:179
unsigned iomap_base
IOMMU base.
Definition: gdt.h:211
unsigned reserved1
Definition: gdt.h:177
unsigned base_high
Higher bits of base address (bits 31..24)
Definition: gdt.h:73
unsigned reserved3
Definition: gdt.h:183
unsigned ecx
General register ECX (prior to task switch)
Definition: gdt.h:188
unsigned short limit
Address limit.
Definition: gdt.h:163
unsigned esp1
Ring-1 ESP (static)
Definition: gdt.h:178
struct gdt_ptr __attribute__((packed))
void setKernelStack(uint32_t stack)
Updates the kernel stack address into the TSS.
Definition: gdt.c:201
unsigned esi
General register ESI (prior to task switch)
Definition: gdt.h:193
Task State Segment structure .
Definition: gdt.h:172
unsigned eflags
CPU flags (prior to task switch)
Definition: gdt.h:186
unsigned ldt
Pointer to the LDT (static)
Definition: gdt.h:207
unsigned dpl
Descriptor privilege level.
Definition: gdt.h:66
unsigned d_b
default operation size (0 => 16-bit, 1 => 32-bit)
Definition: gdt.h:71
unsigned limit_high
Higher bits of the size of the segment (bits 19..16)
Definition: gdt.h:68
unsigned ebp
User-mode EBP (prior to task switch)
Definition: gdt.h:192
void gdt_init()
Installs the GDT into the CPU.
Definition: gdt.c:262
unsigned gs
Segment selector GS (prior to task switch)
Definition: gdt.h:205
unsigned reserved8
Definition: gdt.h:204
unsigned esp
User-mode ESP (prior to task switch)
Definition: gdt.h:191
unsigned present
Preset flag (validity of descriptor)
Definition: gdt.h:67
unsigned reserved5
Definition: gdt.h:198
uint64_t null_desc
Definition: gdt.h:152
unsigned esp0
Kernel-mode ESP (static)
Definition: gdt.h:175
tss_t tss
Generic TSS for userland-to-kernel switch.
Definition: gdt.c:47
unsigned limit_low
Lower bits of the size of the segment (bits 15..0)
Definition: gdt.h:61
unsigned l
Long? flag (only useful in IA-32e) 64 bits code segment.
Definition: gdt.h:70
unsigned base_low
Lower bits of base address (bits 15..0)
Definition: gdt.h:62