Skip to content

Commit

Permalink
fix(aarch64): fix compilation with feature = "common-os"
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Dec 20, 2024
1 parent b6a7325 commit c07093c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/arch/aarch64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
//! Architecture dependent interface to initialize a task
#[cfg(not(feature = "common-os"))]
use alloc::alloc::{alloc_zeroed, Layout};
#[cfg(not(feature = "common-os"))]
use alloc::boxed::Box;
use core::arch::naked_asm;
#[cfg(not(feature = "common-os"))]
use core::slice;
use core::sync::atomic::Ordering;
use core::{mem, ptr, slice};
use core::{mem, ptr};

use align_address::Align;
use memory_addresses::arch::aarch64::{PhysAddr, VirtAddr};

use crate::arch::aarch64::kernel::core_local::core_scheduler;
use crate::arch::aarch64::kernel::CURRENT_STACK_ADDRESS;
use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize, PageTableEntryFlags};
#[cfg(not(feature = "common-os"))]
use crate::env;
use crate::scheduler::task::{Task, TaskFrame};
#[cfg(target_os = "none")]
use crate::scheduler::PerCoreSchedulerExt;
use crate::{env, DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};
use crate::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};

#[derive(Debug)]
#[repr(C, packed)]
Expand Down Expand Up @@ -243,26 +249,30 @@ impl Drop for TaskStacks {
* of the TLS implementations.
*/

#[cfg(not(feature = "common-os"))]
#[derive(Copy, Clone)]
#[repr(C)]
struct DtvPointer {
val: *const (),
to_free: *const (),
}

#[cfg(not(feature = "common-os"))]
#[repr(C)]
union Dtv {
counter: usize,
pointer: DtvPointer,
}

#[cfg(not(feature = "common-os"))]
#[repr(C)]
pub struct TaskTLS {
dtv: mem::MaybeUninit<Box<[Dtv; 2]>>,
_private: usize,
block: [u8],
}

#[cfg(not(feature = "common-os"))]
impl TaskTLS {
fn from_environment() -> Option<Box<Self>> {
let tls_info = env::boot_info().load_info.tls_info?;
Expand Down Expand Up @@ -346,6 +356,7 @@ extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize) -> ! {
impl TaskFrame for Task {
fn create_stack_frame(&mut self, func: unsafe extern "C" fn(usize), arg: usize) {
// Check if TLS is allocated already and if the task uses thread-local storage.
#[cfg(not(feature = "common-os"))]
if self.tls.is_none() {
self.tls = TaskTLS::from_environment();
}
Expand All @@ -360,6 +371,7 @@ impl TaskFrame for Task {
stack -= mem::size_of::<State>();

let state = stack.as_mut_ptr::<State>();
#[cfg(not(feature = "common-os"))]
if let Some(tls) = &self.tls {
(*state).tpidr_el0 = tls.thread_ptr() as u64;
}
Expand Down
1 change: 1 addition & 0 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cfg_if::cfg_if! {
pub(crate) use self::aarch64::kernel::processor;
pub(crate) use self::aarch64::kernel::processor::set_oneshot_timer;
pub(crate) use self::aarch64::kernel::scheduler;
#[cfg(not(feature = "common-os"))]
pub(crate) use self::aarch64::kernel::switch;
#[cfg(feature = "smp")]
pub(crate) use self::aarch64::kernel::application_processor_init;
Expand Down

0 comments on commit c07093c

Please sign in to comment.