rstubs/arch/tss.rs
//! Task state segment register
use core::arch::asm;
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))]
#[allow(non_snake_case)]
pub struct TaskStateSegment {
// TODO: BSB B1 - Create task state register
__: [u8; 108],
}
const _: () = assert!(size_of::<TaskStateSegment>() == 108);
impl TaskStateSegment {
/// Create a new task state segment
pub const fn new() -> Self {
todo!() // BSB B1 - Create task state register
}
}
pub unsafe fn load_tss(sel: SegmentSelector) {
asm!("ltr {0:x}", in(reg) u16::from(sel), options(nostack, nomem));
}