xref: /titanic_52/usr/src/uts/sun4/os/cpu_states.c (revision 005d3feb53a9a10272d4a24b03991575d6a9bcb3)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53c431bb5Swentaoy  * Common Development and Distribution License (the "License").
63c431bb5Swentaoy  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*005d3febSMarek Pospisil  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <sys/reboot.h>
287c478bd9Sstevel@tonic-gate #include <sys/systm.h>
297c478bd9Sstevel@tonic-gate #include <sys/archsystm.h>
307c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
317c478bd9Sstevel@tonic-gate #include <sys/promif.h>
327c478bd9Sstevel@tonic-gate #include <sys/promimpl.h>
337c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h>
347c478bd9Sstevel@tonic-gate #include <sys/cpu_sgnblk_defs.h>
357c478bd9Sstevel@tonic-gate #include <sys/ivintr.h>
367c478bd9Sstevel@tonic-gate #include <sys/kdi.h>
37ae115bc7Smrj #include <sys/kdi_machimpl.h>
387c478bd9Sstevel@tonic-gate #include <sys/callb.h>
393c431bb5Swentaoy #include <sys/wdt.h>
40*005d3febSMarek Pospisil #include <c2/audit.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	TRAPTRACE
437c478bd9Sstevel@tonic-gate #include <sys/traptrace.h>
447c478bd9Sstevel@tonic-gate #endif /* TRAPTRACE */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate extern void audit_enterprom();
477c478bd9Sstevel@tonic-gate extern void audit_exitprom();
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Platforms that use CPU signatures need to set cpu_sgn_func
517c478bd9Sstevel@tonic-gate  * to point to a platform specific function.  This needs to
527c478bd9Sstevel@tonic-gate  * be done in set_platform_defaults() within the platmod.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate void (*cpu_sgn_func)(ushort_t, uchar_t, uchar_t, int) = NULL;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * abort_seq_handler required by sysctrl.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate void debug_enter(char *);
607c478bd9Sstevel@tonic-gate void (*abort_seq_handler)(char *) = debug_enter;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Platform tunable to disable the h/w watchdog timer.
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate extern void clear_watchdog_on_exit(void);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * On sun4u platform, abort_sequence_enter() can be called at high PIL
697c478bd9Sstevel@tonic-gate  * and we can't afford to acquire any adaptive mutex or use any
707c478bd9Sstevel@tonic-gate  * condition variables as we are not allowed to sleep while running
717c478bd9Sstevel@tonic-gate  * on interrupt stack. We work around this problem by posting a level
727c478bd9Sstevel@tonic-gate  * 10 soft interrupt and then invoking the "abort_seq_handler" within
737c478bd9Sstevel@tonic-gate  * that soft interrupt context.
747c478bd9Sstevel@tonic-gate  *
757c478bd9Sstevel@tonic-gate  * This has the side effect of not allowing us to drop into debugger
767c478bd9Sstevel@tonic-gate  * when the kernel is stuck at high PIL (PIL > 10).  It's better to
777c478bd9Sstevel@tonic-gate  * be able to break into a hung system even if it means crashing the
787c478bd9Sstevel@tonic-gate  * system.  If a user presses L1-A more than once within a 15 seconds
797c478bd9Sstevel@tonic-gate  * window, and the previous L1-A soft interrupt is still pending, then
807c478bd9Sstevel@tonic-gate  * we directly invoke the abort_sequence_enter.
817c478bd9Sstevel@tonic-gate  *
827c478bd9Sstevel@tonic-gate  * Since the "msg" argument passed to abort_sequence_enter can refer
837c478bd9Sstevel@tonic-gate  * to a message anywhere in memory, including stack, it's copied into
847c478bd9Sstevel@tonic-gate  * abort_seq_msgbuf buffer for processing by the soft interrupt.
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	ABORT_SEQ_MSGBUFSZ	256
887c478bd9Sstevel@tonic-gate #define	FORCE_ABORT_SEQ_INTERVAL ((hrtime_t)15 * NANOSEC)
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate static kmutex_t	abort_seq_lock;
91b0fc0e77Sgovinda static uint64_t	abort_seq_inum;		/* abort seq softintr # */
927c478bd9Sstevel@tonic-gate static hrtime_t	abort_seq_tstamp;	/* hrtime of last abort seq */
937c478bd9Sstevel@tonic-gate static size_t	abort_seq_msglen;	/* abort seq message length */
947c478bd9Sstevel@tonic-gate static char	abort_seq_msgbuf[ABORT_SEQ_MSGBUFSZ];
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /*ARGSUSED0*/
977c478bd9Sstevel@tonic-gate static uint_t
987c478bd9Sstevel@tonic-gate abort_seq_softintr(caddr_t arg)
997c478bd9Sstevel@tonic-gate {
1007c478bd9Sstevel@tonic-gate 	char	    *msg;
1017c478bd9Sstevel@tonic-gate 	char	    msgbuf[ABORT_SEQ_MSGBUFSZ];
102*005d3febSMarek Pospisil 	uint32_t    auditing = AU_ZONE_AUDITING(GET_KCTX_GZ);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	mutex_enter(&abort_seq_lock);
1057c478bd9Sstevel@tonic-gate 	if (abort_enable != 0 && abort_seq_tstamp != 0LL) {
1067c478bd9Sstevel@tonic-gate 		if (abort_seq_msglen > 0) {
1077c478bd9Sstevel@tonic-gate 			bcopy(abort_seq_msgbuf, msgbuf, abort_seq_msglen);
1087c478bd9Sstevel@tonic-gate 			msg = msgbuf;
1097c478bd9Sstevel@tonic-gate 		} else
1107c478bd9Sstevel@tonic-gate 			msg = NULL;
1117c478bd9Sstevel@tonic-gate 		abort_seq_tstamp = 0LL;
1127c478bd9Sstevel@tonic-gate 		mutex_exit(&abort_seq_lock);
113*005d3febSMarek Pospisil 		if (auditing)
1147c478bd9Sstevel@tonic-gate 			audit_enterprom(1);
1157c478bd9Sstevel@tonic-gate 		(*abort_seq_handler)(msg);
116*005d3febSMarek Pospisil 		if (auditing)
1177c478bd9Sstevel@tonic-gate 			audit_exitprom(1);
1187c478bd9Sstevel@tonic-gate 	} else {
1197c478bd9Sstevel@tonic-gate 		mutex_exit(&abort_seq_lock);
120*005d3febSMarek Pospisil 		if (auditing)
1217c478bd9Sstevel@tonic-gate 			audit_enterprom(0);
1227c478bd9Sstevel@tonic-gate 	}
1237c478bd9Sstevel@tonic-gate 	return (1);
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate void
1277c478bd9Sstevel@tonic-gate abort_sequence_init(void)
1287c478bd9Sstevel@tonic-gate {
1297c478bd9Sstevel@tonic-gate 	mutex_init(&abort_seq_lock, NULL, MUTEX_SPIN, (void *)PIL_12);
1307c478bd9Sstevel@tonic-gate 	abort_seq_tstamp = 0LL;
1317c478bd9Sstevel@tonic-gate 	if (abort_seq_inum == 0)
1327c478bd9Sstevel@tonic-gate 		abort_seq_inum = add_softintr(LOCK_LEVEL,
133b0fc0e77Sgovinda 		    (softintrfunc)abort_seq_softintr, NULL, SOFTINT_ST);
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate  *	Machine dependent abort sequence handling
1387c478bd9Sstevel@tonic-gate  */
1397c478bd9Sstevel@tonic-gate void
1407c478bd9Sstevel@tonic-gate abort_sequence_enter(char *msg)
1417c478bd9Sstevel@tonic-gate {
1427c478bd9Sstevel@tonic-gate 	int		s, on_intr;
1437c478bd9Sstevel@tonic-gate 	size_t		msglen;
1447c478bd9Sstevel@tonic-gate 	hrtime_t	tstamp;
145*005d3febSMarek Pospisil 	int		auditing = AU_ZONE_AUDITING(GET_KCTX_GZ);
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	if (abort_enable != 0) {
1487c478bd9Sstevel@tonic-gate 		s = splhi();
1497c478bd9Sstevel@tonic-gate 		on_intr = CPU_ON_INTR(CPU) || (spltoipl(s) > LOCK_LEVEL);
1507c478bd9Sstevel@tonic-gate 		splx(s);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 		tstamp = gethrtime();
1537c478bd9Sstevel@tonic-gate 		mutex_enter(&abort_seq_lock);
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate 		/*
1567c478bd9Sstevel@tonic-gate 		 * If we are on an interrupt stack and/or running at
1577c478bd9Sstevel@tonic-gate 		 * PIL > LOCK_LEVEL, then we post a softint and invoke
1587c478bd9Sstevel@tonic-gate 		 * abort_seq_handler from there as we can't afford to
1597c478bd9Sstevel@tonic-gate 		 * acquire any adaptive mutex here. However, if we
1607c478bd9Sstevel@tonic-gate 		 * already have a pending softint, which was posted
1617c478bd9Sstevel@tonic-gate 		 * within FORCE_ABORT_SEQ_INTERVAL duration, then we
1627c478bd9Sstevel@tonic-gate 		 * bypass softint approach as our softint may be blocked
1637c478bd9Sstevel@tonic-gate 		 * and the user really wants to drop into the debugger.
1647c478bd9Sstevel@tonic-gate 		 */
1657c478bd9Sstevel@tonic-gate 		if (on_intr && abort_seq_inum != 0 &&
1667c478bd9Sstevel@tonic-gate 		    (abort_seq_tstamp == 0LL || tstamp >
1677c478bd9Sstevel@tonic-gate 		    (abort_seq_tstamp + FORCE_ABORT_SEQ_INTERVAL))) {
1687c478bd9Sstevel@tonic-gate 			abort_seq_tstamp = tstamp;
1697c478bd9Sstevel@tonic-gate 			if (msg != NULL) {
1707c478bd9Sstevel@tonic-gate 				msglen = strlen(msg);
1717c478bd9Sstevel@tonic-gate 				if (msglen >= ABORT_SEQ_MSGBUFSZ)
1727c478bd9Sstevel@tonic-gate 					msglen = ABORT_SEQ_MSGBUFSZ - 1;
1737c478bd9Sstevel@tonic-gate 				bcopy(msg, abort_seq_msgbuf, msglen);
1747c478bd9Sstevel@tonic-gate 				abort_seq_msgbuf[msglen] = '\0';
1757c478bd9Sstevel@tonic-gate 				abort_seq_msglen = msglen + 1;
1767c478bd9Sstevel@tonic-gate 			} else
1777c478bd9Sstevel@tonic-gate 				abort_seq_msglen = 0;
1787c478bd9Sstevel@tonic-gate 			mutex_exit(&abort_seq_lock);
1797c478bd9Sstevel@tonic-gate 			setsoftint(abort_seq_inum);
1807c478bd9Sstevel@tonic-gate 		} else {
1817c478bd9Sstevel@tonic-gate 			/*
1827c478bd9Sstevel@tonic-gate 			 * Ignore any pending abort sequence softint
1837c478bd9Sstevel@tonic-gate 			 * as we are invoking the abort_seq_handler
1847c478bd9Sstevel@tonic-gate 			 * here.
1857c478bd9Sstevel@tonic-gate 			 */
1867c478bd9Sstevel@tonic-gate 			abort_seq_tstamp = 0LL;
1877c478bd9Sstevel@tonic-gate 			mutex_exit(&abort_seq_lock);
188*005d3febSMarek Pospisil 		if (!on_intr && auditing)
1897c478bd9Sstevel@tonic-gate 			audit_enterprom(1);
1907c478bd9Sstevel@tonic-gate 			(*abort_seq_handler)(msg);
191*005d3febSMarek Pospisil 		if (!on_intr && auditing)
1927c478bd9Sstevel@tonic-gate 			audit_exitprom(1);
1937c478bd9Sstevel@tonic-gate 		}
1947c478bd9Sstevel@tonic-gate 	} else {
195*005d3febSMarek Pospisil 		if (auditing)
1967c478bd9Sstevel@tonic-gate 			audit_enterprom(0);
1977c478bd9Sstevel@tonic-gate 	}
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * Enter debugger.  Called when the user types L1-A or break or whenever
2027c478bd9Sstevel@tonic-gate  * code wants to enter the debugger and possibly resume later.
2037c478bd9Sstevel@tonic-gate  * If the debugger isn't present, enter the PROM monitor.
2047c478bd9Sstevel@tonic-gate  *
2057c478bd9Sstevel@tonic-gate  * If console is a framebuffer which is powered off, it will be powered up
2067c478bd9Sstevel@tonic-gate  * before jumping to the debugger.  If we are called above lock level, a
2077c478bd9Sstevel@tonic-gate  * softint is triggered to reenter this code and allow the fb to be powered
2087c478bd9Sstevel@tonic-gate  * up as in the less than lock level case.  If this code is entered at greater
2097c478bd9Sstevel@tonic-gate  * than lock level and the fb is not already powered up, the msg argument
2107c478bd9Sstevel@tonic-gate  * will not be displayed.
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate void
2137c478bd9Sstevel@tonic-gate debug_enter(char *msg)
2147c478bd9Sstevel@tonic-gate {
2157c478bd9Sstevel@tonic-gate 	label_t old_pcb;
2167c478bd9Sstevel@tonic-gate 	int s;
2177c478bd9Sstevel@tonic-gate 	extern void pm_cfb_powerup(void);
2187c478bd9Sstevel@tonic-gate 	extern void pm_cfb_rele(void);
2197c478bd9Sstevel@tonic-gate 	extern void pm_cfb_trigger(void);
2207c478bd9Sstevel@tonic-gate 	extern int pm_cfb_check_and_hold(void);
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	/*
2237c478bd9Sstevel@tonic-gate 	 * For platforms that use CPU signatures, update the signature
2247c478bd9Sstevel@tonic-gate 	 * to indicate that we are entering the debugger if we are in
2257c478bd9Sstevel@tonic-gate 	 * the middle of a panic flow.
2267c478bd9Sstevel@tonic-gate 	 */
2277c478bd9Sstevel@tonic-gate 	if (panicstr)
2287c478bd9Sstevel@tonic-gate 		CPU_SIGNATURE(OS_SIG, SIGST_EXIT, SIGSUBST_DEBUG, -1);
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate 	if (!panicstr)
2317c478bd9Sstevel@tonic-gate 		(void) callb_execute_class(CB_CL_ENTER_DEBUGGER, 0);
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate 	if (pm_cfb_check_and_hold())
2347c478bd9Sstevel@tonic-gate 		if (getpil() > LOCK_LEVEL) {
2357c478bd9Sstevel@tonic-gate 			pm_cfb_trigger();
2367c478bd9Sstevel@tonic-gate 			return;
2377c478bd9Sstevel@tonic-gate 		} else
2387c478bd9Sstevel@tonic-gate 			pm_cfb_powerup();
2397c478bd9Sstevel@tonic-gate 	if (msg)
2407c478bd9Sstevel@tonic-gate 		prom_printf("%s\n", msg);
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate 	clear_watchdog_on_exit();
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 	if ((s = getpil()) < ipltospl(12))
2457c478bd9Sstevel@tonic-gate 		s = splzs();
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	old_pcb = curthread->t_pcb;
2487c478bd9Sstevel@tonic-gate 	(void) setjmp(&curthread->t_pcb);
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	if (boothowto & RB_DEBUG)
251ae115bc7Smrj 		kmdb_enter();
2527c478bd9Sstevel@tonic-gate 	else
2537c478bd9Sstevel@tonic-gate 		prom_enter_mon();
2547c478bd9Sstevel@tonic-gate 
2553c431bb5Swentaoy 	restore_watchdog_on_entry();
2563c431bb5Swentaoy 
2577c478bd9Sstevel@tonic-gate 	curthread->t_pcb = old_pcb;
2587c478bd9Sstevel@tonic-gate 	splx(s);
2597c478bd9Sstevel@tonic-gate 	pm_cfb_rele();
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	if (!panicstr)
2627c478bd9Sstevel@tonic-gate 		(void) callb_execute_class(CB_CL_ENTER_DEBUGGER, 1);
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate 	if (panicstr)
2657c478bd9Sstevel@tonic-gate 		CPU_SIGNATURE(OS_SIG, SIGST_EXIT, SIGSUBST_PANIC_CONT, -1);
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate /*
2697c478bd9Sstevel@tonic-gate  * Halt the machine and return to the monitor
2707c478bd9Sstevel@tonic-gate  */
2717c478bd9Sstevel@tonic-gate void
2727c478bd9Sstevel@tonic-gate halt(char *s)
2737c478bd9Sstevel@tonic-gate {
2747c478bd9Sstevel@tonic-gate 	flush_windows();
2757c478bd9Sstevel@tonic-gate 	stop_other_cpus();		/* send stop signal to other CPUs */
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 	if (s)
2787c478bd9Sstevel@tonic-gate 		prom_printf("(%s) ", s);
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 	/*
2817c478bd9Sstevel@tonic-gate 	 * For Platforms that use CPU signatures, we
2827c478bd9Sstevel@tonic-gate 	 * need to set the signature block to OS and
2837c478bd9Sstevel@tonic-gate 	 * the state to exiting for all the processors.
2847c478bd9Sstevel@tonic-gate 	 */
2857c478bd9Sstevel@tonic-gate 	CPU_SIGNATURE(OS_SIG, SIGST_EXIT, SIGSUBST_HALT, -1);
2867c478bd9Sstevel@tonic-gate 	prom_exit_to_mon();
2877c478bd9Sstevel@tonic-gate 	/*NOTREACHED*/
2887c478bd9Sstevel@tonic-gate }
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * Halt the machine and power off the system.
2927c478bd9Sstevel@tonic-gate  */
2937c478bd9Sstevel@tonic-gate void
2947c478bd9Sstevel@tonic-gate power_down(const char *s)
2957c478bd9Sstevel@tonic-gate {
2967c478bd9Sstevel@tonic-gate 	flush_windows();
2977c478bd9Sstevel@tonic-gate 	stop_other_cpus();		/* send stop signal to other CPUs */
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 	if (s != NULL)
3007c478bd9Sstevel@tonic-gate 		prom_printf("(%s) ", s);
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 	/*
3037c478bd9Sstevel@tonic-gate 	 * For platforms that use CPU signatures, we need to set up the
3047c478bd9Sstevel@tonic-gate 	 * signature blocks to indicate that we have an environmental
3057c478bd9Sstevel@tonic-gate 	 * interrupt request to power down, and then exit to the prom monitor.
3067c478bd9Sstevel@tonic-gate 	 */
3077c478bd9Sstevel@tonic-gate 	CPU_SIGNATURE(OS_SIG, SIGST_EXIT, SIGSUBST_ENVIRON, -1);
3087c478bd9Sstevel@tonic-gate 	prom_power_off();
3097c478bd9Sstevel@tonic-gate 	/*
3107c478bd9Sstevel@tonic-gate 	 * If here is reached, for some reason prom's power-off command failed.
3117c478bd9Sstevel@tonic-gate 	 * Prom should have already printed out error messages. Exit to
3127c478bd9Sstevel@tonic-gate 	 * firmware.
3137c478bd9Sstevel@tonic-gate 	 */
3147c478bd9Sstevel@tonic-gate 	prom_exit_to_mon();
3157c478bd9Sstevel@tonic-gate 	/*NOTREACHED*/
3167c478bd9Sstevel@tonic-gate }
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate void
3197c478bd9Sstevel@tonic-gate do_shutdown(void)
3207c478bd9Sstevel@tonic-gate {
3217c478bd9Sstevel@tonic-gate 	proc_t *initpp;
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate 	/*
3247c478bd9Sstevel@tonic-gate 	 * If we're still booting and init(1) isn't set up yet, simply halt.
3257c478bd9Sstevel@tonic-gate 	 */
3267c478bd9Sstevel@tonic-gate 	mutex_enter(&pidlock);
3277c478bd9Sstevel@tonic-gate 	initpp = prfind(P_INITPID);
3287c478bd9Sstevel@tonic-gate 	mutex_exit(&pidlock);
3297c478bd9Sstevel@tonic-gate 	if (initpp == NULL) {
3307c478bd9Sstevel@tonic-gate 		extern void halt(char *);
3317c478bd9Sstevel@tonic-gate 		prom_power_off();
3327c478bd9Sstevel@tonic-gate 		halt("Power off the System");	/* just in case */
3337c478bd9Sstevel@tonic-gate 	}
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	/*
3367c478bd9Sstevel@tonic-gate 	 * else, graceful shutdown with inittab and all getting involved
3377c478bd9Sstevel@tonic-gate 	 */
3387c478bd9Sstevel@tonic-gate 	psignal(initpp, SIGPWR);
3397c478bd9Sstevel@tonic-gate }
340