PKUOS - Pintos
Pintos source browser for PKU Operating System course
Data Fields
tss Struct Reference

The Task-State Segment (TSS). More...

Data Fields

uint16_t back_link
 
uint16_t void * esp0:16
 Ring 0 stack virtual address. More...
 
uint16_t ss0
 
uint16_t void * esp1:16
 Ring 0 stack segment selector. More...
 
uint16_t ss1
 
uint16_t void * esp2:16
 
uint16_t ss2
 
uint16_t uint32_t cr3:16
 
void(* eip )(void)
 
uint32_t eflags
 
uint32_t eax
 
uint32_t ecx
 
uint32_t edx
 
uint32_t ebx
 
uint32_t esp
 
uint32_t ebp
 
uint32_t esi
 
uint32_t edi
 
uint16_t es
 
uint16_t uint16_t cs:16
 
uint16_t uint16_t uint16_t ss:16
 
uint16_t uint16_t uint16_t uint16_t ds:16
 
uint16_t uint16_t uint16_t uint16_t uint16_t fs:16
 
uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t gs:16
 
uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t ldt:16
 
uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t trace:16
 
uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t uint16_t bitmap
 

Detailed Description

The Task-State Segment (TSS).

Instances of the TSS, an x86-specific structure, are used to define "tasks", a form of support for multitasking built right into the processor. However, for various reasons including portability, speed, and flexibility, most x86 OSes almost completely ignore the TSS. We are no exception.

Unfortunately, there is one thing that can only be done using a TSS: stack switching for interrupts that occur in user mode. When an interrupt occurs in user mode (ring 3), the processor consults the ss0 and esp0 members of the current TSS to determine the stack to use for handling the interrupt. Thus, we must create a TSS and initialize at least these fields, and this is precisely what this file does.

When an interrupt is handled by an interrupt or trap gate (which applies to all interrupts we handle), an x86 processor works like this:

See [IA32-v3a] 6.2.1 "Task-State Segment (TSS)" for a description of the TSS. See [IA32-v3a] 5.12.1 "Exception- or Interrupt-Handler Procedures" for a description of when and how stack switching occurs during an interrupt.

Definition at line 51 of file tss.c.

Field Documentation

◆ back_link

uint16_t tss::back_link

Definition at line 53 of file tss.c.

◆ bitmap

Definition at line 72 of file tss.c.

Referenced by tss_init().

◆ cr3

uint16_t uint32_t tss::cr3

Definition at line 60 of file tss.c.

◆ cs

uint16_t uint16_t tss::cs

Definition at line 66 of file tss.c.

◆ ds

Definition at line 68 of file tss.c.

◆ eax

uint32_t tss::eax

Definition at line 63 of file tss.c.

◆ ebp

uint32_t tss::ebp

Definition at line 64 of file tss.c.

◆ ebx

uint32_t tss::ebx

Definition at line 63 of file tss.c.

◆ ecx

uint32_t tss::ecx

Definition at line 63 of file tss.c.

◆ edi

uint32_t tss::edi

Definition at line 64 of file tss.c.

◆ edx

uint32_t tss::edx

Definition at line 63 of file tss.c.

◆ eflags

uint32_t tss::eflags

Definition at line 62 of file tss.c.

◆ eip

void(* tss::eip) (void)

Definition at line 61 of file tss.c.

◆ es

uint16_t tss::es

Definition at line 65 of file tss.c.

◆ esi

uint32_t tss::esi

Definition at line 64 of file tss.c.

◆ esp

uint32_t tss::esp

Definition at line 64 of file tss.c.

◆ esp0

uint16_t void* tss::esp0

Ring 0 stack virtual address.

Definition at line 54 of file tss.c.

Referenced by tss_update().

◆ esp1

uint16_t void* tss::esp1

Ring 0 stack segment selector.

Definition at line 56 of file tss.c.

◆ esp2

uint16_t void* tss::esp2

Definition at line 58 of file tss.c.

◆ fs

Definition at line 69 of file tss.c.

◆ gs

Definition at line 70 of file tss.c.

◆ ldt

Definition at line 71 of file tss.c.

◆ ss

Definition at line 67 of file tss.c.

◆ ss0

uint16_t tss::ss0

Definition at line 55 of file tss.c.

Referenced by tss_init().

◆ ss1

uint16_t tss::ss1

Definition at line 57 of file tss.c.

◆ ss2

uint16_t tss::ss2

Definition at line 59 of file tss.c.

◆ trace

Definition at line 72 of file tss.c.


The documentation for this struct was generated from the following file: