summaryrefslogtreecommitdiff
path: root/kernel/src/cpu/tss.c
blob: 843c114eaf40bdb33f413327428dacd8d0bd009c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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();
	printf("rsp0 addr in tss: 0x%x\n", stack);
}