29949e866e40b95795203f3ee46f44a197c946e4stevel/*
29949e866e40b95795203f3ee46f44a197c946e4stevel * CDDL HEADER START
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * The contents of this file are subject to the terms of the
29949e866e40b95795203f3ee46f44a197c946e4stevel * Common Development and Distribution License (the "License").
29949e866e40b95795203f3ee46f44a197c946e4stevel * You may not use this file except in compliance with the License.
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
29949e866e40b95795203f3ee46f44a197c946e4stevel * or http://www.opensolaris.org/os/licensing.
29949e866e40b95795203f3ee46f44a197c946e4stevel * See the License for the specific language governing permissions
29949e866e40b95795203f3ee46f44a197c946e4stevel * and limitations under the License.
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * When distributing Covered Code, include this CDDL HEADER in each
29949e866e40b95795203f3ee46f44a197c946e4stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
29949e866e40b95795203f3ee46f44a197c946e4stevel * If applicable, add the following below this CDDL HEADER, with the
29949e866e40b95795203f3ee46f44a197c946e4stevel * fields enclosed by brackets "[]" replaced with your own identifying
29949e866e40b95795203f3ee46f44a197c946e4stevel * information: Portions Copyright [yyyy] [name of copyright owner]
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * CDDL HEADER END
29949e866e40b95795203f3ee46f44a197c946e4stevel */
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel/*
29949e866e40b95795203f3ee46f44a197c946e4stevel * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Use is subject to license terms.
29949e866e40b95795203f3ee46f44a197c946e4stevel */
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel#pragma ident "%Z%%M% %I% %E% SMI"
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/param.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/errno.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/asm_linkage.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/machthread.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/asi.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/privregs.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel#include <sys/spitregs.h>
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel#if defined(lint)
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel#else /* lint */
29949e866e40b95795203f3ee46f44a197c946e4stevel#include "assym.h"
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* lint */
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel/*
29949e866e40b95795203f3ee46f44a197c946e4stevel * fhc_shutdown_asm(u_longlong_t base, int size)
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * Flush cpu E$ then shutdown.
29949e866e40b95795203f3ee46f44a197c946e4stevel * This function is special in that it really sets the D-tags to
29949e866e40b95795203f3ee46f44a197c946e4stevel * a known state. And this is the behavior we're looking for.
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * The flush address is known to be a cpu-unique non-existent
29949e866e40b95795203f3ee46f44a197c946e4stevel * cacheable address. We write to non-existent memory, using
29949e866e40b95795203f3ee46f44a197c946e4stevel * the side effect of d-tag invalidation.
29949e866e40b95795203f3ee46f44a197c946e4stevel *
29949e866e40b95795203f3ee46f44a197c946e4stevel * Also, note that this function is never run from main memory.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Rather it is copied to non-cacheable SRAM (hence the ..._end
29949e866e40b95795203f3ee46f44a197c946e4stevel * label at the bottom of the function). This implies that the
29949e866e40b95795203f3ee46f44a197c946e4stevel * function must be position independent code that doesn't reference
29949e866e40b95795203f3ee46f44a197c946e4stevel * cacheable real memory.
29949e866e40b95795203f3ee46f44a197c946e4stevel */
29949e866e40b95795203f3ee46f44a197c946e4stevel#if defined(lint)
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel/*ARGSUSED*/
29949e866e40b95795203f3ee46f44a197c946e4stevelvoid
29949e866e40b95795203f3ee46f44a197c946e4stevelfhc_shutdown_asm(u_longlong_t base, int size)
29949e866e40b95795203f3ee46f44a197c946e4stevel{}
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel#else /* lint */
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel ENTRY(fhc_shutdown_asm)
29949e866e40b95795203f3ee46f44a197c946e4stevel ! turn off errors (we'll be writing to non-existent memory)
29949e866e40b95795203f3ee46f44a197c946e4stevel stxa %g0, [%g0]ASI_ESTATE_ERR
29949e866e40b95795203f3ee46f44a197c946e4stevel membar #Sync ! SYNC
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel rdpr %pstate, %o4
29949e866e40b95795203f3ee46f44a197c946e4stevel andn %o4, PSTATE_IE | PSTATE_AM, %o3
29949e866e40b95795203f3ee46f44a197c946e4stevel wrpr %o3, %g0, %pstate
29949e866e40b95795203f3ee46f44a197c946e4stevel1:
29949e866e40b95795203f3ee46f44a197c946e4stevel brlez,pn %o1, 2f ! if (len <= 0) exit loop
29949e866e40b95795203f3ee46f44a197c946e4stevel dec 64, %o1 ! size -= 64
29949e866e40b95795203f3ee46f44a197c946e4stevel sta %g0, [%o0]ASI_MEM ! store (unpopulated) word
29949e866e40b95795203f3ee46f44a197c946e4stevel ba 1b
29949e866e40b95795203f3ee46f44a197c946e4stevel inc 64, %o0 ! addr += 64
29949e866e40b95795203f3ee46f44a197c946e4stevel2:
29949e866e40b95795203f3ee46f44a197c946e4stevel membar #Sync ! SYNC
29949e866e40b95795203f3ee46f44a197c946e4stevel shutdown ! SHUTDOWN
29949e866e40b95795203f3ee46f44a197c946e4stevel /*NOTREACHED*/
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel ! if, for some reason, this cpu doesn't shutdown, just sit here
29949e866e40b95795203f3ee46f44a197c946e4stevel3:
29949e866e40b95795203f3ee46f44a197c946e4stevel ba 3b
29949e866e40b95795203f3ee46f44a197c946e4stevel nop ! eventually the master will notice
29949e866e40b95795203f3ee46f44a197c946e4stevel SET_SIZE(fhc_shutdown_asm)
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel .global fhc_shutdown_asm_end
29949e866e40b95795203f3ee46f44a197c946e4stevelfhc_shutdown_asm_end:
29949e866e40b95795203f3ee46f44a197c946e4stevel
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* lint */