PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
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 |
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 72 of file tss.c.
Referenced by tss_init().
uint16_t void* tss::esp0 |
uint16_t tss::ss0 |
Definition at line 55 of file tss.c.
Referenced by tss_init().