fix: 🐛 Put BOOT_CORE_ID const in platform config

This commit is contained in:
Berkus Decker 2023-11-11 19:21:24 +02:00 committed by Berkus Decker
parent 8c3b7d3d0f
commit bb38addd83
5 changed files with 14 additions and 7 deletions
machine/src
arch/aarch64/cpu
platform/raspberrypi
cpu.rs
device_driver/arm/gicv2
mod.rs

View File

@ -10,6 +10,7 @@
use {
super::endless_sleep,
crate::platform::cpu::BOOT_CORE_ID,
aarch64_cpu::{asm, registers::*},
core::{
cell::UnsafeCell,
@ -54,8 +55,6 @@ macro_rules! entry {
#[no_mangle]
#[link_section = ".text.main.entry"]
pub unsafe extern "C" fn _boot_cores() -> ! {
const CORE_0: u64 = 0;
const CORE_MASK: u64 = 0x3;
// Can't match values with dots in match, so use intermediate consts.
#[cfg(qemu)]
const EL3: u64 = CurrentEL::EL::EL3.value;
@ -72,7 +71,7 @@ pub unsafe extern "C" fn _boot_cores() -> ! {
shared_setup_and_enter_pre();
if CORE_0 == MPIDR_EL1.get() & CORE_MASK {
if BOOT_CORE_ID == super::smp::core_id() {
match CurrentEL.get() {
#[cfg(qemu)]
EL3 => setup_and_enter_el1_from_el3(),

View File

@ -1 +1,7 @@
pub fn core_id() {}
#[inline(always)]
pub fn core_id() -> u64 {
use aarch64_cpu::registers::{Readable, MPIDR_EL1};
const CORE_MASK: u64 = 0x3;
MPIDR_EL1.get() & CORE_MASK
}

View File

@ -0,0 +1 @@
pub const BOOT_CORE_ID: u64 = 0;

View File

@ -80,8 +80,8 @@ mod gicc;
mod gicd;
use crate::{
bsp::{self, device_driver::common::BoundedUsize},
cpu, driver, exception,
bsp::{self, cpu::BOOT_CORE_ID, device_driver::common::BoundedUsize},
cpu, drivers, exception,
synchronization::{self, InitStateLock},
};
@ -147,7 +147,7 @@ impl driver::interface::DeviceDriver for GICv2 {
}
unsafe fn init(&self) -> Result<(), &'static str> {
if bsp::cpu::BOOT_CORE_ID == cpu::smp::core_id() {
if BOOT_CORE_ID == cpu::smp::core_id() {
self.gicd.boot_core_init();
}

View File

@ -5,6 +5,7 @@
#![allow(dead_code)]
pub mod cpu;
pub mod device_driver;
pub mod display;
pub mod drivers;