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