view contextSwitch.s @ 132:dbfc8382d546

distributed memory allocation interface - unfinished
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 16 Sep 2011 14:25:49 +0200
parents 9ddbb071142d
children 99343ffe1918
line source
1 .data
4 .text
5 /* VirtProcr offsets:
6 * 0x10 stackPtr
7 * 0x18 framePtr
8 * 0x20 nextInstrPt
9 * 0x30 coreLoopFramePtr
10 * 0x38 coreLoopStackPtr
11 *
12 * _VMSMasterEnv offsets:
13 * 0x38 coreLoopReturnPt
14 * 0x44 masterLock
15 */
16 //Save return label address for the coreLoop to pointer
17 //Arguments: Pointer to variable holding address
18 .globl saveCoreLoopReturnAddr
19 saveCoreLoopReturnAddr:
20 movq $coreLoopReturn, %rcx #load label address
21 movq %rcx, (%rdi) #save address to pointer
22 ret
25 //Initializes VirtProcrFn at first run for 64 bit mode
26 //Puts argument from stack into registers
27 .globl startVirtProcrFn
28 startVirtProcrFn:
29 movq %rdi , %rsi #get second argument from first argument of switchVP
30 movq 0x08(%rsp), %rdi #get first argument
31 movq (%rsp) , %rax #get function addr
32 jmp *%rax
34 //Switches form CoreLoop to VP ether a normal VP or the Master Loop
35 //switch to virt procr's stack and frame ptr then jump to virt procr fn
36 .globl switchToVP
37 switchToVP:
38 #VirtProcr in %rdi
39 movq %rsp , 0x38(%rdi) #save core loop stack pointer
40 movq %rbp , 0x30(%rdi) #save core loop frame pointer
41 movq 0x10(%rdi), %rsp #restore stack pointer
42 movq 0x18(%rdi), %rbp #restore frame pointer
43 movq 0x20(%rdi), %rax #get jmp pointer
44 jmp *%rax #jmp to VP
45 coreLoopReturn:
46 ret
49 //switches to core loop. saves return address
50 .globl switchToCoreLoop
51 switchToCoreLoop:
52 #VirtProcr in %rdi
53 movq $VPReturn , 0x20(%rdi) #store return address
54 movq %rsp , 0x10(%rdi) #save stack pointer
55 movq %rbp , 0x18(%rdi) #save frame pointer
56 movq 0x38(%rdi), %rsp #restore stack pointer
57 movq 0x30(%rdi), %rbp #restore frame pointer
58 movq $_VMSMasterEnv, %rcx
59 movq (%rcx) , %rcx
60 movq 0x38(%rcx), %rax #get CoreLoopStartPt
61 jmp *%rax #jmp to CoreLoop
62 VPReturn:
63 ret
67 //switches to core loop from master. saves return address
68 //Releases masterLock so the next MasterLoop can be executed
69 .globl masterSwitchToCoreLoop
70 masterSwitchToCoreLoop:
71 #VirtProcr in %rdi
72 movq $MasterReturn, 0x20(%rdi) #store return address
73 movq %rsp , 0x10(%rdi) #save stack pointer
74 movq %rbp , 0x18(%rdi) #save frame pointer
75 movq 0x38(%rdi), %rsp #restore stack pointer
76 movq 0x30(%rdi), %rbp #restore frame pointer
77 movq $_VMSMasterEnv, %rcx
78 movq (%rcx) , %rcx
79 movq 0x38(%rcx), %rax #get CoreLoopStartPt
80 movl $0x0 , 0x44(%rcx) #release lock
81 jmp *%rax #jmp to CoreLoop
82 MasterReturn:
83 ret
86 //Switch to terminateCoreLoop
87 //therefor switch to coreLoop context from master context
88 // no need to call because the stack is already set up for switchVP
89 // and virtPr is in %rdi
90 // and both functions have the same argument.
91 // do not save register of VP because this function will never return
92 .globl asmTerminateCoreLoop
93 asmTerminateCoreLoop:
94 #VirtProcr in %rdi
95 movq 0x38(%rdi), %rsp #restore stack pointer
96 movq 0x30(%rdi), %rbp #restore frame pointer
97 movq $terminateCoreLoop, %rax
98 jmp *%rax #jmp to CoreLoop
101 /*
102 * This one for the sequential version is special. It discards the current stack
103 * and returns directly from the coreLoop after VMS__dissipate_procr was called
104 */
105 .globl asmTerminateCoreLoopSeq
106 asmTerminateCoreLoopSeq:
107 #VirtProcr in %rdi
108 movq 0x38(%rdi), %rsp #restore stack pointer
109 movq 0x30(%rdi), %rbp #restore frame pointer
110 #argument is in %rdi
111 call VMS__dissipate_procr
112 movq %rbp , %rsp #goto the coreLoops stack
113 pop %rbp #restore the old framepointer
114 ret #return from core loop