1*611e3850SMichael Ellerman/* SPDX-License-Identifier: GPL-2.0-or-later */ 2*611e3850SMichael Ellerman/* 3*611e3850SMichael Ellerman * test helper assembly functions 4*611e3850SMichael Ellerman * 5*611e3850SMichael Ellerman * Copyright (C) 2016 Simon Guo, IBM Corporation. 6*611e3850SMichael Ellerman * Copyright 2022 Michael Ellerman, IBM Corporation. 7*611e3850SMichael Ellerman */ 8*611e3850SMichael Ellerman#include "basic_asm.h" 9*611e3850SMichael Ellerman 10*611e3850SMichael Ellerman#define GPR_SIZE __SIZEOF_LONG__ 11*611e3850SMichael Ellerman#define FIRST_GPR 14 12*611e3850SMichael Ellerman#define NUM_GPRS (32 - FIRST_GPR) 13*611e3850SMichael Ellerman#define STACK_SIZE (NUM_GPRS * GPR_SIZE) 14*611e3850SMichael Ellerman 15*611e3850SMichael Ellerman// gpr_child_loop(int *read_flag, int *write_flag, 16*611e3850SMichael Ellerman// unsigned long *gpr_buf, double *fpr_buf); 17*611e3850SMichael EllermanFUNC_START(gpr_child_loop) 18*611e3850SMichael Ellerman // r3 = read_flag 19*611e3850SMichael Ellerman // r4 = write_flag 20*611e3850SMichael Ellerman // r5 = gpr_buf 21*611e3850SMichael Ellerman // r6 = fpr_buf 22*611e3850SMichael Ellerman PUSH_BASIC_STACK(STACK_SIZE) 23*611e3850SMichael Ellerman 24*611e3850SMichael Ellerman // Save non-volatile GPRs 25*611e3850SMichael Ellerman OP_REGS PPC_STL, GPR_SIZE, FIRST_GPR, 31, %r1, STACK_FRAME_LOCAL(0, 0), FIRST_GPR 26*611e3850SMichael Ellerman 27*611e3850SMichael Ellerman // Load GPRs with expected values 28*611e3850SMichael Ellerman OP_REGS PPC_LL, GPR_SIZE, FIRST_GPR, 31, r5, 0, FIRST_GPR 29*611e3850SMichael Ellerman 30*611e3850SMichael Ellerman // Load FPRs with expected values 31*611e3850SMichael Ellerman OP_REGS lfd, 8, 0, 31, r6 32*611e3850SMichael Ellerman 33*611e3850SMichael Ellerman // Signal to parent that we're ready 34*611e3850SMichael Ellerman li r0, 1 35*611e3850SMichael Ellerman stw r0, 0(r4) 36*611e3850SMichael Ellerman 37*611e3850SMichael Ellerman // Wait for parent to finish 38*611e3850SMichael Ellerman1: lwz r0, 0(r3) 39*611e3850SMichael Ellerman cmpwi r0, 0 40*611e3850SMichael Ellerman beq 1b // Loop while flag is zero 41*611e3850SMichael Ellerman 42*611e3850SMichael Ellerman // Save GPRs back to caller buffer 43*611e3850SMichael Ellerman OP_REGS PPC_STL, GPR_SIZE, FIRST_GPR, 31, r5, 0, FIRST_GPR 44*611e3850SMichael Ellerman 45*611e3850SMichael Ellerman // Save FPRs 46*611e3850SMichael Ellerman OP_REGS stfd, 8, 0, 31, r6 47*611e3850SMichael Ellerman 48*611e3850SMichael Ellerman // Reload non-volatile GPRs 49*611e3850SMichael Ellerman OP_REGS PPC_LL, GPR_SIZE, FIRST_GPR, 31, %r1, STACK_FRAME_LOCAL(0, 0), FIRST_GPR 50*611e3850SMichael Ellerman 51*611e3850SMichael Ellerman POP_BASIC_STACK(STACK_SIZE) 52*611e3850SMichael Ellerman blr 53