Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * test helper assembly functions
0004  *
0005  * Copyright (C) 2016 Simon Guo, IBM Corporation.
0006  * Copyright 2022 Michael Ellerman, IBM Corporation.
0007  */
0008 #include "basic_asm.h"
0009 
0010 #define GPR_SIZE    __SIZEOF_LONG__
0011 #define FIRST_GPR   14
0012 #define NUM_GPRS    (32 - FIRST_GPR)
0013 #define STACK_SIZE  (NUM_GPRS * GPR_SIZE)
0014 
0015 // gpr_child_loop(int *read_flag, int *write_flag,
0016 //        unsigned long *gpr_buf, double *fpr_buf);
0017 FUNC_START(gpr_child_loop)
0018     // r3 = read_flag
0019     // r4 = write_flag
0020     // r5 = gpr_buf
0021     // r6 = fpr_buf
0022     PUSH_BASIC_STACK(STACK_SIZE)
0023 
0024     // Save non-volatile GPRs
0025     OP_REGS PPC_STL, GPR_SIZE, FIRST_GPR, 31, %r1, STACK_FRAME_LOCAL(0, 0), FIRST_GPR
0026 
0027     // Load GPRs with expected values
0028     OP_REGS PPC_LL, GPR_SIZE, FIRST_GPR, 31, r5, 0, FIRST_GPR
0029 
0030     // Load FPRs with expected values
0031     OP_REGS lfd, 8, 0, 31, r6
0032 
0033     // Signal to parent that we're ready
0034     li  r0, 1
0035     stw r0, 0(r4)
0036 
0037     // Wait for parent to finish
0038 1:  lwz r0, 0(r3)
0039     cmpwi   r0, 0
0040     beq 1b  // Loop while flag is zero
0041 
0042     // Save GPRs back to caller buffer
0043     OP_REGS PPC_STL, GPR_SIZE, FIRST_GPR, 31, r5, 0, FIRST_GPR
0044 
0045     // Save FPRs
0046     OP_REGS stfd, 8, 0, 31, r6
0047 
0048     // Reload non-volatile GPRs
0049     OP_REGS PPC_LL, GPR_SIZE, FIRST_GPR, 31, %r1, STACK_FRAME_LOCAL(0, 0), FIRST_GPR
0050 
0051     POP_BASIC_STACK(STACK_SIZE)
0052     blr