1*5d9d9091SRichard Lowe/* 2*5d9d9091SRichard Lowe * CDDL HEADER START 3*5d9d9091SRichard Lowe * 4*5d9d9091SRichard Lowe * The contents of this file are subject to the terms of the 5*5d9d9091SRichard Lowe * Common Development and Distribution License (the "License"). 6*5d9d9091SRichard Lowe * You may not use this file except in compliance with the License. 7*5d9d9091SRichard Lowe * 8*5d9d9091SRichard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5d9d9091SRichard Lowe * or http://www.opensolaris.org/os/licensing. 10*5d9d9091SRichard Lowe * See the License for the specific language governing permissions 11*5d9d9091SRichard Lowe * and limitations under the License. 12*5d9d9091SRichard Lowe * 13*5d9d9091SRichard Lowe * When distributing Covered Code, include this CDDL HEADER in each 14*5d9d9091SRichard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5d9d9091SRichard Lowe * If applicable, add the following below this CDDL HEADER, with the 16*5d9d9091SRichard Lowe * fields enclosed by brackets "[]" replaced with your own identifying 17*5d9d9091SRichard Lowe * information: Portions Copyright [yyyy] [name of copyright owner] 18*5d9d9091SRichard Lowe * 19*5d9d9091SRichard Lowe * CDDL HEADER END 20*5d9d9091SRichard Lowe */ 21*5d9d9091SRichard Lowe 22*5d9d9091SRichard Lowe/* 23*5d9d9091SRichard Lowe * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*5d9d9091SRichard Lowe * Use is subject to license terms. 25*5d9d9091SRichard Lowe */ 26*5d9d9091SRichard Lowe 27*5d9d9091SRichard Lowe#include <sys/param.h> 28*5d9d9091SRichard Lowe#include <sys/errno.h> 29*5d9d9091SRichard Lowe#include <sys/asm_linkage.h> 30*5d9d9091SRichard Lowe#include <sys/machthread.h> 31*5d9d9091SRichard Lowe#include <sys/asi.h> 32*5d9d9091SRichard Lowe#include <sys/privregs.h> 33*5d9d9091SRichard Lowe#include <sys/spitregs.h> 34*5d9d9091SRichard Lowe 35*5d9d9091SRichard Lowe#include "assym.h" 36*5d9d9091SRichard Lowe 37*5d9d9091SRichard Lowe/* 38*5d9d9091SRichard Lowe * fhc_shutdown_asm(u_longlong_t base, int size) 39*5d9d9091SRichard Lowe * 40*5d9d9091SRichard Lowe * Flush cpu E$ then shutdown. 41*5d9d9091SRichard Lowe * This function is special in that it really sets the D-tags to 42*5d9d9091SRichard Lowe * a known state. And this is the behavior we're looking for. 43*5d9d9091SRichard Lowe * 44*5d9d9091SRichard Lowe * The flush address is known to be a cpu-unique non-existent 45*5d9d9091SRichard Lowe * cacheable address. We write to non-existent memory, using 46*5d9d9091SRichard Lowe * the side effect of d-tag invalidation. 47*5d9d9091SRichard Lowe * 48*5d9d9091SRichard Lowe * Also, note that this function is never run from main memory. 49*5d9d9091SRichard Lowe * Rather it is copied to non-cacheable SRAM (hence the ..._end 50*5d9d9091SRichard Lowe * label at the bottom of the function). This implies that the 51*5d9d9091SRichard Lowe * function must be position independent code that doesn't reference 52*5d9d9091SRichard Lowe * cacheable real memory. 53*5d9d9091SRichard Lowe */ 54*5d9d9091SRichard Lowe 55*5d9d9091SRichard Lowe ENTRY(fhc_shutdown_asm) 56*5d9d9091SRichard Lowe ! turn off errors (we'll be writing to non-existent memory) 57*5d9d9091SRichard Lowe stxa %g0, [%g0]ASI_ESTATE_ERR 58*5d9d9091SRichard Lowe membar #Sync ! SYNC 59*5d9d9091SRichard Lowe 60*5d9d9091SRichard Lowe rdpr %pstate, %o4 61*5d9d9091SRichard Lowe andn %o4, PSTATE_IE | PSTATE_AM, %o3 62*5d9d9091SRichard Lowe wrpr %o3, %g0, %pstate 63*5d9d9091SRichard Lowe1: 64*5d9d9091SRichard Lowe brlez,pn %o1, 2f ! if (len <= 0) exit loop 65*5d9d9091SRichard Lowe dec 64, %o1 ! size -= 64 66*5d9d9091SRichard Lowe sta %g0, [%o0]ASI_MEM ! store (unpopulated) word 67*5d9d9091SRichard Lowe ba 1b 68*5d9d9091SRichard Lowe inc 64, %o0 ! addr += 64 69*5d9d9091SRichard Lowe2: 70*5d9d9091SRichard Lowe membar #Sync ! SYNC 71*5d9d9091SRichard Lowe shutdown ! SHUTDOWN 72*5d9d9091SRichard Lowe /*NOTREACHED*/ 73*5d9d9091SRichard Lowe 74*5d9d9091SRichard Lowe ! if, for some reason, this cpu doesn't shutdown, just sit here 75*5d9d9091SRichard Lowe3: 76*5d9d9091SRichard Lowe ba 3b 77*5d9d9091SRichard Lowe nop ! eventually the master will notice 78*5d9d9091SRichard Lowe SET_SIZE(fhc_shutdown_asm) 79*5d9d9091SRichard Lowe 80*5d9d9091SRichard Lowe .global fhc_shutdown_asm_end 81*5d9d9091SRichard Lowefhc_shutdown_asm_end: 82*5d9d9091SRichard Lowe 83