Skip to content

Commit

Permalink
misc: replace asm! with naked_asm! in naked functions
Browse files Browse the repository at this point in the history
Fixes: error[E0787]: the `asm!` macro is not allowed in naked functions

Signed-off-by: Esteban Blanc <estblcsk@gmail.com>
  • Loading branch information
Skallwar committed Oct 10, 2024
1 parent d46f599 commit 012f9aa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions hal_aarch64/src/irq.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::arch::naked_asm;
use core::ptr;
use core::sync::atomic::{AtomicPtr, Ordering};

Expand Down Expand Up @@ -57,7 +58,7 @@ macro_rules! gen_isr_stub {
#[no_mangle]
#[repr(align(0x800))]
unsafe extern "C" fn el1_vector_table() {
core::arch::asm!(
naked_asm!(
gen_isr_stub!(),
gen_isr_stub!(),
gen_isr_stub!(),
Expand All @@ -70,7 +71,6 @@ unsafe extern "C" fn el1_vector_table() {
gen_isr_stub!(),
gen_isr_stub!(),
gen_isr_stub!(),
options(noreturn)
);
}

Expand Down
7 changes: 3 additions & 4 deletions hal_aarch64/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use cortex_a::registers::*;
use tock_registers::interfaces::Readable;

use core::arch::asm;
use core::arch::naked_asm;

pub mod cpu;
pub mod irq;
Expand All @@ -32,14 +32,13 @@ pub fn panic_info() -> PanicInfo {
#[naked]
#[no_mangle]
unsafe extern "C" fn _start() -> ! {
asm!(
naked_asm!(
"
adrp x9, STACK_START
msr spsel, xzr
mov sp, x9
b k_main
",
options(noreturn)
"
);
}

Expand Down
5 changes: 2 additions & 3 deletions hal_riscv64/src/irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use log;
use super::plic::Plic;
use super::registers;

use core::arch::asm;
use core::arch::naked_asm;
use core::ptr;
use core::sync::atomic::{AtomicPtr, Ordering};

Expand Down Expand Up @@ -228,7 +228,7 @@ extern "C" fn c_trap_dispatch(cause: u64) -> u64 {
#[no_mangle]
#[repr(align(4))]
unsafe extern "C" fn asm_trap_handler() {
asm!(
naked_asm!(
"
addi sp, sp, -0x100
Expand Down Expand Up @@ -315,7 +315,6 @@ unsafe extern "C" fn asm_trap_handler() {
addi sp, sp, 0x100
sret",
options(noreturn)
);
// Obviously this isn't done, we need to jump back to the previous context before the
// interrupt using mpp/spp and mepc/sepc.
Expand Down
4 changes: 2 additions & 2 deletions hal_riscv64/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ pub mod mm;
mod plic;
mod registers;

use core::arch::asm;
use core::arch::naked_asm;

pub fn panic_info() {}

#[naked]
#[no_mangle]
unsafe extern "C" fn _start() -> ! {
asm!("la sp, STACK_START", "call k_main", options(noreturn));
naked_asm!("la sp, STACK_START", "call k_main");
}

pub struct Riscv64CoreInfo;
Expand Down

0 comments on commit 012f9aa

Please sign in to comment.