Add ecall/ebreak
This commit is contained in:
+4
-6
@@ -15,12 +15,6 @@ SECTIONS {
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
. = 0x20000;
|
||||
|
||||
.vectors : {
|
||||
*(.text.vectors)
|
||||
}
|
||||
|
||||
. = 0x20000000;
|
||||
|
||||
.data : {
|
||||
@@ -32,4 +26,8 @@ SECTIONS {
|
||||
.bss : {
|
||||
*(.bss*)
|
||||
}
|
||||
|
||||
. = 0x20400000;
|
||||
|
||||
.end : {}
|
||||
}
|
||||
|
||||
+15
-2
@@ -4,19 +4,32 @@
|
||||
.option push
|
||||
.option norvc
|
||||
__entry:
|
||||
__reset: j fw_entry
|
||||
__exception: j fw_exception_entry
|
||||
|
||||
fw_entry:
|
||||
la sp, stack_top
|
||||
jal {firmware_main}
|
||||
fw_exception_entry:
|
||||
mv tp, sp
|
||||
la sp, exception_stack_top
|
||||
jal {firmware_exception}
|
||||
j .
|
||||
|
||||
.option pop
|
||||
.popsection // .text.entry
|
||||
|
||||
.pushsection .text.vectors
|
||||
.pushsection .text.vectors, "ax"
|
||||
.global __vector
|
||||
__vector:
|
||||
j .
|
||||
.popsection // .text.vectors
|
||||
|
||||
.pushsection .bss
|
||||
stack_bottom:
|
||||
.skip 2048
|
||||
.skip 65536
|
||||
stack_top:
|
||||
exception_stack_bottom:
|
||||
.skip 65536
|
||||
exception_stack_top:
|
||||
.popsection // .bss
|
||||
|
||||
+12
-2
@@ -35,8 +35,18 @@ unsafe extern "C" fn firmware_main() -> ! {
|
||||
loop {
|
||||
// TODO pause/system/fence instruction not implemented
|
||||
// core::hint::spin_loop();
|
||||
core::arch::asm!("nop");
|
||||
core::arch::asm!("ebreak");
|
||||
}
|
||||
}
|
||||
|
||||
global_asm!(include_str!("entry.S"), firmware_main = sym firmware_main);
|
||||
unsafe extern "C" fn firmware_exception() {
|
||||
use fmt::Write;
|
||||
let mut d = D;
|
||||
writeln!(d, "In exception handler").ok();
|
||||
}
|
||||
|
||||
global_asm!(
|
||||
include_str!("entry.S"),
|
||||
firmware_main = sym firmware_main,
|
||||
firmware_exception = sym firmware_exception
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user