use crate::arch::gdt::{Descriptor, GlobalDescriptorTable, Ring, SegmentSelector};
use crate::arch::DescriptorTablePointer;
pub static mut GDT: GlobalDescriptorTable<3> = GlobalDescriptorTable([
Descriptor::new(),
Descriptor::segment(0..=u32::MAX, true, Ring::System),
Descriptor::segment(0..=u32::MAX, false, Ring::System),
]);
pub static GDT_PTR: DescriptorTablePointer = unsafe { GDT.pointer() };
#[allow(unused)]
pub enum Segment {
KernelCode = 1,
KernelData = 2,
UserCode = 3,
UserData = 4,
TaskState = 5,
}
impl Segment {
pub fn selector(self) -> SegmentSelector {
let user = matches!(self, Self::UserCode | Self::UserData);
unsafe { GDT.selector(self as _, user) }
}
}
pub fn init() {
todo!("BSB B1 - Initialize and set the TSS");
}