diff options
author | johannst <johannes.stoelp@gmail.com> | 2020-09-29 04:31:51 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2020-09-29 04:31:51 +0200 |
commit | 533a9e57de8cb74594499f625810ad812359d3fb (patch) | |
tree | 8e8eed62ab86416170b4c9716b36bae736d6b3a8 /lib/arch/arm64/yield.s | |
parent | 48142327c37f716da307bd4a9b22576ad0a67c22 (diff) | |
download | matcha-threads-533a9e57de8cb74594499f625810ad812359d3fb.tar.gz matcha-threads-533a9e57de8cb74594499f625810ad812359d3fb.zip |
added basic arm64 support
Diffstat (limited to 'lib/arch/arm64/yield.s')
-rw-r--r-- | lib/arch/arm64/yield.s | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/arch/arm64/yield.s b/lib/arch/arm64/yield.s new file mode 100644 index 0000000..63a4051 --- /dev/null +++ b/lib/arch/arm64/yield.s @@ -0,0 +1,42 @@ +# Copyright (c) 2020 Johannes Stoelp + + .arch armv8-a + .section .text, "ax", @progbits + + # extern "C" void yield(const void* new_stack, void* const* old_stack); + # ^^^^^^^^^ ^^^^^^^^^ + # rdi rsi + .global yield + .type yield, @function +yield: + .cfi_startproc + // prologue + stp x29, x30, [sp, -16]! + mov x29, sp + + // push callee saved registers + stp x27, x28, [sp, -16]! + stp x25, x26, [sp, -16]! + stp x23, x24, [sp, -16]! + stp x21, x22, [sp, -16]! + stp x19, x20, [sp, -16]! + + // arg0: x0 holds new stack + // arg1: x1 holds addr to location current stack must be saved + mov x2, sp + str x2, [x1] // save current stack ptr + mov sp, x0 // switch to new stack ptr + + // pop callee saved registers + ldp x19, x20, [sp], 16 + ldp x21, x22, [sp], 16 + ldp x23, x24, [sp], 16 + ldp x25, x26, [sp], 16 + ldp x27, x28, [sp], 16 + + // epilogue + ldp x29, x30, [sp], 16 + + ret + .cfi_endproc + .size yield, .-yield |