From 3b89f444ff575c0318f50e6188914db11a2fc361 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Sat, 2 Sep 2023 18:15:41 +0300 Subject: [PATCH] x86-64: fix ACPI init in Thinkpad E14g2 --- src/arch/x86_64/apic/ioapic.rs | 2 +- src/arch/x86_64/boot/mod.rs | 4 ++-- src/arch/x86_64/peripherals/hpet.rs | 16 ++++++++-------- src/device/display/console.rs | 2 +- src/panic.rs | 2 ++ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/arch/x86_64/apic/ioapic.rs b/src/arch/x86_64/apic/ioapic.rs index 9d15efa1..736f98f5 100644 --- a/src/arch/x86_64/apic/ioapic.rs +++ b/src/arch/x86_64/apic/ioapic.rs @@ -227,7 +227,7 @@ impl IoApic { /// Creates an I/O APIC instance from its ACPI definition pub fn from_acpi(info: &AcpiApic) -> Result { if info.io_apics.len() != 1 { - todo!(); + warnln!("The system has multiple I/O APICs, but the kernel only knows how to use one"); } let ioapic = info.io_apics.first().unwrap(); diff --git a/src/arch/x86_64/boot/mod.rs b/src/arch/x86_64/boot/mod.rs index 4386db51..0da96293 100644 --- a/src/arch/x86_64/boot/mod.rs +++ b/src/arch/x86_64/boot/mod.rs @@ -25,8 +25,8 @@ use super::smp::CPU_COUNT; // use super::ARCHITECTURE; -const BOOT_STACK_SIZE: usize = 256 * 1024; -const HEAP_PAGES: usize = 256; +const BOOT_STACK_SIZE: usize = 1024 * 1024; +const HEAP_PAGES: usize = 512; #[repr(C, align(0x20))] struct BootStack { diff --git a/src/arch/x86_64/peripherals/hpet.rs b/src/arch/x86_64/peripherals/hpet.rs index 78f480c8..9e0aaa24 100644 --- a/src/arch/x86_64/peripherals/hpet.rs +++ b/src/arch/x86_64/peripherals/hpet.rs @@ -138,14 +138,6 @@ impl Inner { // Will give an interrupt interval of 1ms let tim0_period = FS_IN_MS / clk_period; - // if tim0_period > 0x100000000 - // && !tim0 - // .ConfigurationCapability - // .matches_all(TimerConfigurationCapablities::TM_SIZE_CAP::Timer64Bit) - // { - // panic!("Period is too large and timer doesn't support 64-bit"); - // } - // Enable the main counter regs.GeneralConfiguration .modify(GeneralConfiguration::ENABLE_CNF::SET); @@ -196,6 +188,14 @@ impl Device for Hpet { let tim0 = &inner.regs.Timers[0]; + if inner.tim0_period > 0x100000000 + && !tim0 + .ConfigurationCapability + .matches_all(TimerConfigurationCapablities::TM_SIZE_CAP::Timer64Bit) + { + panic!("Period is too large and timer doesn't support 64-bit"); + } + // Temporarily disable the main counter inner .regs diff --git a/src/device/display/console.rs b/src/device/display/console.rs index 763015e7..5f8c05cc 100644 --- a/src/device/display/console.rs +++ b/src/device/display/console.rs @@ -16,7 +16,7 @@ use crate::{ task::tasklet::TaskFlow, }; -const CONSOLE_ROW_LEN: usize = 128; +const CONSOLE_ROW_LEN: usize = 80; const MAX_CSI_ARGS: usize = 8; const DEFAULT_FG_COLOR: ColorAttribute = ColorAttribute::White; diff --git a/src/panic.rs b/src/panic.rs index e9cb1555..7bfefc2a 100644 --- a/src/panic.rs +++ b/src/panic.rs @@ -49,6 +49,8 @@ fn panic_handler(pi: &core::panic::PanicInfo) -> ! { static PANIC_HAPPENED: AtomicBool = AtomicBool::new(false); + infoln!("{:?}", pi); + if PANIC_HAPPENED .compare_exchange(false, true, Ordering::Release, Ordering::Acquire) .is_ok()