comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:edea7fad9af1
1 #include "VMS.h"
2
3 .data
4
5
6 .text
7
8 //Save return label address for the coreLoop to pointer
9 //Arguments: Pointer to variable holding address
10 .globl saveCoreLoopReturnAddr
11 saveCoreLoopReturnAddr:
12 movl 0x4(%esp) , %eax #load pointer
13 movl $coreLoopReturn, %ecx #load label address
14 movl %ecx, (%eax) #save address
15 ret
16
17
18
19 //Switches form CoreLoop to VP ether normal VP or the Master Loop
20 //switch to virt procr's stack and frame ptr then jump to virt procr fn
21 /* VirtProcr offsets:
22 * 0xc stackPtr
23 * 0x10 framePtr
24 * 0x14 nextInstrPt
25 * 0x1c coreLoopFramePtr
26 * 0x20 coreLoopStackPtr
27 *
28 * _VMSMasterEnv offsets:
29 * 0x24 coreLoopStartPt
30 * 0x28 coreLoopEndPt
31 * 0x30 masterLock
32 */
33 .globl switchToVP
34 switchToVP:
35 movl 0x4(%esp) , %ecx #get VirtProcr
36 movl %esp , 0x20(%ecx) #save core loop stack pointer
37 movl %ebp , 0x1c(%ecx) #save core loop frame pointer
38 movl 0x0c(%ecx), %esp #restore stack pointer
39 movl 0x10(%ecx), %ebp #restore frame pointer
40 movl 0x14(%ecx), %eax #get jmp pointer
41 jmp *%eax #jmp to VP
42 coreLoopReturn:
43 ret
44
45
46 //switches to core loop. saves return address
47 /* VirtProcr offsets:
48 * 0xc stackPtr
49 * 0x10 framePtr
50 * 0x14 nextInstrPt
51 * 0x1c coreLoopFramePtr
52 * 0x20 coreLoopStackPtr
53 *
54 * _VMSMasterEnv offsets:
55 * 0x24 coreLoopStartPt
56 * 0x28 coreLoopEndPt
57 * 0x30 masterLock
58 */
59 .globl switchToCoreLoop
60 switchToCoreLoop:
61 movl 0x4(%esp) , %ecx #get VirtProcr
62 movl $VPReturn , 0x14(%ecx) #store return address
63 movl %esp , 0x0c(%ecx) #save stack pointer
64 movl %ebp , 0x10(%ecx) #save frame pointer
65 movl 0x20(%ecx), %esp #restore stack pointer
66 movl 0x1c(%ecx), %ebp #restore frame pointer
67 movl $_VMSMasterEnv, %ecx
68 movl (%ecx) , %ecx
69 movl 0x24(%ecx), %eax #get CoreLoopStartPt
70 jmp *%eax #jmp to CoreLoop
71 VPReturn:
72 ret
73
74
75
76 //switches to core loop from master. saves return address
77 /* VirtProcr offsets:
78 * 0xc stackPtr
79 * 0x10 framePtr
80 * 0x14 nextInstrPt
81 * 0x1c coreLoopFramePtr
82 * 0x20 coreLoopStackPtr
83 *
84 * _VMSMasterEnv offsets:
85 * 0x24 coreLoopStartPt
86 * 0x28 coreLoopEndPt
87 * 0x30 masterLock
88 */
89 .globl masterSwitchToCoreLoop
90 masterSwitchToCoreLoop:
91 movl 0x4(%esp) , %ecx #get VirtProcr
92 movl $MasterReturn, 0x14(%ecx) #store return address
93 movl %esp , 0x0c(%ecx) #save stack pointer
94 movl %ebp , 0x10(%ecx) #save frame pointer
95 movl 0x20(%ecx), %esp #restore stack pointer
96 movl 0x1c(%ecx), %ebp #restore frame pointer
97 movl $_VMSMasterEnv, %ecx
98 movl (%ecx) , %ecx
99 movl 0x24(%ecx), %eax #get CoreLoopStartPt
100 movl $0x0 , 0x30(%ecx) #release lock
101 jmp *%eax #jmp to CoreLoop
102 MasterReturn:
103 ret
104
105
106 //Switch to terminateCoreLoop
107 //no need to call because the stack is already set up for switchVP
108 //do not save register of VP because this function will never return
109 /* VirtProcr offsets:
110 * 0xc stackPtr
111 * 0x10 framePtr
112 * 0x14 nextInstrPt
113 * 0x1c coreLoopFramePtr
114 * 0x20 coreLoopStackPtr
115 *
116 * _VMSMasterEnv offsets:
117 * 0x24 coreLoopStartPt
118 * 0x28 coreLoopEndPt
119 * 0x30 masterLock
120 */
121 .globl asmTerminateCoreLoop
122 asmTerminateCoreLoop:
123 movl 0x4(%esp) , %ecx #get VirtProcr
124 movl 0x20(%ecx), %esp #restore stack pointer
125 movl 0x1c(%ecx), %ebp #restore frame pointer
126 movl $terminateCoreLoop, %eax
127 jmp *%eax #jmp to CoreLoop
128