Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv: Add clear_bss to crt0 if image is binary #82

Merged
merged 3 commits into from
Jun 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions elfloader-tool/src/arch-riscv/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ _start:
addi gp, gp, %pcrel_lo(1b)
.option pop

/* a0 should have hart id, store it in temp so as not to clobber from HSM calls */
mv t3, a0
/* a0 should have hart id, store it in s0 so as not to clobber from HSM calls */
mv s0, a0

#ifdef CONFIG_IMAGE_BINARY
/* Clear the BSS before we get to do anything more specific */
axel-h marked this conversation as resolved.
Show resolved Hide resolved
jal clear_bss
#endif

/* Check Heart State Management extension exists so we can use that to switch harts
if we are not hart 1, otherwise rely on the legacy extension. */
Expand All @@ -40,7 +45,7 @@ _start:
or an extension-specific non-zero value if it is available.*/

jal spi_probe_extension
mv a0, t3
mv a0, s0
li s1, 1
blt x1, s1, _start1

Expand All @@ -49,7 +54,7 @@ _start:
li t2, 1
amoadd.w t1, t2, (t1)

mv a0, t3
mv a0, s0
li s0, CONFIG_FIRST_HART_ID
beq a0, s0, _start1

Expand All @@ -62,6 +67,7 @@ hsm_switch_hart:
li a2, 0 // passed in a1 when new hart starts, this is the logical hart_id
ecall

mv a0, s0 // Copy the ID of the HART again, since we've clobbered a0
j secondary_harts

_start1:
Expand Down