Browse Source

Merge pull request #63 from woshiluo/patch-1

fix: use naked_asm for payload and fdt include
guttatus 1 month ago
parent
commit
192b67c89c
2 changed files with 9 additions and 14 deletions
  1. 5 7
      prototyper/src/firmware/mod.rs
  2. 4 7
      prototyper/src/firmware/payload.rs

+ 5 - 7
prototyper/src/firmware/mod.rs

@@ -11,7 +11,8 @@ cfg_if::cfg_if! {
     }
 }
 
-use core::arch::asm;
+#[allow(unused)]
+use core::arch::{asm, naked_asm};
 use core::ops::Range;
 use riscv::register::mstatus;
 
@@ -26,14 +27,11 @@ pub struct BootHart {
 }
 
 #[naked]
-#[link_section = ".rodata.fdt"]
+#[unsafe(link_section = ".rodata.fdt")]
 #[repr(align(16))]
 #[cfg(feature = "fdt")]
-pub unsafe extern "C" fn raw_fdt() {
-    asm!(
-        concat!(".incbin \"", env!("PROTOTYPER_FDT_PATH"), "\""),
-        options(noreturn)
-    );
+pub extern "C" fn raw_fdt() {
+    unsafe { naked_asm!(concat!(".incbin \"", env!("PROTOTYPER_FDT_PATH"), "\""),) }
 }
 
 #[inline]

+ 4 - 7
prototyper/src/firmware/payload.rs

@@ -1,4 +1,4 @@
-use core::arch::asm;
+use core::arch::naked_asm;
 use core::sync::atomic::{AtomicBool, Ordering};
 use riscv::register::mstatus;
 
@@ -20,12 +20,9 @@ pub fn get_boot_info(_nonstandard_a2: usize) -> BootInfo {
 }
 
 #[naked]
-#[link_section = ".payload"]
-pub unsafe extern "C" fn payload_image() {
-    asm!(
-        concat!(".incbin \"", env!("PROTOTYPER_PAYLOAD_PATH"), "\""),
-        options(noreturn)
-    );
+#[unsafe(link_section = ".payload")]
+pub extern "C" fn payload_image() {
+    unsafe { naked_asm!(concat!(".incbin \"", env!("PROTOTYPER_PAYLOAD_PATH"), "\""),) }
 }
 
 #[inline]