From 594cc3e16fb8382b9fe3d19edd5ba6597a0a1178 Mon Sep 17 00:00:00 2001 From: chyyuu Date: Tue, 16 Apr 2019 18:13:55 +0800 Subject: [PATCH] fix bugs about cpu num config (x86-64) TODO: Unfixed bugs: rcore can not identify the hyperthread-mode cpus(i9-9900k) and dead. --- kernel/src/arch/x86_64/gdt.rs | 15 +++++++++++++ kernel/src/consts.rs | 2 +- kernel/src/process/mod.rs | 41 ++++++++++++++++++++++++++++------- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/kernel/src/arch/x86_64/gdt.rs b/kernel/src/arch/x86_64/gdt.rs index b6cfca5..90e5037 100644 --- a/kernel/src/arch/x86_64/gdt.rs +++ b/kernel/src/arch/x86_64/gdt.rs @@ -18,6 +18,21 @@ pub fn init() { static mut CPUS: [Option; MAX_CPU_NUM] = [ // TODO: More elegant ? None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, +// None, None, None, None, None, None, None, None, ]; pub struct Cpu { diff --git a/kernel/src/consts.rs b/kernel/src/consts.rs index fe6b679..22a4afe 100644 --- a/kernel/src/consts.rs +++ b/kernel/src/consts.rs @@ -2,7 +2,7 @@ pub use crate::arch::consts::*; -pub const MAX_CPU_NUM: usize = 8; +pub const MAX_CPU_NUM: usize = 64; pub const MAX_PROCESS_NUM: usize = 128; pub const USEC_PER_TICK: usize = 10000; diff --git a/kernel/src/process/mod.rs b/kernel/src/process/mod.rs index ff69345..fca611d 100644 --- a/kernel/src/process/mod.rs +++ b/kernel/src/process/mod.rs @@ -26,14 +26,39 @@ pub fn init() { } static PROCESSORS: [Processor; MAX_CPU_NUM] = [ - Processor::new(), - Processor::new(), - Processor::new(), - Processor::new(), - Processor::new(), - Processor::new(), - Processor::new(), - Processor::new(), + // TODO: More elegant ? + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), + Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), +// Processor::new(), Processor::new(), Processor::new(), Processor::new(), ]; /// Get current process