- File:
-
- 1 edited
-
libcfa/src/concurrency/CtxSwitch-x86_64.S (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/CtxSwitch-x86_64.S
r0c4a90d r09f357ec 7 7 // CtxSwitch-x86_64.S -- 8 8 // 9 // Author : Peter A. Buhr10 // Created On : Mon Aug 10 08:10:26 20209 // Author : Thierry Delisle 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Oct 24 14:36:25 2020 13 // Update Count : 10 12 // Last Modified On : Fri Jul 21 22:28:11 2017 13 // Update Count : 1 14 // 15 // This library is free software; you can redistribute it and/or modify it 16 // under the terms of the GNU Lesser General Public License as published by the 17 // Free Software Foundation; either version 2.1 of the License, or (at your 18 // option) any later version. 19 // 20 // This library is distributed in the hope that it will be useful, but WITHOUT 21 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 23 // for more details. 24 // 25 // You should have received a copy of the GNU Lesser General Public License 26 // along with this library. 14 27 // 15 28 16 // The context switch routine requires the initial the stack of a thread to 17 // look like the thread has saved its context in the normal manner. 29 // This context switch routine depends on the fact that the stack of a new 30 // thread has been set up to look like the thread has saved its context in 31 // the normal manner. 32 // 33 // void CtxSwitch( machine_context *from, machine_context *to ); 18 34 19 // Offsets must synchronized with the __stack_context_t in invoke.h. 35 // Offsets in the context structure. This needs to be synchronized with the 36 // high level code a little better. 20 37 21 38 #define PTR_BYTE 8 … … 23 40 #define FP_OFFSET ( 1 * PTR_BYTE ) 24 41 25 // Context switch between coroutines/tasks. 26 // void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) ; 27 // Arguments "from" in register rdi, "to" in register rsi. 28 29 .file "CtxSwitch-x86_64.S" 42 //----------------------------------------------------------------------------- 43 // Regular context switch routine which enables switching from one context to anouther 30 44 .text 31 45 .align 2 32 .glob al __cfactx_switch33 .type __cfactx_switch, @function34 __cfactx_switch:46 .globl CtxSwitch 47 .type CtxSwitch, @function 48 CtxSwitch: 35 49 36 50 // Save volatile registers on the stack. … … 63 77 64 78 ret 65 .size __cfactx_switch, .-__cfactx_switch79 .size CtxSwitch, .-CtxSwitch 66 80 67 // Stub to create new stacks which can be context switched to 68 // void __cfactx_invoke_stub( void ); 69 81 //----------------------------------------------------------------------------- 82 // Stub used to create new stacks which are ready to be context switched to 70 83 .text 71 84 .align 2 72 .glob al __cfactx_invoke_stub73 .type __cfactx_invoke_stub, @function74 __cfactx_invoke_stub:75 movq %rbx, %rdi // move main and this to first two arguments85 .globl CtxInvokeStub 86 .type CtxInvokeStub, @function 87 CtxInvokeStub: 88 movq %rbx, %rdi 76 89 movq %r12, %rsi 77 jmp *%r13 // jmp to invoke78 .size __cfactx_invoke_stub, .-__cfactx_invoke_stub90 jmp *%r13 91 .size CtxInvokeStub, .-CtxInvokeStub 79 92 80 93 // Local Variables: // 81 // mode: asm//94 // mode: c // 82 95 // tab-width: 4 // 83 96 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.