xref: /titanic_41/usr/src/cmd/scadm/sparc/mpxu/common/reset.c (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * to support the scadm rscreset option (reset the service processor)
31  */
32 
33 #include <libintl.h>
34 #include <stdio.h>
35 #include <string.h>
36 #include <time.h>  /* required by rsc.h */
37 
38 #include "librsc.h"
39 #include "adm.h"
40 
41 
42 static void usage();
43 
44 
45 void
46 ADM_Process_reset(int argc, char *argv[])
47 {
48 	rscp_msg_t	Message;
49 
50 	if ((argc != 2) && (argc != 3)) {
51 		usage();
52 		exit(-1);
53 	}
54 	if (argc == 3) {
55 		if (strcasecmp(argv[2], "-s") != 0) {
56 			usage();
57 			exit(-1);
58 		}
59 	}
60 
61 	/* If hard reset, reset rsc */
62 	if (argc == 2) {
63 		if (rsc_nmi() != 0) {
64 			(void) fprintf(stderr, "\n%s\n\n",
65 			    gettext("scadm: Unable to reset SC hardware"));
66 			exit(-1);
67 		}
68 	} else {
69 		/* Soft Reset */
70 		ADM_Start();
71 		Message.type = DP_RESET_RSC;
72 		Message.len  = 0;
73 		Message.data = 0x0;
74 		ADM_Send(&Message);
75 	}
76 }
77 
78 
79 static void
80 usage()
81 {
82 	(void) fprintf(stderr,
83 	    "\n%s\n\n", gettext("USAGE: scadm resetrsc [-s]"));
84 }
85