* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: barrier_subr_v8.s
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
#pragma ident "@(#)1.2 02/05/23 barrier_subr_v8.s"
#include <sys/asm_linkage.h>
ld [%o0 + 20], %o1 ! load bp->sbp into %o1
! atomic decrement of running count
! check if this is the last one
! YES, switch sub-barriers, reset count and CV
add %o0, 4, %o2 ! %o2 = &bp->sb[0]
add %o0, 12, %o2 ! %o2 = &bp->sb[1]
1: st %o2, [%o0 + 20] ! store %o2 into bp->sbp
! release the CV busy-waiters
or %o0, 0, %o5 ! loopticks
ld [%o0 + 20], %o1 ! load bp->sbp into %o1
ld [%o0 + 24], %o0 !!!!!! global tick pointer
! atomic decrement of running count
retry1: ldx [%o0], %o2 !!
! check if this is the last one
! YES, switch sub-barriers, reset count and CV
add %o0, 4, %o2 ! %o2 = &bp->sb[0]
add %o0, 12, %o2 ! %o2 = &bp->sb[1]
1: st %o2, [%o0 + 20] ! store %o2 into bp->sbp
! release the CV busy-waiters