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 #define PUSH_FPU(pos) \
15 stfd f16,pos+16(sp); \
16 stfd f17,pos+24(sp); \
17 stfd f18,pos+32(sp); \
18 stfd f19,pos+40(sp); \
19 stfd f20,pos+48(sp); \
20 stfd f21,pos+56(sp); \
21 stfd f22,pos+64(sp); \
22 stfd f23,pos+72(sp); \
23 stfd f24,pos+80(sp); \
24 stfd f25,pos+88(sp); \
25 stfd f26,pos+96(sp); \
26 stfd f27,pos+104(sp); \
27 stfd f28,pos+112(sp); \
28 stfd f29,pos+120(sp); \
29 stfd f30,pos+128(sp); \
32 #define POP_FPU(pos) \
46 lfd f27,pos+104(sp); \
47 lfd f28,pos+112(sp); \
48 lfd f29,pos+120(sp); \
49 lfd f30,pos+128(sp); \
52 # Careful calling this, it will 'clobber' fpu (by design)
53 # Don't call this from C
78 li r3,1 # assume a bad result
137 # r3 holds pointer to where to put the result of fork
138 # r4 holds pointer to the pid
139 # f14-f31 are non volatiles
140 PUSH_BASIC_STACK(256)
141 std r3,STACK_FRAME_PARAM(0)(sp) # Address of darray
142 std r4,STACK_FRAME_PARAM(1)(sp) # Address of pid
143 PUSH_FPU(STACK_FRAME_LOCAL(2,0))
150 # pass the result of the fork to the caller
151 ld r9,STACK_FRAME_PARAM(1)(sp)
154 ld r3,STACK_FRAME_PARAM(0)(sp)
158 POP_FPU(STACK_FRAME_LOCAL(2,0))
163 # int preempt_fpu(double *darray, int *threads_running, int *running)
164 # On starting will (atomically) decrement not_ready as a signal that the FPU
165 # has been loaded with darray. Will proceed to check the validity of the FPU
166 # registers while running is not zero.
167 FUNC_START(preempt_fpu)
168 PUSH_BASIC_STACK(256)
169 std r3,STACK_FRAME_PARAM(0)(sp) # double *darray
170 std r4,STACK_FRAME_PARAM(1)(sp) # int *threads_starting
171 std r5,STACK_FRAME_PARAM(2)(sp) # int *running
172 PUSH_FPU(STACK_FRAME_LOCAL(3,0))
179 ld r3,STACK_FRAME_PARAM(1)(sp)
185 2: ld r3,STACK_FRAME_PARAM(0)(sp)
190 ld r4,STACK_FRAME_PARAM(2)(sp)
195 3: POP_FPU(STACK_FRAME_LOCAL(3,0))
198 FUNC_END(preempt_fpu)