Home | History | Annotate | Download | only in promif
      1  1991    heppo /*
      2  1991    heppo  * CDDL HEADER START
      3  1991    heppo  *
      4  1991    heppo  * The contents of this file are subject to the terms of the
      5  1991    heppo  * Common Development and Distribution License (the "License").
      6  1991    heppo  * You may not use this file except in compliance with the License.
      7  1991    heppo  *
      8  1991    heppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  1991    heppo  * or http://www.opensolaris.org/os/licensing.
     10  1991    heppo  * See the License for the specific language governing permissions
     11  1991    heppo  * and limitations under the License.
     12  1991    heppo  *
     13  1991    heppo  * When distributing Covered Code, include this CDDL HEADER in each
     14  1991    heppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  1991    heppo  * If applicable, add the following below this CDDL HEADER, with the
     16  1991    heppo  * fields enclosed by brackets "[]" replaced with your own identifying
     17  1991    heppo  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  1991    heppo  *
     19  1991    heppo  * CDDL HEADER END
     20  1991    heppo  */
     21  1991    heppo 
     22  1991    heppo /*
     23  8542     Haik  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     24  1991    heppo  * Use is subject to license terms.
     25  1991    heppo  */
     26  1991    heppo 
     27  1991    heppo #include <sys/promif_impl.h>
     28  1991    heppo #include <sys/uadmin.h>
     29  1991    heppo #include <sys/machsystm.h>
     30  1991    heppo #include <sys/hypervisor_api.h>
     31  1991    heppo 
     32  1991    heppo #ifdef _KMDB
     33  1991    heppo 
     34  1991    heppo extern int kmdb_dpi_get_master_cpuid(void);
     35  1991    heppo extern void kmdb_dpi_kernpanic(int cpuid);
     36  1991    heppo extern void prom_reboot(char *bootstr);
     37  1991    heppo 
     38  1991    heppo #define	PIL_DECL(p)
     39  1991    heppo #define	PIL_SET7(p)
     40  1991    heppo #define	PIL_REST(p)
     41  1991    heppo 
     42  1991    heppo #else
     43  1991    heppo 
     44  1991    heppo extern int vx_handler(cell_t *argument_array);
     45  8542     Haik extern void kldc_debug_enter(void);
     46  1991    heppo 
     47  1991    heppo #define	PIL_DECL(p) int p
     48  1991    heppo #define	PIL_SET7(p) (p = spl7())
     49  1991    heppo #define	PIL_REST(p) (splx(p))
     50  1991    heppo 
     51  1991    heppo #endif
     52  1991    heppo 
     53  1991    heppo #define	PROMIF_ISPRINT(c)	(((c) >= ' ') && ((c) <= '~'))
     54  1991    heppo 
     55  5974  jm22469 static int promif_ask_before_reset =
     56  1991    heppo #ifdef _KMDB
     57  5974  jm22469 	1;
     58  1991    heppo #else
     59  5974  jm22469 	0;
     60  1991    heppo #endif
     61  1991    heppo 
     62  1991    heppo /*ARGSUSED*/
     63  1991    heppo int
     64  1991    heppo promif_exit_to_mon(void *p)
     65  1991    heppo {
     66  1991    heppo 	PIL_DECL(pil);
     67  1991    heppo 
     68  1991    heppo 	PIL_SET7(pil);
     69  1991    heppo 
     70  1991    heppo 	prom_printf("Program terminated\n");
     71  1991    heppo 
     72  5974  jm22469 	if (promif_ask_before_reset) {
     73  5974  jm22469 		prom_printf("Press any key to reboot.");
     74  5974  jm22469 		(void) prom_getchar();
     75  5974  jm22469 	}
     76  5974  jm22469 
     77  5974  jm22469 	(void) hv_mach_sir();
     78  5974  jm22469 
     79  5974  jm22469 	/* should not return */
     80  5974  jm22469 	ASSERT(0);
     81  1991    heppo 
     82  1991    heppo 	PIL_REST(pil);
     83  1991    heppo 
     84  1991    heppo 	return (0);
     85  1991    heppo }
     86  1991    heppo 
     87  5974  jm22469 /*ARGSUSED*/
     88  5974  jm22469 int
     89  5974  jm22469 promif_enter_mon(void *p)
     90  1991    heppo {
     91  1991    heppo 	char		cmd;
     92  5974  jm22469 	static char	*prompt = "c)ontinue, s)ync, r)eset? ";
     93  5974  jm22469 	PIL_DECL(pil);
     94  5974  jm22469 
     95  5974  jm22469 	PIL_SET7(pil);
     96  5974  jm22469 
     97  5974  jm22469 #ifndef _KMDB
     98  5974  jm22469 	idle_other_cpus();
     99  8542     Haik 	kldc_debug_enter();
    100  1991    heppo #endif
    101  1991    heppo 
    102  1991    heppo 	for (;;) {
    103  1991    heppo 		prom_printf("%s", prompt);
    104  5974  jm22469 		cmd = promif_getchar();
    105  1991    heppo 		prom_printf("%c\n", cmd);
    106  1991    heppo 
    107  1991    heppo 		switch (cmd) {
    108  1991    heppo 
    109  1991    heppo 		case 'r':
    110  3263  jm22469 			prom_printf("Resetting...\n");
    111  3263  jm22469 
    112  3263  jm22469 			(void) hv_mach_sir();
    113  3263  jm22469 
    114  3263  jm22469 			/* should not return */
    115  3263  jm22469 			ASSERT(0);
    116  1991    heppo 			break;
    117  1991    heppo 
    118  1991    heppo 		case '\r':
    119  1991    heppo 			break;
    120  1991    heppo 
    121  1991    heppo 		case 's':
    122  5974  jm22469 			{
    123  1991    heppo #ifdef _KMDB
    124  1991    heppo 				kmdb_dpi_kernpanic(kmdb_dpi_get_master_cpuid());
    125  1991    heppo #else
    126  1991    heppo 				cell_t arg = p1275_ptr2cell("sync");
    127  5974  jm22469 
    128  1991    heppo 				(void) vx_handler(&arg);
    129  1991    heppo #endif
    130  1991    heppo 			}
    131  5974  jm22469 
    132  5974  jm22469 			/* should not return */
    133  5974  jm22469 			ASSERT(0);
    134  1991    heppo 			break;
    135  1991    heppo 
    136  1991    heppo 		case 'c':
    137  5974  jm22469 #ifndef _KMDB
    138  5974  jm22469 			resume_other_cpus();
    139  5974  jm22469 #endif
    140  5974  jm22469 			PIL_REST(pil);
    141  5974  jm22469 
    142  5974  jm22469 			return (0);
    143  1991    heppo 
    144  1991    heppo 		default:
    145  5974  jm22469 			if (PROMIF_ISPRINT(cmd))
    146  5974  jm22469 				prom_printf("invalid option (%c)\n", cmd);
    147  1991    heppo 			break;
    148  1991    heppo 		}
    149  1991    heppo 	}
    150  1991    heppo 
    151  1991    heppo 	_NOTE(NOTREACHED)
    152  1991    heppo }
    153