Improve readability

This commit is contained in:
4lDO2
2024-03-18 14:26:00 +01:00
parent f7900df0e2
commit ff0bd96abd
2 changed files with 13 additions and 7 deletions
+6 -4
View File
@@ -120,6 +120,8 @@ const BASE_GDT: [GdtEntry; 9] = [
GdtEntry::new(0, 0, GDT_A_PRESENT | GDT_A_RING_3 | GDT_A_TSS_AVAIL, 0),
];
const IOBITMAP_SIZE: usize = 8192;
#[repr(C, align(4096))]
pub struct ProcessorControlRegion {
pub self_ref: usize,
@@ -127,8 +129,8 @@ pub struct ProcessorControlRegion {
pub gdt: [GdtEntry; 9],
percpu: crate::percpu::PercpuBlock,
pub tss: TssWrapper,
pub pio_bitmap: [u8; 8192],
pub all_ones: u8,
pub _pio_bitmap: [u8; IOBITMAP_SIZE],
pub _all_ones: u8,
}
// NOTE: Despite not using #[repr(packed)], we do know that while there may be some padding
@@ -193,12 +195,12 @@ pub unsafe fn init_paging(stack_offset: usize, cpu_id: LogicalCpuId) {
};
{
pcr.all_ones = 0xFF;
pcr._all_ones = 0xFF;
pcr.tss.0.iobp_offset = 0xFFFF;
let tss = &pcr.tss.0 as *const _ as usize as u32;
pcr.gdt[GDT_TSS].set_offset(tss);
pcr.gdt[GDT_TSS].set_limit(mem::size_of::<TaskStateSegment>() as u32 + 8192);
pcr.gdt[GDT_TSS].set_limit(mem::size_of::<TaskStateSegment>() as u32 + IOBITMAP_SIZE);
}
// Load the new GDT, which is correctly located in thread local storage.
+7 -3
View File
@@ -121,8 +121,12 @@ pub struct ProcessorControlRegion {
pub gdt: [GdtEntry; 8],
pub percpu: PercpuBlock,
pub tss: TaskStateSegment,
pub iobitmap: [u8; IOBITMAP_SIZE as usize],
pub all_ones: u8,
// These two fields are read by the CPU, but not currently modified by the kernel. Instead, the
// kernel sets the `iomap_base` field in the TSS, to either point to this bitmap, or outside
// the TSS, in which case userspace is not granted port IO access.
pub _iobitmap: [u8; IOBITMAP_SIZE as usize],
pub _all_ones: u8,
}
const _: () = {
@@ -213,7 +217,7 @@ pub unsafe fn init_paging(stack_offset: usize, cpu_id: LogicalCpuId) {
{
pcr.tss.iomap_base = 0xFFFF;
pcr.all_ones = 0xFF;
pcr._all_ones = 0xFF;
let tss = &mut pcr.tss as *mut TaskStateSegment as usize as u64;
let tss_lo = (tss & 0xFFFF_FFFF) as u32;