summaryrefslogtreecommitdiff
path: root/kernel/src/cpu/tss.c
blob: a1224f6d3911285c19b7b1f64bc09b9859767579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <tss.h>
#include <heap.h>
#include <libk/stdio.h>

tss_type tss;

void load_tss()
{
	__asm__ volatile ("push %rax; mov $0x28, %ax; ltr %ax; pop %rax;");
}

void init_tss()
{
	tss.iopb = sizeof(tss_type);
	uint64_t stack = (uint64_t)kalloc(4096*4);
	stack = (uint64_t)kalloc(4096*4) + 8;
	tss.rsp0_low = (uint32_t)stack;
	tss.rsp0_high = (uint32_t)(stack >> 32);

	load_tss();
}