Skip to content

Commit

Permalink
Backport boost context asm for riscv64
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Aug 15, 2021
1 parent 87782c3 commit 6ca6657
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions thirdparty/boost/asm/jump_riscv64_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jump_fcontext:
# prepare stack for GP + FPU
addi sp, sp, -0xd0

beqz a3, .L1

# save fs0 - fs11
fsd fs0, 0x00(sp)
fsd fs1, 0x08(sp)
Expand All @@ -79,6 +81,7 @@ jump_fcontext:
fsd fs9, 0x48(sp)
fsd fs10, 0x50(sp)
fsd fs11, 0x58(sp)
.L1:

# save s0-s11, ra
sd s0, 0x60(sp)
Expand All @@ -98,12 +101,13 @@ jump_fcontext:
# save RA as PC
sd ra, 0xc8(sp)

# store SP (pointing to context-data) in A2
mv a2, sp
# store SP (pointing to context-data) in A0
sd sp, (a0)

# restore SP (pointing to context-data) from A0
mv sp, a0
# restore SP (pointing to context-data) from A1
mv sp, a1

beqz a3, .L2
# load fs0 - fs11
fld fs0, 0x00(sp)
fld fs1, 0x08(sp)
Expand All @@ -117,6 +121,7 @@ jump_fcontext:
fld fs9, 0x48(sp)
fld fs10, 0x50(sp)
fld fs11, 0x58(sp)
.L2:

# load s0-s11,ra
ld s0, 0x60(sp)
Expand All @@ -133,9 +138,7 @@ jump_fcontext:
ld s11, 0xb8(sp)
ld ra, 0xc0(sp)

# return transfer_t from jump
# pass transfer_t as first arg in context function
# a0 == FCTX, a1 == DATA
# use A2 as return value
mv a0, a2

# load pc
Expand Down

0 comments on commit 6ca6657

Please sign in to comment.