forked from rust-embedded/riscv-rt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
141 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Entry point of all programs (_start). | ||
|
||
It initializes DWARF call frame information, the stack pointer, the | ||
frame pointer (needed for closures to work in start_rust) and the global | ||
pointer. Then it calls _start_rust. | ||
*/ | ||
|
||
.section .init, "ax" | ||
.global _start | ||
|
||
_start: | ||
.cfi_startproc | ||
.cfi_undefined ra | ||
|
||
// .option push | ||
// .option norelax | ||
lui gp, %hi(__global_pointer$) | ||
addi gp, gp, %lo(__global_pointer$) | ||
// .option pop | ||
|
||
lui sp, %hi(_stack_start) | ||
addi sp, sp, %lo(_stack_start) | ||
|
||
add s0, sp, zero | ||
|
||
jal zero, _start_rust | ||
|
||
.cfi_endproc | ||
|
||
|
||
/* | ||
Trap entry point (_start_trap) | ||
|
||
Saves caller saved registers ra, t0..6, a0..7, calls _start_trap_rust, | ||
restores caller saved registers and then returns. | ||
*/ | ||
.section .trap, "ax" | ||
.align 4 | ||
.global _start_trap | ||
|
||
_start_trap: | ||
addi sp, sp, -16*4 | ||
|
||
sw ra, 0*4(sp) | ||
sw t0, 1*4(sp) | ||
sw t1, 2*4(sp) | ||
sw t2, 3*4(sp) | ||
sw t3, 4*4(sp) | ||
sw t4, 5*4(sp) | ||
sw t5, 6*4(sp) | ||
sw t6, 7*4(sp) | ||
sw a0, 8*4(sp) | ||
sw a1, 9*4(sp) | ||
sw a2, 10*4(sp) | ||
sw a3, 11*4(sp) | ||
sw a4, 12*4(sp) | ||
sw a5, 13*4(sp) | ||
sw a6, 14*4(sp) | ||
sw a7, 15*4(sp) | ||
|
||
jal ra, _start_trap_rust | ||
|
||
lw ra, 0*4(sp) | ||
lw t0, 1*4(sp) | ||
lw t1, 2*4(sp) | ||
lw t2, 3*4(sp) | ||
lw t3, 4*4(sp) | ||
lw t4, 5*4(sp) | ||
lw t5, 6*4(sp) | ||
lw t6, 7*4(sp) | ||
lw a0, 8*4(sp) | ||
lw a1, 9*4(sp) | ||
lw a2, 10*4(sp) | ||
lw a3, 11*4(sp) | ||
lw a4, 12*4(sp) | ||
lw a5, 13*4(sp) | ||
lw a6, 14*4(sp) | ||
lw a7, 15*4(sp) | ||
|
||
addi sp, sp, 16*4 | ||
mret | ||
|
||
|
||
/* Make sure there is an abort when linking */ | ||
.section .init | ||
.globl abort | ||
abort: | ||
jal zero, _start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
crate=riscv-rt | ||
|
||
# remove existing blobs because otherwise this will append object files to the old blobs | ||
rm -f bin/*.a | ||
|
||
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imac asm.S -o bin/$crate.o | ||
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o | ||
cp bin/riscv32imac-unknown-none-elf.a bin/riscv32imc-unknown-none-elf.a | ||
|
||
rm bin/$crate.o |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# Checks that the blobs are up to date with the committed assembly files | ||
|
||
set -euxo pipefail | ||
|
||
for lib in $(ls bin/*.a); do | ||
filename=$(basename $lib) | ||
riscv64-unknown-elf-objdump -Cd $lib > bin/${filename%.a}.before | ||
done | ||
|
||
./assemble.sh | ||
|
||
for lib in $(ls bin/*.a); do | ||
filename=$(basename $lib) | ||
riscv64-unknown-elf-objdump -Cd $lib > bin/${filename%.a}.after | ||
done | ||
|
||
for cksum in $(ls bin/*.after); do | ||
diff -u $cksum ${cksum%.after}.before | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters