Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view contextSwitch.s @ 75:f6990e1ba998
new sequential version
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 02 Jun 2011 13:55:51 +0200 |
| parents | d8f12351f7cc |
| children | 9ddbb071142d |
line source
1 .data
4 .text
6 //Save return label address for the coreLoop to pointer
7 //Arguments: Pointer to variable holding address
8 .globl saveCoreLoopReturnAddr
9 saveCoreLoopReturnAddr:
10 movl 0x4(%esp) , %eax #load pointer
11 movl $coreLoopReturn, %ecx #load label address
12 movl %ecx, (%eax) #save address
13 ret
17 //Switches form CoreLoop to VP ether normal VP or the Master Loop
18 //switch to virt procr's stack and frame ptr then jump to virt procr fn
19 /* VirtProcr offsets:
20 * 0xc stackPtr
21 * 0x10 framePtr
22 * 0x14 nextInstrPt
23 * 0x1c coreLoopFramePtr
24 * 0x20 coreLoopStackPtr
25 *
26 * _VMSMasterEnv offsets:
27 * 0x24 coreLoopReturnPt
28 * 0x2c masterLock
29 */
30 .globl switchToVP
31 switchToVP:
32 movl 0x4(%esp) , %ecx #get VirtProcr
33 movl %esp , 0x20(%ecx) #save core loop stack pointer
34 movl %ebp , 0x1c(%ecx) #save core loop frame pointer
35 movl 0x0c(%ecx), %esp #restore stack pointer
36 movl 0x10(%ecx), %ebp #restore frame pointer
37 movl 0x14(%ecx), %eax #get jmp pointer
38 jmp *%eax #jmp to VP
39 coreLoopReturn:
40 ret
43 //switches to core loop. saves return address
44 /* VirtProcr offsets:
45 * 0xc stackPtr
46 * 0x10 framePtr
47 * 0x14 nextInstrPt
48 * 0x1c coreLoopFramePtr
49 * 0x20 coreLoopStackPtr
50 *
51 * _VMSMasterEnv offsets:
52 * 0x24 coreLoopReturnPt
53 * 0x28 coreLoopEndPt
54 * 0x2c masterLock
55 */
56 .globl switchToCoreLoop
57 switchToCoreLoop:
58 movl 0x4(%esp) , %ecx #get VirtProcr
59 movl $VPReturn , 0x14(%ecx) #store return address
60 movl %esp , 0x0c(%ecx) #save stack pointer
61 movl %ebp , 0x10(%ecx) #save frame pointer
62 movl 0x20(%ecx), %esp #restore stack pointer
63 movl 0x1c(%ecx), %ebp #restore frame pointer
64 movl $_VMSMasterEnv, %ecx
65 movl (%ecx) , %ecx
66 movl 0x24(%ecx), %eax #get CoreLoopStartPt
67 jmp *%eax #jmp to CoreLoop
68 VPReturn:
69 ret
73 //switches to core loop from master. saves return address
74 //Releases masterLock so the next MasterLoop can be executed
75 /* VirtProcr offsets:
76 * 0xc stackPtr
77 * 0x10 framePtr
78 * 0x14 nextInstrPt
79 * 0x1c coreLoopFramePtr
80 * 0x20 coreLoopStackPtr
81 *
82 * _VMSMasterEnv offsets:
83 * 0x24 coreLoopReturnPt
84 * 0x2c masterLock
85 */
86 .globl masterSwitchToCoreLoop
87 masterSwitchToCoreLoop:
88 movl 0x4(%esp) , %ecx #get VirtProcr
89 movl $MasterReturn, 0x14(%ecx) #store return address
90 movl %esp , 0x0c(%ecx) #save stack pointer
91 movl %ebp , 0x10(%ecx) #save frame pointer
92 movl 0x20(%ecx), %esp #restore stack pointer
93 movl 0x1c(%ecx), %ebp #restore frame pointer
94 movl $_VMSMasterEnv, %ecx
95 movl (%ecx) , %ecx
96 movl 0x24(%ecx), %eax #get CoreLoopStartPt
97 movl $0x0 , 0x2c(%ecx) #release lock
98 jmp *%eax #jmp to CoreLoop
99 MasterReturn:
100 ret
103 //Switch to terminateCoreLoop
104 // no need to call because the stack is already set up for switchVP
105 // and both functions have the same argument.
106 // do not save register of VP because this function will never return
107 /* VirtProcr offsets:
108 * 0xc stackPtr
109 * 0x10 framePtr
110 * 0x14 nextInstrPt
111 * 0x1c coreLoopFramePtr
112 * 0x20 coreLoopStackPtr
113 *
114 * _VMSMasterEnv offsets:
115 * 0x24 coreLoopReturnPt
116 * 0x2c masterLock
117 */
118 .globl asmTerminateCoreLoop
119 asmTerminateCoreLoop:
120 movl 0x4(%esp) , %ecx #get VirtProcr
121 movl 0x20(%ecx), %esp #restore stack pointer
122 movl 0x1c(%ecx), %ebp #restore frame pointer
123 movl $terminateCoreLoop, %eax
124 jmp *%eax #jmp to CoreLoop
127 /*
128 * This one for the sequential version is special. It discards the current stack
129 * and returns directly from the coreLoop after VMS__dissipate_procr was called
130 */
131 .globl asmTerminateCoreLoopSeq
132 asmTerminateCoreLoopSeq:
133 movl 0x4(%esp) , %ecx #get VirtProcr
134 movl 0x20(%ecx), %esp #restore stack pointer
135 movl 0x1c(%ecx), %ebp #restore frame pointer
136 sub $0x4 , %esp
137 movl %ecx , (%esp) #put argument on stack
138 call VMS__dissipate_procr
139 movl %ebp , %esp #goto the coreLoops stack
140 pop %ebp #restore the old framepointer
141 ret #return from core loop
