Fix TSS descriptor flags
All checks were successful
Continuous Integration / Check (push) Successful in 1m2s
Continuous Integration / Clippy (push) Successful in 1m8s

This commit is contained in:
August 2026-10-11 19:53:45 -04:00
parent 69bf4c6576
commit f4200d768b
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
3 changed files with 7 additions and 9 deletions

View File

@ -82,7 +82,7 @@ lazy_static! {
let tss_size = size_of::<TaskStateSegment>() as u128 - 1; let tss_size = size_of::<TaskStateSegment>() as u128 - 1;
let mut tss_descriptor: u128 = 0; let mut tss_descriptor: u128 = 0;
tss_descriptor.set_bits(56..=95, tss_addr.bits(24..=63)); // Base bits 24..=63 tss_descriptor.set_bits(56..=95, tss_addr.bits(24..=63)); // Base bits 24..=63
tss_descriptor.set_bits(52..=55, 0b0000); // Flags: 1-byte granularity tss_descriptor.set_bits(52..=55, 0b0010); // Flags: 1-byte granularity, long mode
tss_descriptor.set_bits(48..=51, tss_size.bits(16..=19)); // Limit bits 16..=19 tss_descriptor.set_bits(48..=51, tss_size.bits(16..=19)); // Limit bits 16..=19
tss_descriptor.set_bits(40..=47, 0b10001001); // Access: Present, ring 0, system segment tss_descriptor.set_bits(40..=47, 0b10001001); // Access: Present, ring 0, system segment
tss_descriptor.set_bits(16..=39, tss_addr.bits(0..=23)); // Base bits 0..=23 tss_descriptor.set_bits(16..=39, tss_addr.bits(0..=23)); // Base bits 0..=23
@ -147,7 +147,7 @@ pub fn read_gdt() -> GlobalDescriptorTable {
#[allow(unused)] #[allow(unused)]
pub fn dump_gdt() { pub fn dump_gdt() {
let gdt = crate::arch::x86_64::gdt::read_gdt(); let gdt = crate::arch::x86_64::gdt::read_gdt();
log_info!("GDT length: {}", gdt.limit() + 1); log_info!("GDT length (Counting null descriptor): {}", gdt.limit() + 1);
for entry in gdt.entries() { for entry in gdt.entries() {
let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(entry.raw()); let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(entry.raw());
let seg_type = SegmentType::try_from(entry); let seg_type = SegmentType::try_from(entry);

View File

@ -36,4 +36,4 @@ pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new();
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static FLANTERM_REQUEST: FlantermParamsRequest = limine::request::FlantermParamsRequest::new(); pub static FLANTERM_REQUEST: FlantermParamsRequest = limine::request::FlantermParamsRequest::new();

View File

@ -27,7 +27,7 @@ use lazy_static::lazy_static;
use spin::mutex::Mutex; use spin::mutex::Mutex;
use x86_64::VirtAddr; use x86_64::VirtAddr;
use crate::{arch::x86_64::gdt::SELECTORS, boot::modules::MODULE_RESPONSE}; use crate::{arch::x86_64::gdt, boot::modules::MODULE_RESPONSE};
lazy_static! { lazy_static! {
pub static ref SERIAL_3F8: Mutex<SerialPort> = Mutex::new( pub static ref SERIAL_3F8: Mutex<SerialPort> = Mutex::new(
@ -93,15 +93,13 @@ unsafe extern "C" fn main() -> ! {
log_info!("Trans rights!"); log_info!("Trans rights!");
// TODO: Figure out a way to specify log categories
// Especially, get rid of fine grain logs if building in release mode
boot::modules::log_modules(); boot::modules::log_modules();
memory::log_memory(); memory::log_memory();
memory::log_address(); memory::log_address();
gdt::dump_gdt();
log_info!(
"TSS descriptor: 0x{:08x} {:08x}",
SELECTORS.gdt.entries()[SELECTORS.sel_tss.index() as usize + 1].raw(),
SELECTORS.gdt.entries()[SELECTORS.sel_tss.index() as usize].raw()
);
if let Some(modules_list) = *MODULE_RESPONSE if let Some(modules_list) = *MODULE_RESPONSE
&& modules_list.modules()[0].path().ends_with("/userboot.bin") && modules_list.modules()[0].path().ends_with("/userboot.bin")
{ {