/* * ========== 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 #if 0 ENTRY(barrier) ld [%o0 + 20], %o1 ! load bp->sbp into %o1 ! atomic decrement of running count add %o1, 4, %o2 retry: ld [%o2], %o3 add %o3, -1, %o4 cas [%o2], %o3, %o4 cmp %o3, %o4 bne retry nop ! check if this is the last one cmp %o3, 1 bne wait nop ! YES, switch sub-barriers, reset count and CV add %o0, 4, %o2 ! %o2 = &bp->sb[0] cmp %o1, %o2 bne 1f nop add %o0, 12, %o2 ! %o2 = &bp->sb[1] 1: st %o2, [%o0 + 20] ! store %o2 into bp->sbp set 1, %o4 st %o4, [%o2] ld [%o0], %o3 st %o3, [%o2 + 4] ! release the CV busy-waiters retl clr [%o1] ! NO, busy-wait on CV wait: ld [%o1], %o2 tst %o2 bne wait nop retl nop SET_SIZE(barrier) #else .global cpu_barrier ENTRY(barrier) or %o0, 0, %o5 ! loopticks set cpu_barrier, %o0 ld [%o0 + 20], %o1 ! load bp->sbp into %o1 ld [%o0 + 24], %o0 !!!!!! global tick pointer ! atomic decrement of running count add %o1, 4, %o2 retry: ld [%o2], %o3 add %o3, -1, %o4 cas [%o2], %o3, %o4 cmp %o3, %o4 bne retry nop retry1: ldx [%o0], %o2 !! add %o2, %o5, %o4 !! casx [%o0], %o2, %o4 !! cmp %o2, %o4 !! bne,pn %xcc, retry1 nop !! ! check if this is the last one cmp %o3, 1 bne wait nop ! YES, switch sub-barriers, reset count and CV set cpu_barrier, %o0 add %o0, 4, %o2 ! %o2 = &bp->sb[0] cmp %o1, %o2 bne 1f nop add %o0, 12, %o2 ! %o2 = &bp->sb[1] 1: st %o2, [%o0 + 20] ! store %o2 into bp->sbp set 1, %o4 st %o4, [%o2] ld [%o0], %o3 st %o3, [%o2 + 4] ! release the CV busy-waiters retl clr [%o1] ! NO, busy-wait on CV wait: ld [%o1], %o2 tst %o2 bne wait nop retl nop SET_SIZE(barrier) #endif