2 * Copyright 2015, Cyril Bur, IBM Corp.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
10 #include "../basic_asm.h"
12 # POS MUST BE 16 ALIGNED!
13 #define PUSH_VMX(pos,reg) \
39 # POS MUST BE 16 ALIGNED!
40 #define POP_VMX(pos,reg) \
66 # Carefull this will 'clobber' vmx (by design)
67 # Don't call this from C
96 # Should be safe from C, only touches r4, r5 and v0,v1,v2
100 li r3,1 # assume a bad result
161 li r5,STACK_FRAME_LOCAL(0,0)
164 cmpdi r0,0xffffffffffffffff
167 1: POP_BASIC_STACK(32)
173 # r3 holds pointer to where to put the result of fork
174 # r4 holds pointer to the pid
175 # v20-v31 are non-volatile
176 PUSH_BASIC_STACK(512)
177 std r3,STACK_FRAME_PARAM(0)(sp) # Address of varray
178 std r4,STACK_FRAME_PARAM(1)(sp) # address of pid
179 PUSH_VMX(STACK_FRAME_LOCAL(2,0),r4)
186 # Pass the result of fork back to the caller
187 ld r9,STACK_FRAME_PARAM(1)(sp)
190 ld r3,STACK_FRAME_PARAM(0)(sp)
194 POP_VMX(STACK_FRAME_LOCAL(2,0),r4)
199 # int preempt_vmx(vector int *varray, int *threads_starting, int *running)
200 # On starting will (atomically) decrement threads_starting as a signal that
201 # the VMX have been loaded with varray. Will proceed to check the validity of
202 # the VMX registers while running is not zero.
203 FUNC_START(preempt_vmx)
204 PUSH_BASIC_STACK(512)
205 std r3,STACK_FRAME_PARAM(0)(sp) # vector int *varray
206 std r4,STACK_FRAME_PARAM(1)(sp) # int *threads_starting
207 std r5,STACK_FRAME_PARAM(2)(sp) # int *running
208 # VMX need to write to 16 byte aligned addresses, skip STACK_FRAME_LOCAL(3,0)
209 PUSH_VMX(STACK_FRAME_LOCAL(4,0),r4)
216 ld r3,STACK_FRAME_PARAM(1)(sp)
222 2: ld r3,STACK_FRAME_PARAM(0)(sp)
227 ld r4,STACK_FRAME_PARAM(2)(sp)
232 3: POP_VMX(STACK_FRAME_LOCAL(4,0),r4)
235 FUNC_END(preempt_vmx)