2026-02-08 11:34:21 +00:00
|
|
|
#ifndef ARCH_TSS_H_
|
|
|
|
|
#define ARCH_TSS_H_
|
|
|
|
|
|
2026-02-19 18:54:48 +00:00
|
|
|
#include <kernel/compiler.h>
|
|
|
|
|
#include <kernel/types.h>
|
2026-02-08 11:34:21 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#define TSS_GDT_INDEX 5
|
|
|
|
|
|
|
|
|
|
struct tss {
|
|
|
|
|
uint32_t res0;
|
|
|
|
|
uint64_t rsp0;
|
|
|
|
|
uint64_t rsp1;
|
|
|
|
|
uint64_t rsp2;
|
|
|
|
|
uint64_t res1;
|
|
|
|
|
uint64_t ist1;
|
|
|
|
|
uint64_t ist2;
|
|
|
|
|
uint64_t ist3;
|
|
|
|
|
uint64_t ist4;
|
|
|
|
|
uint64_t ist5;
|
|
|
|
|
uint64_t ist6;
|
|
|
|
|
uint64_t ist7;
|
|
|
|
|
uint64_t res2;
|
|
|
|
|
uint16_t res3;
|
|
|
|
|
uint16_t iomap_offset;
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
struct tss_gdt_entry {
|
|
|
|
|
/* these fields are copied from struct gdt_entry */
|
|
|
|
|
uint16_t ge_limit_low;
|
|
|
|
|
uint16_t ge_base_low;
|
|
|
|
|
uint8_t ge_base_mid;
|
|
|
|
|
uint8_t ge_access;
|
|
|
|
|
uint8_t ge_gran;
|
|
|
|
|
uint8_t ge_base_hi;
|
|
|
|
|
/* these fields are specific to the TSS entry */
|
|
|
|
|
uint32_t ge_base_ext;
|
|
|
|
|
uint32_t ge_reserved;
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
struct tss_ptr {
|
|
|
|
|
uint16_t tss_limit;
|
|
|
|
|
uint64_t tss_base;
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
extern void tss_init(struct tss *tss, struct tss_ptr *ptr);
|
|
|
|
|
extern void tss_load(struct tss *tss);
|
|
|
|
|
|
|
|
|
|
extern virt_addr_t tss_get_kstack(struct tss *tss);
|
|
|
|
|
extern virt_addr_t tss_get_ustack(struct tss *tss);
|
|
|
|
|
|
|
|
|
|
extern void tss_set_kstack(struct tss *tss, virt_addr_t sp);
|
|
|
|
|
extern void tss_set_ustack(struct tss *tss, virt_addr_t sp);
|
|
|
|
|
|
|
|
|
|
#endif
|