comparison contextSwitch.s @ 73:d8f12351f7cc

generic VMS lib
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 02 Jun 2011 12:36:14 +0200
parents 5ff1631c26ed
children f6990e1ba998
comparison
equal deleted inserted replaced
0:edea7fad9af1 1:27d2872398f7
1 #include "VMS.h"
2
3 .data 1 .data
4 2
5 3
6 .text 4 .text
7 5
24 * 0x14 nextInstrPt 22 * 0x14 nextInstrPt
25 * 0x1c coreLoopFramePtr 23 * 0x1c coreLoopFramePtr
26 * 0x20 coreLoopStackPtr 24 * 0x20 coreLoopStackPtr
27 * 25 *
28 * _VMSMasterEnv offsets: 26 * _VMSMasterEnv offsets:
29 * 0x24 coreLoopStartPt 27 * 0x24 coreLoopReturnPt
30 * 0x28 coreLoopEndPt 28 * 0x2c masterLock
31 * 0x30 masterLock
32 */ 29 */
33 .globl switchToVP 30 .globl switchToVP
34 switchToVP: 31 switchToVP:
35 movl 0x4(%esp) , %ecx #get VirtProcr 32 movl 0x4(%esp) , %ecx #get VirtProcr
36 movl %esp , 0x20(%ecx) #save core loop stack pointer 33 movl %esp , 0x20(%ecx) #save core loop stack pointer
50 * 0x14 nextInstrPt 47 * 0x14 nextInstrPt
51 * 0x1c coreLoopFramePtr 48 * 0x1c coreLoopFramePtr
52 * 0x20 coreLoopStackPtr 49 * 0x20 coreLoopStackPtr
53 * 50 *
54 * _VMSMasterEnv offsets: 51 * _VMSMasterEnv offsets:
55 * 0x24 coreLoopStartPt 52 * 0x24 coreLoopReturnPt
56 * 0x28 coreLoopEndPt 53 * 0x28 coreLoopEndPt
57 * 0x30 masterLock 54 * 0x2c masterLock
58 */ 55 */
59 .globl switchToCoreLoop 56 .globl switchToCoreLoop
60 switchToCoreLoop: 57 switchToCoreLoop:
61 movl 0x4(%esp) , %ecx #get VirtProcr 58 movl 0x4(%esp) , %ecx #get VirtProcr
62 movl $VPReturn , 0x14(%ecx) #store return address 59 movl $VPReturn , 0x14(%ecx) #store return address
72 ret 69 ret
73 70
74 71
75 72
76 //switches to core loop from master. saves return address 73 //switches to core loop from master. saves return address
74 //Releases masterLock so the next MasterLoop can be executed
77 /* VirtProcr offsets: 75 /* VirtProcr offsets:
78 * 0xc stackPtr 76 * 0xc stackPtr
79 * 0x10 framePtr 77 * 0x10 framePtr
80 * 0x14 nextInstrPt 78 * 0x14 nextInstrPt
81 * 0x1c coreLoopFramePtr 79 * 0x1c coreLoopFramePtr
82 * 0x20 coreLoopStackPtr 80 * 0x20 coreLoopStackPtr
83 * 81 *
84 * _VMSMasterEnv offsets: 82 * _VMSMasterEnv offsets:
85 * 0x24 coreLoopStartPt 83 * 0x24 coreLoopReturnPt
86 * 0x28 coreLoopEndPt 84 * 0x2c masterLock
87 * 0x30 masterLock
88 */ 85 */
89 .globl masterSwitchToCoreLoop 86 .globl masterSwitchToCoreLoop
90 masterSwitchToCoreLoop: 87 masterSwitchToCoreLoop:
91 movl 0x4(%esp) , %ecx #get VirtProcr 88 movl 0x4(%esp) , %ecx #get VirtProcr
92 movl $MasterReturn, 0x14(%ecx) #store return address 89 movl $MasterReturn, 0x14(%ecx) #store return address
95 movl 0x20(%ecx), %esp #restore stack pointer 92 movl 0x20(%ecx), %esp #restore stack pointer
96 movl 0x1c(%ecx), %ebp #restore frame pointer 93 movl 0x1c(%ecx), %ebp #restore frame pointer
97 movl $_VMSMasterEnv, %ecx 94 movl $_VMSMasterEnv, %ecx
98 movl (%ecx) , %ecx 95 movl (%ecx) , %ecx
99 movl 0x24(%ecx), %eax #get CoreLoopStartPt 96 movl 0x24(%ecx), %eax #get CoreLoopStartPt
100 movl $0x0 , 0x30(%ecx) #release lock 97 movl $0x0 , 0x2c(%ecx) #release lock
101 jmp *%eax #jmp to CoreLoop 98 jmp *%eax #jmp to CoreLoop
102 MasterReturn: 99 MasterReturn:
103 ret 100 ret
104 101
105 102
106 //Switch to terminateCoreLoop 103 //Switch to terminateCoreLoop
107 //no need to call because the stack is already set up for switchVP 104 // 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 105 // and both functions have the same argument.
106 // do not save register of VP because this function will never return
109 /* VirtProcr offsets: 107 /* VirtProcr offsets:
110 * 0xc stackPtr 108 * 0xc stackPtr
111 * 0x10 framePtr 109 * 0x10 framePtr
112 * 0x14 nextInstrPt 110 * 0x14 nextInstrPt
113 * 0x1c coreLoopFramePtr 111 * 0x1c coreLoopFramePtr
114 * 0x20 coreLoopStackPtr 112 * 0x20 coreLoopStackPtr
115 * 113 *
116 * _VMSMasterEnv offsets: 114 * _VMSMasterEnv offsets:
117 * 0x24 coreLoopStartPt 115 * 0x24 coreLoopReturnPt
118 * 0x28 coreLoopEndPt 116 * 0x2c masterLock
119 * 0x30 masterLock
120 */ 117 */
121 .globl asmTerminateCoreLoop 118 .globl asmTerminateCoreLoop
122 asmTerminateCoreLoop: 119 asmTerminateCoreLoop:
123 movl 0x4(%esp) , %ecx #get VirtProcr 120 movl 0x4(%esp) , %ecx #get VirtProcr
124 movl 0x20(%ecx), %esp #restore stack pointer 121 movl 0x20(%ecx), %esp #restore stack pointer