11991Sheppo /* 21991Sheppo * CDDL HEADER START 31991Sheppo * 41991Sheppo * The contents of this file are subject to the terms of the 51991Sheppo * Common Development and Distribution License (the "License"). 61991Sheppo * You may not use this file except in compliance with the License. 71991Sheppo * 81991Sheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91991Sheppo * or http://www.opensolaris.org/os/licensing. 101991Sheppo * See the License for the specific language governing permissions 111991Sheppo * and limitations under the License. 121991Sheppo * 131991Sheppo * When distributing Covered Code, include this CDDL HEADER in each 141991Sheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151991Sheppo * If applicable, add the following below this CDDL HEADER, with the 161991Sheppo * fields enclosed by brackets "[]" replaced with your own identifying 171991Sheppo * information: Portions Copyright [yyyy] [name of copyright owner] 181991Sheppo * 191991Sheppo * CDDL HEADER END 201991Sheppo */ 211991Sheppo 221991Sheppo /* 23*8542SHaik.Aftandilian@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 241991Sheppo * Use is subject to license terms. 251991Sheppo */ 261991Sheppo 271991Sheppo #include <sys/promif_impl.h> 281991Sheppo #include <sys/uadmin.h> 291991Sheppo #include <sys/machsystm.h> 301991Sheppo #include <sys/hypervisor_api.h> 311991Sheppo 321991Sheppo #ifdef _KMDB 331991Sheppo 341991Sheppo extern int kmdb_dpi_get_master_cpuid(void); 351991Sheppo extern void kmdb_dpi_kernpanic(int cpuid); 361991Sheppo extern void prom_reboot(char *bootstr); 371991Sheppo 381991Sheppo #define PIL_DECL(p) 391991Sheppo #define PIL_SET7(p) 401991Sheppo #define PIL_REST(p) 411991Sheppo 421991Sheppo #else 431991Sheppo 441991Sheppo extern int vx_handler(cell_t *argument_array); 45*8542SHaik.Aftandilian@Sun.COM extern void kldc_debug_enter(void); 461991Sheppo 471991Sheppo #define PIL_DECL(p) int p 481991Sheppo #define PIL_SET7(p) (p = spl7()) 491991Sheppo #define PIL_REST(p) (splx(p)) 501991Sheppo 511991Sheppo #endif 521991Sheppo 531991Sheppo #define PROMIF_ISPRINT(c) (((c) >= ' ') && ((c) <= '~')) 541991Sheppo 555974Sjm22469 static int promif_ask_before_reset = 561991Sheppo #ifdef _KMDB 575974Sjm22469 1; 581991Sheppo #else 595974Sjm22469 0; 601991Sheppo #endif 611991Sheppo 621991Sheppo /*ARGSUSED*/ 631991Sheppo int promif_exit_to_mon(void * p)641991Sheppopromif_exit_to_mon(void *p) 651991Sheppo { 661991Sheppo PIL_DECL(pil); 671991Sheppo 681991Sheppo PIL_SET7(pil); 691991Sheppo 701991Sheppo prom_printf("Program terminated\n"); 711991Sheppo 725974Sjm22469 if (promif_ask_before_reset) { 735974Sjm22469 prom_printf("Press any key to reboot."); 745974Sjm22469 (void) prom_getchar(); 755974Sjm22469 } 765974Sjm22469 775974Sjm22469 (void) hv_mach_sir(); 785974Sjm22469 795974Sjm22469 /* should not return */ 805974Sjm22469 ASSERT(0); 811991Sheppo 821991Sheppo PIL_REST(pil); 831991Sheppo 841991Sheppo return (0); 851991Sheppo } 861991Sheppo 875974Sjm22469 /*ARGSUSED*/ 885974Sjm22469 int promif_enter_mon(void * p)895974Sjm22469promif_enter_mon(void *p) 901991Sheppo { 911991Sheppo char cmd; 925974Sjm22469 static char *prompt = "c)ontinue, s)ync, r)eset? "; 935974Sjm22469 PIL_DECL(pil); 945974Sjm22469 955974Sjm22469 PIL_SET7(pil); 965974Sjm22469 975974Sjm22469 #ifndef _KMDB 985974Sjm22469 idle_other_cpus(); 99*8542SHaik.Aftandilian@Sun.COM kldc_debug_enter(); 1001991Sheppo #endif 1011991Sheppo 1021991Sheppo for (;;) { 1031991Sheppo prom_printf("%s", prompt); 1045974Sjm22469 cmd = promif_getchar(); 1051991Sheppo prom_printf("%c\n", cmd); 1061991Sheppo 1071991Sheppo switch (cmd) { 1081991Sheppo 1091991Sheppo case 'r': 1103263Sjm22469 prom_printf("Resetting...\n"); 1113263Sjm22469 1123263Sjm22469 (void) hv_mach_sir(); 1133263Sjm22469 1143263Sjm22469 /* should not return */ 1153263Sjm22469 ASSERT(0); 1161991Sheppo break; 1171991Sheppo 1181991Sheppo case '\r': 1191991Sheppo break; 1201991Sheppo 1211991Sheppo case 's': 1225974Sjm22469 { 1231991Sheppo #ifdef _KMDB 1241991Sheppo kmdb_dpi_kernpanic(kmdb_dpi_get_master_cpuid()); 1251991Sheppo #else 1261991Sheppo cell_t arg = p1275_ptr2cell("sync"); 1275974Sjm22469 1281991Sheppo (void) vx_handler(&arg); 1291991Sheppo #endif 1301991Sheppo } 1315974Sjm22469 1325974Sjm22469 /* should not return */ 1335974Sjm22469 ASSERT(0); 1341991Sheppo break; 1351991Sheppo 1361991Sheppo case 'c': 1375974Sjm22469 #ifndef _KMDB 1385974Sjm22469 resume_other_cpus(); 1395974Sjm22469 #endif 1405974Sjm22469 PIL_REST(pil); 1415974Sjm22469 1425974Sjm22469 return (0); 1431991Sheppo 1441991Sheppo default: 1455974Sjm22469 if (PROMIF_ISPRINT(cmd)) 1465974Sjm22469 prom_printf("invalid option (%c)\n", cmd); 1471991Sheppo break; 1481991Sheppo } 1491991Sheppo } 1501991Sheppo 1511991Sheppo _NOTE(NOTREACHED) 1521991Sheppo } 153