Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
|
Include file for GDT configuration. More...
#include <stdint.h>
#include "maldefines.h"
Go to the source code of this file.
Data Structures | |
struct | segment_descriptor_s |
Meant to be written inside the GDT. Provides the processor with the size and location of a segment, as well as access control and status information. More... | |
struct | callgate_descriptor_s |
A callgate descriptor for the GDT/LDT Intel 64 and IA-32 Architectures Software Developer's Manual - Vol. 3a - Sec. 5.8.3 and Fig. 5.8. More... | |
struct | tss_descriptor_s |
union | gdt_entry |
struct | gdt_ptr |
Pointer to the GDT. More... | |
struct | tss_s |
Task State Segment structure . More... | |
Macros | |
#define | GRANULARITY_1 0 |
#define | GRANULARITY_4096 1 |
#define | SEG_DATA_READONLY_EXPANDUP_TYPE 0b0000 |
#define | SEG_DATA_READWRITE_EXPANDUP_TYPE 0b0010 |
#define | SEG_DATA_READONLY_EXPANDDOWN_TYPE 0b0100 |
#define | SEG_DATA_READWRITE_EXPANDDOWN_TYPE 0b0110 |
#define | SEG_CODE_EXECONLY_NONCONFORMING_TYPE 0b1000 |
#define | SEG_CODE_EXECREAD_NONCONFORMING_TYPE 0b1010 |
#define | SEG_CODE_EXECONLY_CONFORMING_TYPE 0b1100 |
#define | SEG_CODE_EXECREAD_CONFORMING_TYPE 0b1110 |
#define | GDT_CALLGATE_TYPE 0b1100 |
#define | GDT_TSS_INACTIVE_TYPE 0b1001 |
#define | GDT_TSS_BUSY_TYPE 0b1011 |
Typedefs | |
typedef struct segment_descriptor_s | segment_descriptor_t |
typedef struct callgate_descriptor_s | callgate_descriptor_t |
typedef struct tss_descriptor_s | tss_descriptor_t |
typedef union gdt_entry | gdt_entry_t |
typedef struct tss_s | tss_t |
Functions | |
struct gdt_ptr | __attribute__ ((packed)) |
void | gdt_init () |
Installs the GDT into the CPU. More... | |
void | setKernelStack (uint32_t stack) |
Updates the kernel stack address into the TSS. More... | |
Variables | |
unsigned short | limit |
Address limit. More... | |
unsigned int | base |
Base address. More... | |
unsigned | prev_tss |
Pointer to the previous TSS entry (updated on a task switch) More... | |
unsigned | reserved0 |
unsigned | esp0 |
Kernel-mode ESP (static) More... | |
unsigned | ss0 |
Kernel-mode stack segment (static) More... | |
unsigned | reserved1 |
unsigned | esp1 |
Ring-1 ESP (static) More... | |
unsigned | ss1 |
Ring-1 stack segment (static) More... | |
unsigned | reserved2 |
unsigned | esp2 |
Ring-2 ESP (static) More... | |
unsigned | ss2 |
Ring-2 stack segment (static) More... | |
unsigned | reserved3 |
unsigned | cr3 |
Page directory address (static) More... | |
unsigned | eip |
Execution pointer (prior to task switch) More... | |
unsigned | eflags |
CPU flags (prior to task switch) More... | |
unsigned | eax |
General register EAX (prior to task switch) More... | |
unsigned | ecx |
General register ECX (prior to task switch) More... | |
unsigned | edx |
General register EDX (prior to task switch) More... | |
unsigned | ebx |
General register EBX (prior to task switch) More... | |
unsigned | esp |
User-mode ESP (prior to task switch) More... | |
unsigned | ebp |
User-mode EBP (prior to task switch) More... | |
unsigned | esi |
General register ESI (prior to task switch) More... | |
unsigned | edi |
General register EDI (prior to task switch) More... | |
unsigned | es |
Segment selector ES (prior to task switch) More... | |
unsigned | reserved4 |
unsigned | cs |
Segment selector CS (prior to task switch) More... | |
unsigned | reserved5 |
unsigned | ss |
Segment selector SS (prior to task switch) More... | |
unsigned | reserved6 |
unsigned | ds |
Segment selector DS (prior to task switch) More... | |
unsigned | reserved7 |
unsigned | fs |
Segment selector FS (prior to task switch) More... | |
unsigned | reserved8 |
unsigned | gs |
Segment selector GS (prior to task switch) More... | |
unsigned | reserved9 |
unsigned | ldt |
Pointer to the LDT (static) More... | |
unsigned | reserved10 |
unsigned | trap |
Flag to raise an exception when a task switch to this task occurs (static) More... | |
unsigned | reserved11 |
unsigned | iomap_base |
IOMMU base. More... | |
tss_t | tss |
Generic TSS for userland-to-kernel switch. More... | |
Include file for GDT configuration.
#define GDT_CALLGATE_TYPE 0b1100 |
#define GDT_TSS_BUSY_TYPE 0b1011 |
#define GDT_TSS_INACTIVE_TYPE 0b1001 |
#define GRANULARITY_1 0 |
#define GRANULARITY_4096 1 |
#define SEG_CODE_EXECONLY_CONFORMING_TYPE 0b1100 |
#define SEG_CODE_EXECONLY_NONCONFORMING_TYPE 0b1000 |
#define SEG_CODE_EXECREAD_CONFORMING_TYPE 0b1110 |
#define SEG_CODE_EXECREAD_NONCONFORMING_TYPE 0b1010 |
#define SEG_DATA_READONLY_EXPANDDOWN_TYPE 0b0100 |
#define SEG_DATA_READONLY_EXPANDUP_TYPE 0b0000 |
All the different types of segments entries Last bit of the type is written every time the segment is accessed, and can be cleared for debug purposes and virtual memory management (according to Intel's doc).
Intel 64 and IA-32 Architectures Software Developer's Manual - Vol. 3a - Sec. 3.5 and Fig. 3-8
#define SEG_DATA_READWRITE_EXPANDDOWN_TYPE 0b0110 |
#define SEG_DATA_READWRITE_EXPANDUP_TYPE 0b0010 |
typedef struct callgate_descriptor_s callgate_descriptor_t |
typedef union gdt_entry gdt_entry_t |
typedef struct segment_descriptor_s segment_descriptor_t |
typedef struct tss_descriptor_s tss_descriptor_t |
struct gdt_ptr __attribute__ | ( | (packed) | ) |
void gdt_init | ( | ) |
Installs the GDT into the CPU.
Callgate setup (Syscalls)
void setKernelStack | ( | uint32_t | stack | ) |
Updates the kernel stack address into the TSS.
stack | The stack address |
unsigned int base |
Base address.
unsigned cr3 |
Page directory address (static)
unsigned cs |
Segment selector CS (prior to task switch)
unsigned ds |
Segment selector DS (prior to task switch)
unsigned eax |
General register EAX (prior to task switch)
unsigned ebp |
User-mode EBP (prior to task switch)
unsigned ebx |
General register EBX (prior to task switch)
unsigned ecx |
General register ECX (prior to task switch)
unsigned edi |
General register EDI (prior to task switch)
unsigned edx |
General register EDX (prior to task switch)
unsigned eflags |
CPU flags (prior to task switch)
unsigned eip |
Execution pointer (prior to task switch)
unsigned es |
Segment selector ES (prior to task switch)
unsigned esi |
General register ESI (prior to task switch)
unsigned esp |
User-mode ESP (prior to task switch)
unsigned esp0 |
Kernel-mode ESP (static)
unsigned esp1 |
Ring-1 ESP (static)
unsigned esp2 |
Ring-2 ESP (static)
unsigned fs |
Segment selector FS (prior to task switch)
unsigned gs |
Segment selector GS (prior to task switch)
unsigned iomap_base |
IOMMU base.
unsigned ldt |
Pointer to the LDT (static)
unsigned short limit |
Address limit.
unsigned prev_tss |
Pointer to the previous TSS entry (updated on a task switch)
unsigned reserved0 |
unsigned reserved1 |
unsigned reserved10 |
unsigned reserved11 |
unsigned reserved2 |
unsigned reserved3 |
unsigned reserved4 |
unsigned reserved5 |
unsigned reserved6 |
unsigned reserved7 |
unsigned reserved8 |
unsigned reserved9 |
unsigned ss |
Segment selector SS (prior to task switch)
unsigned ss0 |
Kernel-mode stack segment (static)
unsigned ss1 |
Ring-1 stack segment (static)
unsigned ss2 |
Ring-2 stack segment (static)
unsigned trap |
Flag to raise an exception when a task switch to this task occurs (static)
tss_t tss |
Generic TSS for userland-to-kernel switch.