Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff contextSwitch.s @ 71:5ff1631c26ed
working O3 version
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 30 May 2011 18:28:41 +0200 |
| parents | |
| children | d8f12351f7cc |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/contextSwitch.s Mon May 30 18:28:41 2011 +0200 1.3 @@ -0,0 +1,128 @@ 1.4 +#include "VMS.h" 1.5 + 1.6 +.data 1.7 + 1.8 + 1.9 +.text 1.10 + 1.11 +//Save return label address for the coreLoop to pointer 1.12 +//Arguments: Pointer to variable holding address 1.13 +.globl saveCoreLoopReturnAddr 1.14 +saveCoreLoopReturnAddr: 1.15 + movl 0x4(%esp) , %eax #load pointer 1.16 + movl $coreLoopReturn, %ecx #load label address 1.17 + movl %ecx, (%eax) #save address 1.18 + ret 1.19 + 1.20 + 1.21 + 1.22 +//Switches form CoreLoop to VP ether normal VP or the Master Loop 1.23 +//switch to virt procr's stack and frame ptr then jump to virt procr fn 1.24 +/* VirtProcr offsets: 1.25 + * 0xc stackPtr 1.26 + * 0x10 framePtr 1.27 + * 0x14 nextInstrPt 1.28 + * 0x1c coreLoopFramePtr 1.29 + * 0x20 coreLoopStackPtr 1.30 + * 1.31 + * _VMSMasterEnv offsets: 1.32 + * 0x24 coreLoopStartPt 1.33 + * 0x28 coreLoopEndPt 1.34 + * 0x30 masterLock 1.35 + */ 1.36 +.globl switchToVP 1.37 +switchToVP: 1.38 + movl 0x4(%esp) , %ecx #get VirtProcr 1.39 + movl %esp , 0x20(%ecx) #save core loop stack pointer 1.40 + movl %ebp , 0x1c(%ecx) #save core loop frame pointer 1.41 + movl 0x0c(%ecx), %esp #restore stack pointer 1.42 + movl 0x10(%ecx), %ebp #restore frame pointer 1.43 + movl 0x14(%ecx), %eax #get jmp pointer 1.44 + jmp *%eax #jmp to VP 1.45 +coreLoopReturn: 1.46 + ret 1.47 + 1.48 + 1.49 +//switches to core loop. saves return address 1.50 +/* VirtProcr offsets: 1.51 + * 0xc stackPtr 1.52 + * 0x10 framePtr 1.53 + * 0x14 nextInstrPt 1.54 + * 0x1c coreLoopFramePtr 1.55 + * 0x20 coreLoopStackPtr 1.56 + * 1.57 + * _VMSMasterEnv offsets: 1.58 + * 0x24 coreLoopStartPt 1.59 + * 0x28 coreLoopEndPt 1.60 + * 0x30 masterLock 1.61 + */ 1.62 +.globl switchToCoreLoop 1.63 +switchToCoreLoop: 1.64 + movl 0x4(%esp) , %ecx #get VirtProcr 1.65 + movl $VPReturn , 0x14(%ecx) #store return address 1.66 + movl %esp , 0x0c(%ecx) #save stack pointer 1.67 + movl %ebp , 0x10(%ecx) #save frame pointer 1.68 + movl 0x20(%ecx), %esp #restore stack pointer 1.69 + movl 0x1c(%ecx), %ebp #restore frame pointer 1.70 + movl $_VMSMasterEnv, %ecx 1.71 + movl (%ecx) , %ecx 1.72 + movl 0x24(%ecx), %eax #get CoreLoopStartPt 1.73 + jmp *%eax #jmp to CoreLoop 1.74 +VPReturn: 1.75 + ret 1.76 + 1.77 + 1.78 + 1.79 +//switches to core loop from master. saves return address 1.80 +/* VirtProcr offsets: 1.81 + * 0xc stackPtr 1.82 + * 0x10 framePtr 1.83 + * 0x14 nextInstrPt 1.84 + * 0x1c coreLoopFramePtr 1.85 + * 0x20 coreLoopStackPtr 1.86 + * 1.87 + * _VMSMasterEnv offsets: 1.88 + * 0x24 coreLoopStartPt 1.89 + * 0x28 coreLoopEndPt 1.90 + * 0x30 masterLock 1.91 + */ 1.92 +.globl masterSwitchToCoreLoop 1.93 +masterSwitchToCoreLoop: 1.94 + movl 0x4(%esp) , %ecx #get VirtProcr 1.95 + movl $MasterReturn, 0x14(%ecx) #store return address 1.96 + movl %esp , 0x0c(%ecx) #save stack pointer 1.97 + movl %ebp , 0x10(%ecx) #save frame pointer 1.98 + movl 0x20(%ecx), %esp #restore stack pointer 1.99 + movl 0x1c(%ecx), %ebp #restore frame pointer 1.100 + movl $_VMSMasterEnv, %ecx 1.101 + movl (%ecx) , %ecx 1.102 + movl 0x24(%ecx), %eax #get CoreLoopStartPt 1.103 + movl $0x0 , 0x30(%ecx) #release lock 1.104 + jmp *%eax #jmp to CoreLoop 1.105 +MasterReturn: 1.106 + ret 1.107 + 1.108 + 1.109 +//Switch to terminateCoreLoop 1.110 +//no need to call because the stack is already set up for switchVP 1.111 +//do not save register of VP because this function will never return 1.112 +/* VirtProcr offsets: 1.113 + * 0xc stackPtr 1.114 + * 0x10 framePtr 1.115 + * 0x14 nextInstrPt 1.116 + * 0x1c coreLoopFramePtr 1.117 + * 0x20 coreLoopStackPtr 1.118 + * 1.119 + * _VMSMasterEnv offsets: 1.120 + * 0x24 coreLoopStartPt 1.121 + * 0x28 coreLoopEndPt 1.122 + * 0x30 masterLock 1.123 + */ 1.124 +.globl asmTerminateCoreLoop 1.125 +asmTerminateCoreLoop: 1.126 + movl 0x4(%esp) , %ecx #get VirtProcr 1.127 + movl 0x20(%ecx), %esp #restore stack pointer 1.128 + movl 0x1c(%ecx), %ebp #restore frame pointer 1.129 + movl $terminateCoreLoop, %eax 1.130 + jmp *%eax #jmp to CoreLoop 1.131 +
