Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
Macros | Functions | Variables
gdt.c File Reference

GDT configuration. More...

#include "gdt.h"
#include "libc.h"
#include "debug.h"
#include "pipcall.h"
#include "segment_selectors.h"

Macros

#define GDT_N_ENTRY   (LAST_PIPCALL + 1)
 

Functions

void set_segment_descriptor (uint32_t num, uint32_t base, uint32_t limit, unsigned char type, unsigned char dpl, unsigned char granularity)
 
void set_callgate_descriptor (int num, void *handler, uint8_t args, uint8_t dpl, uint16_t segment)
 Installs a call gate entry into the GDT. More...
 
void set_tss_descriptor (uint32_t num, tss_t *tss_ptr, uint32_t limit, unsigned char type, unsigned char dpl, unsigned char granularity)
 
void set_tss (uint16_t kernel_code_segment, uint16_t kernel_data_segment, uint16_t kernel_stack_segment)
 
void setKernelStack (uint32_t stack)
 Updates the kernel stack address into the TSS. More...
 
void load_gdt (void *base, uint16_t limit)
 
void load_tss ()
 
void gdt_init (void)
 Installs the GDT into the CPU. More...
 

Variables

gdt_entry_t gdt [GDT_N_ENTRY]
 Our GDT. More...
 
tss_t tss
 Generic TSS for userland-to-kernel switch. More...
 
void * cg_outbGlue
 
void * cg_inbGlue
 
void * cg_outwGlue
 
void * cg_inwGlue
 
void * cg_outlGlue
 
void * cg_inlGlue
 
void * cg_outaddrlGlue
 
void * cg_createPartition
 
void * cg_countToMap
 
void * cg_prepare
 
void * cg_addVAddr
 
void * cg_get_int_state
 
void * cg_set_int_state
 
void * cg_removeVAddr
 
void * cg_mappedInChild
 
void * cg_deletePartition
 
void * cg_collect
 
void * cg_yieldGlue
 

Detailed Description

GDT configuration.

Macro Definition Documentation

◆ GDT_N_ENTRY

#define GDT_N_ENTRY   (LAST_PIPCALL + 1)

Function Documentation

◆ gdt_init()

void gdt_init ( void  )

Installs the GDT into the CPU.

Callgate setup (Syscalls)

◆ load_gdt()

void load_gdt ( void *  base,
uint16_t  limit 
)

< Pointer to our GDT

◆ load_tss()

void load_tss ( )

◆ set_callgate_descriptor()

void set_callgate_descriptor ( int  num,
void *  handler,
uint8_t  args,
uint8_t  dpl,
uint16_t  segment 
)

Installs a call gate entry into the GDT.

Parameters
numThe index of the segment into the GDT
handlerThe function pointer
argsArgument count
dplDescriptor Privilege Level (Caller Privilege Level must be numerically less or equal to DPL)
segmentThe segment to switch to

◆ set_segment_descriptor()

void set_segment_descriptor ( uint32_t  num,
uint32_t  base,
uint32_t  limit,
unsigned char  type,
unsigned char  dpl,
unsigned char  granularity 
)

◆ set_tss()

void set_tss ( uint16_t  kernel_code_segment,
uint16_t  kernel_data_segment,
uint16_t  kernel_stack_segment 
)

< Pointer to the previous TSS entry (updated on a task switch)

< Kernel-mode ESP (static)

< Kernel-mode stack segment (static)

< Ring-1 ESP (static)

< Ring-1 stack segment (static)

< Ring-2 ESP (static)

< Ring-2 stack segment (static)

< Page directory address (static)

< Execution pointer (prior to task switch)

< CPU flags (prior to task switch)

< General register EAX (prior to task switch)

< General register ECX (prior to task switch)

< General register EDX (prior to task switch)

< General register EBX (prior to task switch)

< User-mode ESP (prior to task switch)

< User-mode EBP (prior to task switch)

< General register ESI (prior to task switch)

< General register EDI (prior to task switch)

< Segment selector ES (prior to task switch)

< Segment selector CS (prior to task switch)

< Segment selector SS (prior to task switch)

< Segment selector DS (prior to task switch)

< Segment selector FS (prior to task switch)

< Segment selector GS (prior to task switch)

< Pointer to the LDT (static)

< Flag to raise an exception when a task switch to this task occurs (static)

< IOMMU base

◆ set_tss_descriptor()

void set_tss_descriptor ( uint32_t  num,
tss_t tss_ptr,
uint32_t  limit,
unsigned char  type,
unsigned char  dpl,
unsigned char  granularity 
)

◆ setKernelStack()

void setKernelStack ( uint32_t  stack)

Updates the kernel stack address into the TSS.

Parameters
stackThe stack address

Variable Documentation

◆ cg_addVAddr

void* cg_addVAddr

◆ cg_collect

void* cg_collect

◆ cg_countToMap

void* cg_countToMap

◆ cg_createPartition

void* cg_createPartition

◆ cg_deletePartition

void* cg_deletePartition

◆ cg_get_int_state

void* cg_get_int_state

◆ cg_inbGlue

void* cg_inbGlue

◆ cg_inlGlue

void* cg_inlGlue

◆ cg_inwGlue

void* cg_inwGlue

◆ cg_mappedInChild

void* cg_mappedInChild

◆ cg_outaddrlGlue

void* cg_outaddrlGlue

◆ cg_outbGlue

void* cg_outbGlue

◆ cg_outlGlue

void* cg_outlGlue

◆ cg_outwGlue

void* cg_outwGlue

◆ cg_prepare

void* cg_prepare

◆ cg_removeVAddr

void* cg_removeVAddr

◆ cg_set_int_state

void* cg_set_int_state

◆ cg_yieldGlue

void* cg_yieldGlue

◆ gdt

Our GDT.

◆ tss

tss_t tss

Generic TSS for userland-to-kernel switch.