Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 217:ecbdb74cad97 Common_Ancestor
Made separate Hardware_Dependent directory and moved primitives to there
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Sat, 10 Mar 2012 20:38:25 -0800 |
| parents | 712218cdc4ba |
| children | 82f7defac851 |
| files | Hardware_Dependent/VMS__HW_measurement.h Hardware_Dependent/VMS__primitives.c Hardware_Dependent/VMS__primitives.h Hardware_Dependent/VMS__primitives.s VMS__HW_dependent.c VMS__HW_dependent.h VMS__HW_dependent.s |
| diffstat | 7 files changed, 310 insertions(+), 296 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Hardware_Dependent/VMS__HW_measurement.h Sat Mar 10 20:38:25 2012 -0800 1.3 @@ -0,0 +1,49 @@ 1.4 +/* 1.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 + * Licensed under GNU General Public License version 2 1.7 + * 1.8 + * Author: seanhalle@yahoo.com 1.9 + * 1.10 + */ 1.11 + 1.12 +#ifndef _VMS__HW_MEASUREMENT_H 1.13 +#define _VMS__HW_MEASUREMENT_H 1.14 +#define _GNU_SOURCE 1.15 + 1.16 +//=================== Macros to Capture Measurements ====================== 1.17 +// 1.18 +//===== RDTSC wrapper ===== 1.19 +//Also runs with x86_64 code 1.20 +#define saveTSCLowHigh(lowHighIn) \ 1.21 + asm volatile("RDTSC; \ 1.22 + movl %%eax, %0; \ 1.23 + movl %%edx, %1;" \ 1.24 + /* outputs */ : "=m" (lowHighIn.lowHigh[0]), "=m" (lowHighIn.lowHigh[1])\ 1.25 + /* inputs */ : \ 1.26 + /* clobber */ : "%eax", "%edx" \ 1.27 + ); 1.28 + 1.29 +#define saveTimeStampCountInto(low, high) \ 1.30 + asm volatile("RDTSC; \ 1.31 + movl %%eax, %0; \ 1.32 + movl %%edx, %1;" \ 1.33 + /* outputs */ : "=m" (low), "=m" (high)\ 1.34 + /* inputs */ : \ 1.35 + /* clobber */ : "%eax", "%edx" \ 1.36 + ); 1.37 + 1.38 +#define saveLowTimeStampCountInto(low) \ 1.39 + asm volatile("RDTSC; \ 1.40 + movl %%eax, %0;" \ 1.41 + /* outputs */ : "=m" (low) \ 1.42 + /* inputs */ : \ 1.43 + /* clobber */ : "%eax", "%edx" \ 1.44 + ); 1.45 + 1.46 + //For code that calculates normalization-offset between TSC counts of 1.47 + // different cores. 1.48 +//#define NUM_TSC_ROUND_TRIPS 10 1.49 + 1.50 + 1.51 +#endif /* */ 1.52 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/Hardware_Dependent/VMS__primitives.c Sat Mar 10 20:38:25 2012 -0800 2.3 @@ -0,0 +1,53 @@ 2.4 +/* 2.5 + * This File contains all hardware dependent C code. 2.6 + */ 2.7 + 2.8 + 2.9 +#include "../VMS.h" 2.10 + 2.11 +/*Set up the stack with __cdecl structure on it 2.12 + * Except doing a trick for 64 bits, where put top-level fn pointer on 2.13 + * stack, then call an assembly helper that copies it into a reg and 2.14 + * jumps to it. So, set the resumeInstrPtr to the helper-assembly. 2.15 + *No need to save registers on old stack frame, because there's no old 2.16 + * animator state to return to 2.17 + * 2.18 + *This was factored into separate function because it's used stand-alone in 2.19 + * some wrapper-libraries (but only "int" version, to warn users to check 2.20 + * carefully that it's safe) 2.21 + */ 2.22 +inline void 2.23 +VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, 2.24 + void *dataParam) 2.25 + { void *stackPtr; 2.26 + 2.27 +// Start of Hardware dependent part 2.28 + 2.29 + //Set slave's instr pointer to a helper Fn that copies params from stack 2.30 + slaveVP->resumeInstrPtr = (TopLevelFnPtr)&startUpTopLevelFn; 2.31 + 2.32 + //fnPtr takes two params -- void *dataParam & void *animSlv 2.33 + // Stack grows *down*, so start it at highest stack addr, minus room 2.34 + // for 2 params + return addr. 2.35 + stackPtr = 2.36 + (void *)slaveVP->startOfStack + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*); 2.37 + 2.38 + //setup __cdecl on stack 2.39 + //Normally, return Addr is in loc pointed to by stackPtr, but doing a 2.40 + // trick for 64 bit arch, where put ptr to top-level fn there instead, 2.41 + // and set resumeInstrPtr to a helper-fn that copies the top-level 2.42 + // fn ptr and params into registers. 2.43 + //Then, dataParam is at stackPtr + 8 bytes, & animating SlaveVP above 2.44 + *((SlaveVP**)stackPtr + 2 ) = slaveVP; //rightmost param 2.45 + *((void**)stackPtr + 1 ) = dataParam; //next param to left 2.46 + *((void**)stackPtr) = (void*)fnPtr; //copied to reg by helper Fn 2.47 + 2.48 + 2.49 +// end of Hardware dependent part 2.50 + 2.51 + //core controller will switch to stack & frame pointers stored in slave, 2.52 + // suspend will save processor's stack and frame into slave 2.53 + slaveVP->stackPtr = slaveVP->startOfStack; 2.54 + slaveVP->framePtr = slaveVP->startOfStack; 2.55 + } 2.56 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/Hardware_Dependent/VMS__primitives.h Sat Mar 10 20:38:25 2012 -0800 3.3 @@ -0,0 +1,41 @@ 3.4 +/* 3.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 3.6 + * Licensed under GNU General Public License version 2 3.7 + * 3.8 + * Author: seanhalle@yahoo.com 3.9 + * 3.10 + */ 3.11 + 3.12 +#ifndef _VMS__PRIMITIVES_H 3.13 +#define _VMS__PRIMITIVES_H 3.14 +#define _GNU_SOURCE 3.15 + 3.16 +void 3.17 +recordCoreCtlrReturnLabelAddr(void **returnAddress); 3.18 + 3.19 +void 3.20 +switchToSlv(SlaveVP *nextSlave); 3.21 + 3.22 +void 3.23 +switchToCoreCtlr(SlaveVP *nextSlave); 3.24 + 3.25 +void 3.26 +masterSwitchToCoreCtlr(SlaveVP *nextSlave); 3.27 + 3.28 +void 3.29 +startUpTopLevelFn(); 3.30 + 3.31 +void * 3.32 +asmTerminateCoreCtlr(SlaveVP *currSlv); 3.33 + 3.34 +#define flushRegisters() \ 3.35 + asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15") 3.36 + 3.37 +void 3.38 +VMS_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc); 3.39 + 3.40 +void 3.41 +VMS_int__return_to_addr_in_ptd_to_loc(void *ptdToLoc); 3.42 + 3.43 +#endif /* _VMS__HW_DEPENDENT_H */ 3.44 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/Hardware_Dependent/VMS__primitives.s Sat Mar 10 20:38:25 2012 -0800 4.3 @@ -0,0 +1,167 @@ 4.4 +.data 4.5 + 4.6 + 4.7 +.text 4.8 + 4.9 +//Save return label address for the coreCtlr to pointer 4.10 +//Arguments: Pointer to variable holding address 4.11 +.globl recordCoreCtlrReturnLabelAddr 4.12 +recordCoreCtlrReturnLabelAddr: 4.13 + movq $coreCtlrReturn, %rcx #load label address 4.14 + movq %rcx, (%rdi) #save address to pointer 4.15 + ret 4.16 + 4.17 + 4.18 +//Trick for 64 bit arch -- copies args from stack into regs, then does jmp to 4.19 +// the top-level function, which was pointed to by the stack-ptr 4.20 +.globl startUpTopLevelFn 4.21 +startUpTopLevelFn: 4.22 + movq %rdi , %rsi #get second argument from first argument of switchSlv 4.23 + movq 0x08(%rsp), %rdi #get first argument from stack 4.24 + movq (%rsp) , %rax #get top-level function's addr from stack 4.25 + jmp *%rax #jump to the top-level function 4.26 + 4.27 +//Switches form CoreCtlr to either a normal Slv VP or the Master VP 4.28 +//switch to VP's stack and frame ptr then jump to VP's next-instr-ptr 4.29 +/* SlaveVP offsets: 4.30 + * 0x10 stackPtr 4.31 + * 0x18 framePtr 4.32 + * 0x20 resumeInstrPtr 4.33 + * 0x30 coreCtlrFramePtr 4.34 + * 0x38 coreCtlrStackPtr 4.35 + * 4.36 + * _VMSMasterEnv offsets: 4.37 + * 0x48 coreCtlrReturnPt 4.38 + * 0x54 masterLock 4.39 + */ 4.40 +.globl switchToSlv 4.41 +switchToSlv: 4.42 + #SlaveVP in %rdi 4.43 + movq %rsp , 0x38(%rdi) #save core ctlr stack pointer 4.44 + movq %rbp , 0x30(%rdi) #save core ctlr frame pointer 4.45 + movq 0x10(%rdi), %rsp #restore stack pointer 4.46 + movq 0x18(%rdi), %rbp #restore frame pointer 4.47 + movq 0x20(%rdi), %rax #get jmp pointer 4.48 + jmp *%rax #jmp to Slv 4.49 +coreCtlrReturn: 4.50 + ret 4.51 + 4.52 + 4.53 +//switches to core controller. saves return address 4.54 +/* SlaveVP offsets: 4.55 + * 0x10 stackPtr 4.56 + * 0x18 framePtr 4.57 + * 0x20 resumeInstrPtr 4.58 + * 0x30 coreCtlrFramePtr 4.59 + * 0x38 coreCtlrStackPtr 4.60 + * 4.61 + * _VMSMasterEnv offsets: 4.62 + * 0x48 coreCtlrReturnPt 4.63 + * 0x54 masterLock 4.64 + */ 4.65 +.globl switchToCoreCtlr 4.66 +switchToCoreCtlr: 4.67 + #SlaveVP in %rdi 4.68 + movq $SlvReturn, 0x20(%rdi) #store return address 4.69 + movq %rsp , 0x10(%rdi) #save stack pointer 4.70 + movq %rbp , 0x18(%rdi) #save frame pointer 4.71 + movq 0x38(%rdi), %rsp #restore stack pointer 4.72 + movq 0x30(%rdi), %rbp #restore frame pointer 4.73 + movq $_VMSMasterEnv, %rcx 4.74 + movq (%rcx) , %rcx 4.75 + movq 0x48(%rcx), %rax #get CoreCtlrStartPt 4.76 + jmp *%rax #jmp to CoreCtlr 4.77 +SlvReturn: 4.78 + ret 4.79 + 4.80 + 4.81 + 4.82 +//switches to core controller from master. saves return address 4.83 +//Releases masterLock so the next MasterLoop can be executed 4.84 +/* SlaveVP offsets: 4.85 + * 0x10 stackPtr 4.86 + * 0x18 framePtr 4.87 + * 0x20 resumeInstrPtr 4.88 + * 0x30 coreCtlrFramePtr 4.89 + * 0x38 coreCtlrStackPtr 4.90 + * 4.91 + * _VMSMasterEnv offsets: 4.92 + * 0x48 coreCtlrReturnPt 4.93 + * 0x54 masterLock 4.94 + */ 4.95 +.globl masterSwitchToCoreCtlr 4.96 +masterSwitchToCoreCtlr: 4.97 + #SlaveVP in %rdi 4.98 + movq $MasterReturn, 0x20(%rdi) #store return address 4.99 + movq %rsp , 0x10(%rdi) #save stack pointer 4.100 + movq %rbp , 0x18(%rdi) #save frame pointer 4.101 + movq 0x38(%rdi), %rsp #restore stack pointer 4.102 + movq 0x30(%rdi), %rbp #restore frame pointer 4.103 + movq $_VMSMasterEnv, %rcx 4.104 + movq (%rcx) , %rcx 4.105 + movq 0x48(%rcx), %rax #get CoreCtlr return pt 4.106 + movl $0x0 , 0x54(%rcx) #release lock 4.107 + jmp *%rax #jmp to CoreCtlr 4.108 +MasterReturn: 4.109 + ret 4.110 + 4.111 + 4.112 +//Switch to terminateCoreCtlr 4.113 +//therefor switch to coreCtlr context from master context 4.114 +// no need to call because the stack is already set up for switchSlv 4.115 +// and Slv is in %rdi 4.116 +// and both functions have the same argument. 4.117 +// do not save register of Slv because this function will never return 4.118 +/* SlaveVP offsets: 4.119 + * 0x10 stackPtr 4.120 + * 0x18 framePtr 4.121 + * 0x20 resumeInstrPtr 4.122 + * 0x30 coreCtlrFramePtr 4.123 + * 0x38 coreCtlrStackPtr 4.124 + * 4.125 + * _VMSMasterEnv offsets: 4.126 + * 0x48 coreCtlrReturnPt 4.127 + * 0x58 masterLock 4.128 + */ 4.129 +.globl asmTerminateCoreCtlr 4.130 +asmTerminateCoreCtlr: 4.131 + #SlaveVP in %rdi 4.132 + movq 0x38(%rdi), %rsp #restore stack pointer 4.133 + movq 0x30(%rdi), %rbp #restore frame pointer 4.134 + movq $terminateCoreCtlr, %rax 4.135 + jmp *%rax #jmp to CoreCtlr 4.136 + 4.137 + 4.138 +/* 4.139 + * This one for the sequential version is special. It discards the current stack 4.140 + * and returns directly from the coreCtlr after VMS_WL__dissipate_slaveVP was called 4.141 + */ 4.142 +.globl asmTerminateCoreCtlrSeq 4.143 +asmTerminateCoreCtlrSeq: 4.144 + #SlaveVP in %rdi 4.145 + movq 0x38(%rdi), %rsp #restore stack pointer 4.146 + movq 0x30(%rdi), %rbp #restore frame pointer 4.147 + #argument is in %rdi 4.148 + call VMS_int__dissipate_slaveVP 4.149 + movq %rbp , %rsp #goto the coreCtlrs stack 4.150 + pop %rbp #restore the old framepointer 4.151 + ret #return from core controller 4.152 + 4.153 + 4.154 +//Takes the return addr off the stack and saves into the loc pointed to by 4.155 +// by the parameter passed in via rdi. Return addr is at 0x8(%rbp) for 64bit 4.156 +.globl VMS_int__save_return_into_ptd_to_loc_then_do_ret 4.157 +VMS_int__save_return_into_ptd_to_loc_then_do_ret: 4.158 + movq 0x8(%rbp), %rax #get ret address, rbp is the same as in the calling function 4.159 + movq %rax, (%rdi) #write ret addr into addr passed as param field 4.160 + ret 4.161 + 4.162 + 4.163 +//Assembly code changes the return addr on the stack to the one 4.164 +// pointed to by the parameter, then returns. Stack's return addr is at 0x8(%rbp) 4.165 +.globl VMS_int__return_to_addr_in_ptd_to_loc 4.166 +VMS_int__return_to_addr_in_ptd_to_loc: 4.167 + movq (%rdi), %rax #get return addr from addr passed as param 4.168 + movq %rax, 0x8(%rbp) #write return addr to the stack of the caller 4.169 + ret 4.170 +
5.1 --- a/VMS__HW_dependent.c Sat Mar 10 20:35:38 2012 -0800 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,53 +0,0 @@ 5.4 -/* 5.5 - * This File contains all hardware dependent C code. 5.6 - */ 5.7 - 5.8 - 5.9 -#include "VMS.h" 5.10 - 5.11 -/*Set up the stack with __cdecl structure on it 5.12 - * Except doing a trick for 64 bits, where put top-level fn pointer on 5.13 - * stack, then call an assembly helper that copies it into a reg and 5.14 - * jumps to it. So, set the resumeInstrPtr to the helper-assembly. 5.15 - *No need to save registers on old stack frame, because there's no old 5.16 - * animator state to return to 5.17 - * 5.18 - *This was factored into separate function because it's used stand-alone in 5.19 - * some wrapper-libraries (but only "int" version, to warn users to check 5.20 - * carefully that it's safe) 5.21 - */ 5.22 -inline void 5.23 -VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, 5.24 - void *dataParam) 5.25 - { void *stackPtr; 5.26 - 5.27 -// Start of Hardware dependent part 5.28 - 5.29 - //Set slave's instr pointer to a helper Fn that copies params from stack 5.30 - slaveVP->resumeInstrPtr = (TopLevelFnPtr)&startUpTopLevelFn; 5.31 - 5.32 - //fnPtr takes two params -- void *dataParam & void *animSlv 5.33 - // Stack grows *down*, so start it at highest stack addr, minus room 5.34 - // for 2 params + return addr. 5.35 - stackPtr = 5.36 - (void *)slaveVP->startOfStack + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*); 5.37 - 5.38 - //setup __cdecl on stack 5.39 - //Normally, return Addr is in loc pointed to by stackPtr, but doing a 5.40 - // trick for 64 bit arch, where put ptr to top-level fn there instead, 5.41 - // and set resumeInstrPtr to a helper-fn that copies the top-level 5.42 - // fn ptr and params into registers. 5.43 - //Then, dataParam is at stackPtr + 8 bytes, & animating SlaveVP above 5.44 - *((SlaveVP**)stackPtr + 2 ) = slaveVP; //rightmost param 5.45 - *((void**)stackPtr + 1 ) = dataParam; //next param to left 5.46 - *((void**)stackPtr) = (void*)fnPtr; //copied to reg by helper Fn 5.47 - 5.48 - 5.49 -// end of Hardware dependent part 5.50 - 5.51 - //core loop will switch to stack & frame pointers stored in slave, 5.52 - // suspend will save processor's stack and frame into slave 5.53 - slaveVP->stackPtr = slaveVP->startOfStack; 5.54 - slaveVP->framePtr = slaveVP->startOfStack; 5.55 - } 5.56 -
6.1 --- a/VMS__HW_dependent.h Sat Mar 10 20:35:38 2012 -0800 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,76 +0,0 @@ 6.4 -/* 6.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 6.6 - * Licensed under GNU General Public License version 2 6.7 - * 6.8 - * Author: seanhalle@yahoo.com 6.9 - * 6.10 - */ 6.11 - 6.12 -#ifndef _VMS__HW_DEPENDENT_H 6.13 -#define _VMS__HW_DEPENDENT_H 6.14 -#define _GNU_SOURCE 6.15 - 6.16 -void 6.17 -recordCoreLoopReturnLabelAddr(void **returnAddress); 6.18 - 6.19 -void 6.20 -switchToSlv(SlaveVP *nextSlave); 6.21 - 6.22 -void 6.23 -switchToCoreLoop(SlaveVP *nextSlave); 6.24 - 6.25 -void 6.26 -masterSwitchToCoreLoop(SlaveVP *nextSlave); 6.27 - 6.28 -void 6.29 -startUpTopLevelFn(); 6.30 - 6.31 -void * 6.32 -asmTerminateCoreLoop(SlaveVP *currSlv); 6.33 - 6.34 -#define flushRegisters() \ 6.35 - asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15") 6.36 - 6.37 -void 6.38 -VMS_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc); 6.39 - 6.40 -void 6.41 -VMS_int__return_to_addr_in_ptd_to_loc(void *ptdToLoc); 6.42 - 6.43 -//=================== Macros to Capture Measurements ====================== 6.44 -// 6.45 -//===== RDTSC wrapper ===== 6.46 -//Also runs with x86_64 code 6.47 -#define saveTSCLowHigh(lowHighIn) \ 6.48 - asm volatile("RDTSC; \ 6.49 - movl %%eax, %0; \ 6.50 - movl %%edx, %1;" \ 6.51 - /* outputs */ : "=m" (lowHighIn.lowHigh[0]), "=m" (lowHighIn.lowHigh[1])\ 6.52 - /* inputs */ : \ 6.53 - /* clobber */ : "%eax", "%edx" \ 6.54 - ); 6.55 - 6.56 -#define saveTimeStampCountInto(low, high) \ 6.57 - asm volatile("RDTSC; \ 6.58 - movl %%eax, %0; \ 6.59 - movl %%edx, %1;" \ 6.60 - /* outputs */ : "=m" (low), "=m" (high)\ 6.61 - /* inputs */ : \ 6.62 - /* clobber */ : "%eax", "%edx" \ 6.63 - ); 6.64 - 6.65 -#define saveLowTimeStampCountInto(low) \ 6.66 - asm volatile("RDTSC; \ 6.67 - movl %%eax, %0;" \ 6.68 - /* outputs */ : "=m" (low) \ 6.69 - /* inputs */ : \ 6.70 - /* clobber */ : "%eax", "%edx" \ 6.71 - ); 6.72 - 6.73 - //For code that calculates normalization-offset between TSC counts of 6.74 - // different cores. 6.75 -//#define NUM_TSC_ROUND_TRIPS 10 6.76 - 6.77 - 6.78 -#endif /* _VMS__HW_DEPENDENT_H */ 6.79 -
7.1 --- a/VMS__HW_dependent.s Sat Mar 10 20:35:38 2012 -0800 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,167 +0,0 @@ 7.4 -.data 7.5 - 7.6 - 7.7 -.text 7.8 - 7.9 -//Save return label address for the coreLoop to pointer 7.10 -//Arguments: Pointer to variable holding address 7.11 -.globl saveCoreLoopReturnAddr 7.12 -recordCoreLoopReturnLabelAddr: 7.13 - movq $coreLoopReturn, %rcx #load label address 7.14 - movq %rcx, (%rdi) #save address to pointer 7.15 - ret 7.16 - 7.17 - 7.18 -//Trick for 64 bit arch -- copies args from stack into regs, then does jmp to 7.19 -// the top-level function, which was pointed to by the stack-ptr 7.20 -.globl startUpTopLevelFn 7.21 -startUpTopLevelFn: 7.22 - movq %rdi , %rsi #get second argument from first argument of switchSlv 7.23 - movq 0x08(%rsp), %rdi #get first argument from stack 7.24 - movq (%rsp) , %rax #get top-level function's addr from stack 7.25 - jmp *%rax #jump to the top-level function 7.26 - 7.27 -//Switches form CoreLoop to either a normal Slv VP or the Master VP 7.28 -//switch to VP's stack and frame ptr then jump to VP's next-instr-ptr 7.29 -/* SlaveVP offsets: 7.30 - * 0x10 stackPtr 7.31 - * 0x18 framePtr 7.32 - * 0x20 resumeInstrPtr 7.33 - * 0x30 coreLoopFramePtr 7.34 - * 0x38 coreLoopStackPtr 7.35 - * 7.36 - * _VMSMasterEnv offsets: 7.37 - * 0x48 coreLoopReturnPt 7.38 - * 0x54 masterLock 7.39 - */ 7.40 -.globl switchToSlv 7.41 -switchToSlv: 7.42 - #SlaveVP in %rdi 7.43 - movq %rsp , 0x38(%rdi) #save core loop stack pointer 7.44 - movq %rbp , 0x30(%rdi) #save core loop frame pointer 7.45 - movq 0x10(%rdi), %rsp #restore stack pointer 7.46 - movq 0x18(%rdi), %rbp #restore frame pointer 7.47 - movq 0x20(%rdi), %rax #get jmp pointer 7.48 - jmp *%rax #jmp to Slv 7.49 -coreLoopReturn: 7.50 - ret 7.51 - 7.52 - 7.53 -//switches to core loop. saves return address 7.54 -/* SlaveVP offsets: 7.55 - * 0x10 stackPtr 7.56 - * 0x18 framePtr 7.57 - * 0x20 resumeInstrPtr 7.58 - * 0x30 coreLoopFramePtr 7.59 - * 0x38 coreLoopStackPtr 7.60 - * 7.61 - * _VMSMasterEnv offsets: 7.62 - * 0x48 coreLoopReturnPt 7.63 - * 0x54 masterLock 7.64 - */ 7.65 -.globl switchToCoreLoop 7.66 -switchToCoreLoop: 7.67 - #SlaveVP in %rdi 7.68 - movq $SlvReturn, 0x20(%rdi) #store return address 7.69 - movq %rsp , 0x10(%rdi) #save stack pointer 7.70 - movq %rbp , 0x18(%rdi) #save frame pointer 7.71 - movq 0x38(%rdi), %rsp #restore stack pointer 7.72 - movq 0x30(%rdi), %rbp #restore frame pointer 7.73 - movq $_VMSMasterEnv, %rcx 7.74 - movq (%rcx) , %rcx 7.75 - movq 0x48(%rcx), %rax #get CoreLoopStartPt 7.76 - jmp *%rax #jmp to CoreLoop 7.77 -SlvReturn: 7.78 - ret 7.79 - 7.80 - 7.81 - 7.82 -//switches to core loop from master. saves return address 7.83 -//Releases masterLock so the next MasterLoop can be executed 7.84 -/* SlaveVP offsets: 7.85 - * 0x10 stackPtr 7.86 - * 0x18 framePtr 7.87 - * 0x20 resumeInstrPtr 7.88 - * 0x30 coreLoopFramePtr 7.89 - * 0x38 coreLoopStackPtr 7.90 - * 7.91 - * _VMSMasterEnv offsets: 7.92 - * 0x48 coreLoopReturnPt 7.93 - * 0x54 masterLock 7.94 - */ 7.95 -.globl masterSwitchToCoreLoop 7.96 -masterSwitchToCoreLoop: 7.97 - #SlaveVP in %rdi 7.98 - movq $MasterReturn, 0x20(%rdi) #store return address 7.99 - movq %rsp , 0x10(%rdi) #save stack pointer 7.100 - movq %rbp , 0x18(%rdi) #save frame pointer 7.101 - movq 0x38(%rdi), %rsp #restore stack pointer 7.102 - movq 0x30(%rdi), %rbp #restore frame pointer 7.103 - movq $_VMSMasterEnv, %rcx 7.104 - movq (%rcx) , %rcx 7.105 - movq 0x48(%rcx), %rax #get CoreLoopStartPt 7.106 - movl $0x0 , 0x54(%rcx) #release lock 7.107 - jmp *%rax #jmp to CoreLoop 7.108 -MasterReturn: 7.109 - ret 7.110 - 7.111 - 7.112 -//Switch to terminateCoreLoop 7.113 -//therefor switch to coreLoop context from master context 7.114 -// no need to call because the stack is already set up for switchSlv 7.115 -// and Slv is in %rdi 7.116 -// and both functions have the same argument. 7.117 -// do not save register of Slv because this function will never return 7.118 -/* SlaveVP offsets: 7.119 - * 0x10 stackPtr 7.120 - * 0x18 framePtr 7.121 - * 0x20 resumeInstrPtr 7.122 - * 0x30 coreLoopFramePtr 7.123 - * 0x38 coreLoopStackPtr 7.124 - * 7.125 - * _VMSMasterEnv offsets: 7.126 - * 0x48 coreLoopReturnPt 7.127 - * 0x58 masterLock 7.128 - */ 7.129 -.globl asmTerminateCoreLoop 7.130 -asmTerminateCoreLoop: 7.131 - #SlaveVP in %rdi 7.132 - movq 0x38(%rdi), %rsp #restore stack pointer 7.133 - movq 0x30(%rdi), %rbp #restore frame pointer 7.134 - movq $terminateCoreLoop, %rax 7.135 - jmp *%rax #jmp to CoreLoop 7.136 - 7.137 - 7.138 -/* 7.139 - * This one for the sequential version is special. It discards the current stack 7.140 - * and returns directly from the coreLoop after VMS_WL__dissipate_slaveVP was called 7.141 - */ 7.142 -.globl asmTerminateCoreLoopSeq 7.143 -asmTerminateCoreLoopSeq: 7.144 - #SlaveVP in %rdi 7.145 - movq 0x38(%rdi), %rsp #restore stack pointer 7.146 - movq 0x30(%rdi), %rbp #restore frame pointer 7.147 - #argument is in %rdi 7.148 - call VMS_int__dissipate_slaveVP 7.149 - movq %rbp , %rsp #goto the coreLoops stack 7.150 - pop %rbp #restore the old framepointer 7.151 - ret #return from core loop 7.152 - 7.153 - 7.154 -//Takes the return addr off the stack and saves into the loc pointed to by 7.155 -// by the parameter passed in via rdi. Return addr is at 0x8(%rbp) for 64bit 7.156 -.globl VMS_int__save_return_into_ptd_to_loc_then_do_ret 7.157 -VMS_int__save_return_into_ptd_to_loc_then_do_ret: 7.158 - movq 0x8(%rbp), %rax #get ret address, rbp is the same as in the calling function 7.159 - movq %rax, (%rdi) #write ret addr into addr passed as param field 7.160 - ret 7.161 - 7.162 - 7.163 -//Assembly code changes the return addr on the stack to the one 7.164 -// pointed to by the parameter, then returns. Stack's return addr is at 0x8(%rbp) 7.165 -.globl VMS_int__return_to_addr_in_ptd_to_loc 7.166 -VMS_int__return_to_addr_in_ptd_to_loc: 7.167 - movq (%rdi), %rax #get return addr from addr passed as param 7.168 - movq %rax, 0x8(%rbp) #write return addr to the stack of the caller 7.169 - ret 7.170 -
