1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! This module defines the GDT and its segments.
use crate::arch::gdt::{Descriptor, GlobalDescriptorTable, Ring};
use crate::arch::DescriptorTablePointer;

/// The global descriptor table
pub static mut GDT: GlobalDescriptorTable<3> = GlobalDescriptorTable([
    // First one is usually null
    Descriptor::new(),
    // Kernel code
    Descriptor::segment(0..=u32::MAX, true, Ring::System),
    // Kernel data
    Descriptor::segment(0..=u32::MAX, false, Ring::System),
    // TODO: BSB B1 - Add user code, user data and TSS segments
]);

/// Fat pointer to the GDT, used by the boot asm code.
#[no_mangle]
pub static GDT_PTR: DescriptorTablePointer = unsafe { GDT.pointer() };