1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-21 23:56:18 +04:00

Forcing hart BOOT_HART_ID to initialize everything.

This commit is contained in:
gjz010 2021-03-03 20:02:30 +08:00
parent 95f0cd5b6c
commit 465d26a7c6

View File

@ -36,8 +36,6 @@ fn start_all_harts() {
#[no_mangle]
pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
let device_tree_vaddr = phys_to_virt(device_tree_paddr);
unsafe {
cpu::set_cpu_id(hartid);
}
@ -46,15 +44,15 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.is_ok()
{
LOTTERY_HART_ID.store(hartid, Ordering::SeqCst);
DEVICE_TREE_PADDR.store(device_tree_paddr, Ordering::SeqCst);
start_all_harts();
}
let main_hart = LOTTERY_HART_ID.load(Ordering::SeqCst);
if hartid != main_hart {
if hartid != BOOT_HART_ID {
while !AP_CAN_INIT.load(Ordering::Relaxed) {}
others_main(hartid);
}
let device_tree_vaddr = phys_to_virt(DEVICE_TREE_PADDR.load(Ordering::SeqCst));
unsafe {
memory::clear_bss();
}
@ -93,7 +91,7 @@ fn others_main(hartid: usize) -> ! {
static AP_CAN_INIT: AtomicBool = AtomicBool::new(false);
static FIRST_HART: AtomicBool = AtomicBool::new(false);
static LOTTERY_HART_ID: AtomicUsize = AtomicUsize::new(0);
static DEVICE_TREE_PADDR: AtomicUsize = AtomicUsize::new(0);
#[cfg(not(feature = "board_u540"))]
const BOOT_HART_ID: usize = 0;