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