PatchworkOS
Loading...
Searching...
No Matches
tss.c
Go to the documentation of this file.
1#include <kernel/cpu/tss.h>
2
3#include <assert.h>
4
5void tss_init(tss_t* tss)
6{
7 tss->reserved1 = 0;
8 tss->rsp0 = 0;
9 tss->rsp1 = 0;
10 tss->rsp2 = 0;
11 tss->reserved2 = 0;
12 for (int i = 0; i < 7; i++)
13 {
14 tss->ist[i] = 0;
15 }
16 tss->reserved3 = 0;
17 tss->reserved4 = 0;
18 tss->iopb = sizeof(tss_t);
19}
20
22{
23 assert(ist < TSS_IST_COUNT && ist >= TSS_IST1);
24 tss->ist[ist - 1] = stack->top;
25}
#define assert(expression)
Definition assert.h:29
void tss_ist_load(tss_t *tss, tss_ist_t ist, stack_pointer_t *stack)
Load a stack into an IST entry.
Definition tss.c:21
void tss_init(tss_t *tss)
Initialize a TSS structure.
Definition tss.c:5
tss_ist_t
Interrupt Stack Table indices.
Definition tss.h:25
@ TSS_IST1
Definition tss.h:27
static pmm_stack_t stack
Definition pmm.c:36
Structure to define a stack in memory.
Task State Segment structure.
Definition tss.h:88
uint32_t reserved1
Definition tss.h:89
uint64_t reserved2
Definition tss.h:93
uint64_t rsp1
Stack pointer to load when switching to ring 1, unused.
Definition tss.h:91
uint16_t iopb
Offset to the I/O permission bitmap, we set this to the size of the TSS to disable the bitmap.
Definition tss.h:97
uint64_t rsp0
Stack pointer to load when switching to ring 0, unused.
Definition tss.h:90
uint64_t reserved3
Definition tss.h:95
uint64_t rsp2
Stack pointer to load when switching to ring 2, unused.
Definition tss.h:92
uint64_t ist[7]
Definition tss.h:94
uint16_t reserved4
Definition tss.h:96