* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: cmp_park_self.s
* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* For the avoidance of doubt, and except that if any non-GPL license
* choice is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any
* software where a choice of GPL license versions is made
* available with the language indicating that GPLv2 or any later version
* may be used, or where a choice of which version of the GPL is applied is
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* ========== Copyright Header End ============================================
#define MAIN_PAGE_HV_ALSO
/************************************************************************
************************************************************************/
! Determine thread running on
be main_t0 ! Branch if thread 0
ba main_t1 ! Branch if thread 1
/************************************************************************
************************************************************************/
/* Signal thread 1 it can start. */
setx user_data_start, %g1, %g2
/* Wait for thread 1 to do all its work. */
/* Note that at this time thread 1 will be
waiting for thread 0 to do all of its work. */
/* Check that CORE_RUNNING_RW = CORE_RUNNING_STATUS */
setx ASI_CMP_CORE_RUNNING_RW, %g1, %g2
setx ASI_CMP_CORE_RUNNING_STATUS, %g1, %g3
ldxa [%g2]ASI_CMP_CORE, %g4
ldxa [%g3]ASI_CMP_CORE, %g5
/* Park thread 1, i.e. set CORE_RUNNING_RW[63:0] = 0x1 */
/* Park the other thread */
ldxa [%g0]ASI_INTR_ID, %o2 ! get full thread ID
stxa %g7, [%g2]ASI_CMP_CORE
/* Wait long enough for thread 1 to park. */
beq local_test_failed ! Fails if thead 1 never parks
ldxa [%g3]ASI_CMP_CORE, %g5
dec %g6 ! decrement loop count
/* Also check CORE_RUNING_RW = 1 */
ldxa [%g2]ASI_CMP_CORE, %g4
/* Thread 0 attempts to park all threads, i.e. CORE_RUNNING_RW = 0 */
stxa %g0, [%g2]ASI_CMP_CORE
/* Wait long enough for a thread to park itself. */
bne t0_th0_park_loop_top ! Waited long enough
dec %g6 ! decrement loop count
/* Check that CORE_RUNNING_RW = CORE_RUNNING_STATUS = 0x1 */
ldxa [%g2]ASI_CMP_CORE, %g4
ldxa [%g3]ASI_CMP_CORE, %g5
stxa %g6, [%g2]ASI_CMP_CORE
setx user_data_start, %g1, %g7
stx %g6, [%g7] ! Signal thread 1 to exit
/************************************************************************
************************************************************************/
/* Check that CORE_RUNNING_RW = CORE_RUNNING_STATUS */
setx ASI_CMP_CORE_RUNNING_RW, %g1, %g2
setx ASI_CMP_CORE_RUNNING_STATUS, %g1, %g3
ldxa [%g2]ASI_CMP_CORE, %g4
ldxa [%g3]ASI_CMP_CORE, %g5
/* Wait for thread 0 to signal it is ready. */
setx user_data_start, %g1, %g2
bne t1_th0_startup_loop_top
/* Park thread 0, i.e. set CORE_RUNNING_RW[63:0] = 0x2 */
setx ASI_CMP_CORE_RUNNING_RW, %g1, %g2
/* Park first thread in this core */
setx ASI_CMP_CORE_RUNNING_RW, %g1, %g2
ldxa [%g0]ASI_INTR_ID, %o2 ! get full thread ID
stxa %g7, [%g2]ASI_CMP_CORE
/* Wait long enough for thread 0 to park. */
set 0x100, %g6 ! loop count
t1_th0_park_wait_loop_top:
ldxa [%g3]ASI_CMP_CORE, %g5
bne t1_th0_park_wait_loop_top
/* Check that CORE_RUNNING_RW = 0x2 */
ldxa [%g2]ASI_CMP_CORE, %g4
/* Attempt to park all threads, i.e. set CORE_RUNNING_RW = 0 */
stxa %g0, [%g2]ASI_CMP_CORE
/* Wait long enough for a thread to park. */
bne t1_th1_park_loop_top ! Waited long enough
dec %g6 ! decrement loop count
/* Check that CORE_RUNNING_RW = CORE_RUNNING_STATUS = 0x2 */
ldxa [%g2]ASI_CMP_CORE, %g4
ldxa [%g3]ASI_CMP_CORE, %g5
stxa %g6, [%g2]ASI_CMP_CORE
/* Signal thread 0 to stop waiting. */
setx user_data_start, %g1, %g6
/* Wait for thread 0 to do all its work. */
/**********************************************************************/
/************************************************************************
************************************************************************/