|
Line 0
Link Here
|
|
|
1 |
# |
| 2 |
# Context switch for AMD64 small model. (Position-independent code.) |
| 3 |
# |
| 4 |
# See http://www.amd64.org/ for information about AMD64 programming. |
| 5 |
# |
| 6 |
|
| 7 |
.file "rswitch.s" |
| 8 |
|
| 9 |
.section .rodata |
| 10 |
.L0: .string "new_context() returned in coswitch" |
| 11 |
|
| 12 |
.globl coswitch |
| 13 |
|
| 14 |
.text |
| 15 |
.globl coswitch |
| 16 |
.type coswitch, @function |
| 17 |
coswitch: |
| 18 |
# coswitch(old_cstate, new_cstate, first) |
| 19 |
# |
| 20 |
# %rdi old_cstate |
| 21 |
# %rsi new_cstate |
| 22 |
# %edx first (equals 0 if first activation) |
| 23 |
# |
| 24 |
|
| 25 |
movq %rsp, 0(%rdi) # Old stack pointer -> old_cstate[0] |
| 26 |
movq 0(%rsi), %rsp # new_cstate[0] -> new stack pointer |
| 27 |
orl %edx, %edx # Is this the first activation? |
| 28 |
je .L1 # If so, skip. |
| 29 |
ret # Otherwise we are done. |
| 30 |
.L1: xorl %edi, %edi # Call new_context((int) 0, (ptr) 0) |
| 31 |
xorl %esi, %esi # (Implicitly zero-extended to 64 bits) |
| 32 |
call new_context@PLT |
| 33 |
leaq .L0(%rip), %rdi # Call syserr(...) |
| 34 |
movl $0, %eax |
| 35 |
jmp syserr@PLT |