- File:
-
- 1 edited
-
libcfa/src/concurrency/CtxSwitch-i386.S (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/CtxSwitch-i386.S
ra4bdbcd rb78129a 10 10 // Created On : Tue Dec 6 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 6 18:23:37 2020 13 // Update Count : 5 12 // Last Modified On : Fri Jul 21 22:29:25 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 4 22 39 #define SP_OFFSET ( 0 * PTR_BYTE ) 23 40 #define FP_OFFSET ( 1 * PTR_BYTE ) 41 #define PC_OFFSET ( 2 * PTR_BYTE ) 24 42 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 4(%esp), "to" in register 20(%esp)28 29 .file "CtxSwitch-i386.S"30 43 .text 31 44 .align 2 32 .glob al __cfactx_switch33 .type __cfactx_switch, @function34 __cfactx_switch:45 .globl CtxSwitch 46 .type CtxSwitch, @function 47 CtxSwitch: 35 48 36 49 // Copy the "from" context argument from the stack to register eax 37 // Return address is at 0(%esp), with parameters following .50 // Return address is at 0(%esp), with parameters following 38 51 39 52 movl 4(%esp),%eax … … 50 63 movl %ebp,FP_OFFSET(%eax) 51 64 52 // Copy the "to" context argument from the stack to register eax . Having53 // pushed 3 words (= 12 bytes) on the stack, the argument is now at54 // 8 + 12 = 20(%esp).65 // Copy the "to" context argument from the stack to register eax 66 // Having pushed three words (= 12 bytes) on the stack, the 67 // argument is now at 8 + 12 = 20(%esp) 55 68 56 69 movl 20(%esp),%eax … … 70 83 71 84 ret 72 .size __cfactx_switch, .-__cfactx_switch85 .size CtxSwitch, .-CtxSwitch 73 86 74 87 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.