Skip to content

Commit bfda4cb

Browse files
committed
rt: use core::arch::naked_asm in naked functions to ensure build under rustc nightly 2024-10-07
Ref: rust-lang/rust#128651 Signed-off-by: Zhouqi Jiang <[email protected]>
1 parent 6ee8ebf commit bfda4cb

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

bouffalo-rt/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Bouffalo chip ROM runtime library.
2-
#![feature(naked_functions, asm_const)]
2+
#![feature(naked_functions)]
33
#![no_std]
44

55
#[macro_use]

bouffalo-rt/src/soc/bl616.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use core::ops::Deref;
88
#[link_section = ".text.entry"]
99
#[export_name = "_start"]
1010
unsafe extern "C" fn start() -> ! {
11-
use {crate::Stack, core::arch::asm};
11+
use {crate::Stack, core::arch::naked_asm};
1212
const LEN_STACK: usize = 1 * 1024;
1313
#[link_section = ".bss.uninit"]
1414
static mut STACK: Stack<LEN_STACK> = Stack([0; LEN_STACK]);
15-
asm!(
15+
naked_asm!(
1616
" la sp, {stack}
1717
li t0, {hart_stack_size}
1818
add sp, sp, t0",
@@ -37,7 +37,6 @@ unsafe extern "C" fn start() -> ! {
3737
stack = sym STACK,
3838
hart_stack_size = const LEN_STACK,
3939
main = sym main,
40-
options(noreturn)
4140
)
4241
}
4342

bouffalo-rt/src/soc/bl702.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::HalFlashConfig;
88
use crate::Stack;
99

1010
#[cfg(feature = "bl702")]
11-
use core::arch::asm;
11+
use core::arch::naked_asm;
1212
use core::ops::Deref;
1313

1414
#[cfg(feature = "bl702")]
@@ -21,7 +21,7 @@ const LEN_STACK: usize = 1 * 1024;
2121
unsafe extern "C" fn start() -> ! {
2222
#[link_section = ".bss.uninit"]
2323
static mut STACK: Stack<LEN_STACK> = Stack([0; LEN_STACK]);
24-
asm!(
24+
naked_asm!(
2525
" la sp, {stack}
2626
li t0, {hart_stack_size}
2727
add sp, sp, t0",
@@ -46,7 +46,6 @@ unsafe extern "C" fn start() -> ! {
4646
stack = sym STACK,
4747
hart_stack_size = const LEN_STACK,
4848
main = sym main,
49-
options(noreturn)
5049
)
5150
}
5251

bouffalo-rt/src/soc/bl808.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{HalBasicConfig, HalFlashConfig, HalPatchCfg};
55
all(feature = "bl808-mcu", target_arch = "riscv32"),
66
all(feature = "bl808-dsp", target_arch = "riscv64")
77
))]
8-
use core::arch::asm;
8+
use core::arch::naked_asm;
99
use core::ops::Deref;
1010

1111
#[cfg(all(feature = "bl808-mcu", target_arch = "riscv32"))]
@@ -17,7 +17,7 @@ unsafe extern "C" fn start() -> ! {
1717
const LEN_STACK_MCU: usize = 1 * 1024;
1818
#[link_section = ".bss.uninit"]
1919
static mut STACK: Stack<LEN_STACK_MCU> = Stack([0; LEN_STACK_MCU]);
20-
asm!(
20+
naked_asm!(
2121
" la sp, {stack}
2222
li t0, {hart_stack_size}
2323
add sp, sp, t0",
@@ -57,7 +57,6 @@ unsafe extern "C" fn start() -> ! {
5757
stack_protect_pmp_address_end = const {0x62030000},
5858
stack_protect_pmp_flags = const 0b00001000, // -r, -w, -x, tor, not locked
5959
main = sym main,
60-
options(noreturn)
6160
)
6261
}
6362

@@ -70,7 +69,7 @@ unsafe extern "C" fn start() -> ! {
7069
const LEN_STACK_DSP: usize = 4 * 1024;
7170
#[link_section = ".bss.uninit"]
7271
static mut STACK: Stack<LEN_STACK_DSP> = Stack([0; LEN_STACK_DSP]);
73-
asm!(
72+
naked_asm!(
7473
" la sp, {stack}
7574
li t0, {hart_stack_size}
7675
add sp, sp, t0",
@@ -106,7 +105,6 @@ unsafe extern "C" fn start() -> ! {
106105
stack_protect_pmp_address = const {(0x3E000000 >> 2) + (16 * 1024 * 1024 >> 3) - 1},
107106
stack_protect_pmp_flags = const 0b00011000, // -r, -w, -x, napot, not locked
108107
main = sym main,
109-
options(noreturn)
110108
)
111109
}
112110

@@ -127,7 +125,7 @@ extern "Rust" {
127125
#[link_section = ".trap.trap-entry"]
128126
#[naked]
129127
unsafe extern "C" fn trap_vectored() -> ! {
130-
asm!(
128+
naked_asm!(
131129
".p2align 2",
132130
"j {exceptions}",
133131
"j {supervisor_software}",
@@ -156,7 +154,6 @@ unsafe extern "C" fn trap_vectored() -> ! {
156154
supervisor_external = sym reserved,
157155
thead_hpm_overflow = sym reserved,
158156
reserved = sym reserved,
159-
options(noreturn)
160157
)
161158
}
162159

@@ -166,7 +163,7 @@ unsafe extern "C" fn trap_vectored() -> ! {
166163
))]
167164
#[naked]
168165
unsafe extern "C" fn reserved() -> ! {
169-
asm!("1: j 1b", options(noreturn))
166+
naked_asm!("1: j 1b")
170167
}
171168

172169
#[cfg(any(
@@ -183,7 +180,7 @@ extern "C" {
183180
))]
184181
#[naked]
185182
unsafe extern "C" fn exceptions_trampoline() -> ! {
186-
asm!(
183+
naked_asm!(
187184
"addi sp, sp, -19*8",
188185
"sd ra, 0*8(sp)",
189186
"sd t0, 1*8(sp)",
@@ -235,7 +232,6 @@ unsafe extern "C" fn exceptions_trampoline() -> ! {
235232
"addi sp, sp, 19*8",
236233
"mret",
237234
rust_exceptions = sym exceptions,
238-
options(noreturn)
239235
)
240236
}
241237

@@ -245,7 +241,7 @@ unsafe extern "C" fn exceptions_trampoline() -> ! {
245241
))]
246242
#[naked]
247243
unsafe extern "C" fn machine_external_trampoline() -> ! {
248-
asm!(
244+
naked_asm!(
249245
"addi sp, sp, -19*8",
250246
"sd ra, 0*8(sp)",
251247
"sd t0, 1*8(sp)",
@@ -297,7 +293,6 @@ unsafe extern "C" fn machine_external_trampoline() -> ! {
297293
"addi sp, sp, 19*8",
298294
"mret",
299295
rust_all_traps = sym rust_bl808_dsp_machine_external,
300-
options(noreturn)
301296
)
302297
}
303298

0 commit comments

Comments
 (0)