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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * to support the scadm rscreset option (reset the service processor)
29  */
30 
31 #include <libintl.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <time.h>  /* required by rsc.h */
35 
36 #include "librsc.h"
37 #include "adm.h"
38 
39 
40 static void usage();
41 
42 
43 void
ADM_Process_reset(int argc,char * argv[])44 ADM_Process_reset(int argc, char *argv[])
45 {
46 	rscp_msg_t	Message;
47 
48 	if ((argc != 2) && (argc != 3)) {
49 		usage();
50 		exit(-1);
51 	}
52 	if (argc == 3) {
53 		if (strcasecmp(argv[2], "-s") != 0) {
54 			usage();
55 			exit(-1);
56 		}
57 	}
58 
59 	/* If hard reset, reset rsc */
60 	if (argc == 2) {
61 		if (rsc_nmi() != 0) {
62 			(void) fprintf(stderr, "\n%s\n\n",
63 			    gettext("scadm: Unable to reset SC hardware"));
64 			exit(-1);
65 		}
66 	} else {
67 		/* Soft Reset */
68 		ADM_Start();
69 		Message.type = DP_RESET_RSC;
70 		Message.len  = 0;
71 		Message.data = 0x0;
72 		ADM_Send(&Message);
73 	}
74 }
75 
76 
77 static void
usage()78 usage()
79 {
80 	(void) fprintf(stderr,
81 	    "\n%s\n\n", gettext("USAGE: scadm resetrsc [-s]"));
82 }
83