Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright 2015, Cyril Bur, IBM Corp.
0004  */
0005 
0006 #include "basic_asm.h"
0007 #include "vsx_asm.h"
0008 
0009 #long check_vsx(vector int *r3);
0010 #This function wraps storeing VSX regs to the end of an array and a
0011 #call to a comparison function in C which boils down to a memcmp()
0012 FUNC_START(check_vsx)
0013     PUSH_BASIC_STACK(32)
0014     std r3,STACK_FRAME_PARAM(0)(sp)
0015     addi r3, r3, 16 * 12 #Second half of array
0016     bl store_vsx
0017     ld r3,STACK_FRAME_PARAM(0)(sp)
0018     bl vsx_memcmp
0019     POP_BASIC_STACK(32)
0020     blr
0021 FUNC_END(check_vsx)
0022 
0023 # int preempt_vmx(vector int *varray, int *threads_starting,
0024 #                 int *running);
0025 # On starting will (atomically) decrement threads_starting as a signal
0026 # that the VMX have been loaded with varray. Will proceed to check the
0027 # validity of the VMX registers while running is not zero.
0028 FUNC_START(preempt_vsx)
0029     PUSH_BASIC_STACK(512)
0030     std r3,STACK_FRAME_PARAM(0)(sp) # vector int *varray
0031     std r4,STACK_FRAME_PARAM(1)(sp) # int *threads_starting
0032     std r5,STACK_FRAME_PARAM(2)(sp) # int *running
0033 
0034     bl load_vsx
0035     nop
0036 
0037     sync
0038     # Atomic DEC
0039     ld r3,STACK_FRAME_PARAM(1)(sp)
0040 1:  lwarx r4,0,r3
0041     addi r4,r4,-1
0042     stwcx. r4,0,r3
0043     bne- 1b
0044 
0045 2:  ld r3,STACK_FRAME_PARAM(0)(sp)
0046     bl check_vsx
0047     nop
0048     cmpdi r3,0
0049     bne 3f
0050     ld r4,STACK_FRAME_PARAM(2)(sp)
0051     ld r5,0(r4)
0052     cmpwi r5,0
0053     bne 2b
0054 
0055 3:  POP_BASIC_STACK(512)
0056     blr
0057 FUNC_END(preempt_vsx)