aarch64_cpu/asm.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2018-2023 by the author(s)
//
// Author(s):
// - Jorge Aparicio
// - Andre Richter <andre.o.richter@gmail.com>
//! Wrappers around ARMv8-A instructions.
pub mod barrier;
pub mod random;
/// The classic no-op
#[inline(always)]
pub fn nop() {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("nop", options(nomem, nostack))
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}
/// Wait For Interrupt
///
/// For more details on wfi, refer to [here](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/CIHEGBBF.html).
#[inline(always)]
pub fn wfi() {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("wfi", options(nomem, nostack))
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}
/// Wait For Event
///
/// For more details of wfe - sev pair, refer to [here](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/CIHEGBBF.html).
#[inline(always)]
pub fn wfe() {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("wfe", options(nomem, nostack))
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}
/// Send EVent.Locally
///
/// SEV causes an event to be signaled to the local core within a multiprocessor system.
///
/// For more details of wfe - sev/sevl pair, refer to [here](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/CIHEGBBF.html).
#[inline(always)]
pub fn sevl() {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("sevl", options(nomem, nostack))
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}
/// Send EVent.
///
/// SEV causes an event to be signaled to all cores within a multiprocessor system.
///
/// For more details of wfe - sev pair, refer to [here](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/CIHEGBBF.html).
#[inline(always)]
pub fn sev() {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("sev", options(nomem, nostack))
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}
/// Exception return
///
/// Will jump to wherever the corresponding link register points to, and therefore never return.
#[inline(always)]
pub fn eret() -> ! {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("eret", options(nomem, nostack));
core::hint::unreachable_unchecked()
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}
/// Function return
///
/// Will jump to wherever the corresponding link register points to, and therefore never return.
#[inline(always)]
pub fn ret() -> ! {
#[cfg(target_arch = "aarch64")]
unsafe {
core::arch::asm!("ret", options(nomem, nostack));
core::hint::unreachable_unchecked()
}
#[cfg(not(target_arch = "aarch64"))]
unimplemented!()
}