//! Task state segment register
use core::arch::asm;
use core::fmt;
use core::mem::size_of;
use crate::arch::gdt::SegmentSelector;
/// Task state segment register, that holds information about hardware tasks.
///
/// Its fields are mostly unused nowdays, with the exception of esp0 and ss0.
/// These fields containt the kernel stack pointer and segment used for interrupt handling.
///
/// - <https://wiki.osdev.org/Task_State_Segment>
#[repr(C, align(4))]
pub struct TaskStateSegment {
// TODO: A1 - Create task state register
__: [u8; 108],
}
const _: () = assert!(size_of::<TaskStateSegment>() == 108);
impl TaskStateSegment {
/// Create a new task state segment
pub const fn new() -> TaskStateSegment {
todo!()
}
}
pub unsafe fn load_tss(sel: SegmentSelector) {
asm!("ltr {0:x}", in(reg) u16::from(sel), options(nostack, nomem));
}