Skip to content

Commit b6df0b9

Browse files
Make Hyp Timer !Send
1 parent 54abf1a commit b6df0b9

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

  • aarch32-cpu/src/generic_timer

aarch32-cpu/src/generic_timer/el2.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Code and types for Generic Timer support at EL2 on Armv8-R.
22
3+
use core::marker::PhantomData;
4+
35
use crate::register;
46

57
use super::{El1PhysicalTimer, El1VirtualTimer, GenericTimer};
@@ -160,18 +162,30 @@ impl GenericTimer for El2VirtualTimer {
160162
}
161163
}
162164

163-
/// Represents our Hypervisor-specific Physical Timer when we are running at EL1.
164-
pub struct El2HypPhysicalTimer();
165+
/// Represents our Hypervisor-specific Physical Timer.
166+
///
167+
/// This is designed for use by a hypervisor, whilst an EL1 application
168+
/// concurrently uses the Physical Timer and/or the Virtual Timer.
169+
///
170+
/// This type is not [Send] because it is a per-core type and should not be moved across
171+
/// cores on an SMP system.
172+
pub struct El2HypPhysicalTimer {
173+
_phantom: PhantomData<*const u8>,
174+
}
165175

166176
impl El2HypPhysicalTimer {
167177
/// Create a Timer handle for the EL2-specific Hyp Physical Timer.
168178
///
169179
/// # Safety
170180
///
171181
/// Only create one of these at any given time, as they access shared
172-
/// mutable state within the processor and do read-modify-writes on that state.
182+
/// mutable state within the processor and do read-modify-writes on that
183+
/// state. This timer is distinct from the Physical Timer and the Virtual
184+
/// Timer, and so can exist concurrently.
173185
pub unsafe fn new() -> El2HypPhysicalTimer {
174-
El2HypPhysicalTimer()
186+
El2HypPhysicalTimer {
187+
_phantom: PhantomData,
188+
}
175189
}
176190
}
177191

0 commit comments

Comments
 (0)