Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view contextSwitch.s @ 102:def70e32cf2c
Malloc with easy shave off
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 03 Aug 2011 13:23:32 +0200 |
| parents | f6990e1ba998 |
| children | dbfc8382d546 bfaebdf60df3 |
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 movq $coreLoopReturn, %rcx #load label address
11 movq %rcx, (%rdi) #save address to pointer
12 ret
15 //Initializes VirtProcrFn at first run for 64 bit mode
16 //Puts argument from stack into registers
17 .globl startVirtProcrFn
18 startVirtProcrFn:
19 movq %rdi , %rsi #get second argument from first argument of switchVP
20 movq 0x08(%rsp), %rdi #get first argument
21 movq (%rsp) , %rax #get function addr
22 jmp *%rax
24 //Switches form CoreLoop to VP ether a normal VP or the Master Loop
25 //switch to virt procr's stack and frame ptr then jump to virt procr fn
26 /* VirtProcr offsets:
27 * 0x10 stackPtr
28 * 0x18 framePtr
29 * 0x20 nextInstrPt
30 * 0x30 coreLoopFramePtr
31 * 0x38 coreLoopStackPtr
32 *
33 * _VMSMasterEnv offsets:
34 * 0x48 coreLoopReturnPt
35 * 0x54 masterLock
36 */
37 .globl switchToVP
38 switchToVP:
39 #VirtProcr in %rdi
40 movq %rsp , 0x38(%rdi) #save core loop stack pointer
41 movq %rbp , 0x30(%rdi) #save core loop frame pointer
42 movq 0x10(%rdi), %rsp #restore stack pointer
43 movq 0x18(%rdi), %rbp #restore frame pointer
44 movq 0x20(%rdi), %rax #get jmp pointer
45 jmp *%rax #jmp to VP
46 coreLoopReturn:
47 ret
50 //switches to core loop. saves return address
51 /* VirtProcr offsets:
52 * 0x10 stackPtr
53 * 0x18 framePtr
54 * 0x20 nextInstrPt
55 * 0x30 coreLoopFramePtr
56 * 0x38 coreLoopStackPtr
57 *
58 * _VMSMasterEnv offsets:
59 * 0x48 coreLoopReturnPt
60 * 0x54 masterLock
61 */
62 .globl switchToCoreLoop
63 switchToCoreLoop:
64 #VirtProcr in %rdi
65 movq $VPReturn , 0x20(%rdi) #store return address
66 movq %rsp , 0x10(%rdi) #save stack pointer
67 movq %rbp , 0x18(%rdi) #save frame pointer
68 movq 0x38(%rdi), %rsp #restore stack pointer
69 movq 0x30(%rdi), %rbp #restore frame pointer
70 movq $_VMSMasterEnv, %rcx
71 movq (%rcx) , %rcx
72 movq 0x48(%rcx), %rax #get CoreLoopStartPt
73 jmp *%rax #jmp to CoreLoop
74 VPReturn:
75 ret
79 //switches to core loop from master. saves return address
80 //Releases masterLock so the next MasterLoop can be executed
81 /* VirtProcr offsets:
82 * 0x10 stackPtr
83 * 0x18 framePtr
84 * 0x20 nextInstrPt
85 * 0x30 coreLoopFramePtr
86 * 0x38 coreLoopStackPtr
87 *
88 * _VMSMasterEnv offsets:
89 * 0x48 coreLoopReturnPt
90 * 0x54 masterLock
91 */
92 .globl masterSwitchToCoreLoop
93 masterSwitchToCoreLoop:
94 #VirtProcr in %rdi
95 movq $MasterReturn, 0x20(%rdi) #store return address
96 movq %rsp , 0x10(%rdi) #save stack pointer
97 movq %rbp , 0x18(%rdi) #save frame pointer
98 movq 0x38(%rdi), %rsp #restore stack pointer
99 movq 0x30(%rdi), %rbp #restore frame pointer
100 movq $_VMSMasterEnv, %rcx
101 movq (%rcx) , %rcx
102 movq 0x48(%rcx), %rax #get CoreLoopStartPt
103 movl $0x0 , 0x54(%rcx) #release lock
104 jmp *%rax #jmp to CoreLoop
105 MasterReturn:
106 ret
109 //Switch to terminateCoreLoop
110 //therefor switch to coreLoop context from master context
111 // no need to call because the stack is already set up for switchVP
112 // and virtPr is in %rdi
113 // and both functions have the same argument.
114 // do not save register of VP because this function will never return
115 /* VirtProcr offsets:
116 * 0x10 stackPtr
117 * 0x18 framePtr
118 * 0x20 nextInstrPt
119 * 0x30 coreLoopFramePtr
120 * 0x38 coreLoopStackPtr
121 *
122 * _VMSMasterEnv offsets:
123 * 0x48 coreLoopReturnPt
124 * 0x58 masterLock
125 */
126 .globl asmTerminateCoreLoop
127 asmTerminateCoreLoop:
128 #VirtProcr in %rdi
129 movq 0x38(%rdi), %rsp #restore stack pointer
130 movq 0x30(%rdi), %rbp #restore frame pointer
131 movq $terminateCoreLoop, %rax
132 jmp *%rax #jmp to CoreLoop
135 /*
136 * This one for the sequential version is special. It discards the current stack
137 * and returns directly from the coreLoop after VMS__dissipate_procr was called
138 */
139 .globl asmTerminateCoreLoopSeq
140 asmTerminateCoreLoopSeq:
141 #VirtProcr in %rdi
142 movq 0x38(%rdi), %rsp #restore stack pointer
143 movq 0x30(%rdi), %rbp #restore frame pointer
144 #argument is in %rdi
145 call VMS__dissipate_procr
146 movq %rbp , %rsp #goto the coreLoops stack
147 pop %rbp #restore the old framepointer
148 ret #return from core loop
