Ver código fonte

refactor: rename ENABLED to CPU_ENABLED

Signed-off-by: yzs <320016@qq.com>
yzs 5 dias atrás
pai
commit
6f80275b62

+ 3 - 5
prototyper/prototyper/src/main.rs

@@ -20,6 +20,7 @@ mod sbi;
 
 use core::arch::{asm, naked_asm};
 
+use crate::platform::CPU_ENABLED;
 use crate::platform::PLATFORM;
 use crate::riscv::csr::menvcfg;
 use crate::riscv::current_hartid;
@@ -37,9 +38,6 @@ use crate::sbi::trap_stack;
 
 pub const R_RISCV_RELATIVE: usize = 3;
 
-use crate::cfg::NUM_HART_MAX;
-static mut ENABLED: [bool; NUM_HART_MAX] = [false; NUM_HART_MAX];
-
 #[unsafe(no_mangle)]
 extern "C" fn rust_main(_hart_id: usize, opaque: usize, nonstandard_a2: usize) {
     // Track whether SBI is initialized and ready.
@@ -58,7 +56,7 @@ extern "C" fn rust_main(_hart_id: usize, opaque: usize, nonstandard_a2: usize) {
                 fail::stop();
             } else {
                 unsafe {
-                    ENABLED[current_hartid()] = true;
+                    CPU_ENABLED[current_hartid()] = true;
                 }
             }
         }
@@ -67,7 +65,7 @@ extern "C" fn rust_main(_hart_id: usize, opaque: usize, nonstandard_a2: usize) {
                 fail::stop();
             } else {
                 unsafe {
-                    ENABLED[current_hartid()] = true;
+                    CPU_ENABLED[current_hartid()] = true;
                 }
             }
         }

+ 2 - 1
prototyper/prototyper/src/platform/mod.rs

@@ -36,6 +36,7 @@ use crate::sbi::suspend::SbiSuspend;
 mod clint;
 mod console;
 mod reset;
+pub static mut CPU_ENABLED: [bool; NUM_HART_MAX] = [false; NUM_HART_MAX];
 
 type BaseAddress = usize;
 
@@ -265,7 +266,7 @@ impl Platform {
             let hart_id = cpu.reg.iter().next().unwrap().0.start;
             if let Some(x) = cpu_list.get_mut(hart_id) {
                 unsafe {
-                    *x = crate::ENABLED[hart_id];
+                    *x = CPU_ENABLED[hart_id];
                 }
             } else {
                 error!(