8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / scadm / sparc / mpxu / common / wrappers.c
blob595c303c701cd7cff0f45565c171634c0f172fa9
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * wrappers.c: utility for scadm command processing functions
33 #include <libintl.h>
34 #include <stdio.h>
35 #include <errno.h>
36 #include <time.h> /* required by rsc.h */
38 #include "librsc.h"
39 #include "adm.h"
42 void
43 ADM_Start()
45 if (rscp_start() != 0) {
47 (void) fprintf(stderr, "\n%s\n\n",
48 gettext("scadm: SC firmware not responding"));
49 exit(-1);
54 void
55 ADM_Send(rscp_msg_t *msg)
57 int err;
59 err = rscp_send(msg);
61 if (err == ENOTSUP) {
63 (void) fprintf(stderr, "\n%s\n\n",
64 gettext("scadm: command/option not supported"));
65 exit(-1);
67 } else if (err != 0) {
69 (void) fprintf(stderr, "\n%s\n\n",
70 gettext("scadm: unable to send data to SC"));
71 exit(-1);
76 int
77 ADM_Send_ret(rscp_msg_t *msg)
79 return (rscp_send(msg));
83 void
84 ADM_Recv(rscp_msg_t *msg, struct timespec *timeout, int expectType,
85 int expectSize)
87 if (rscp_recv(msg, timeout) != 0) {
88 (void) fprintf(stderr, "\n%s\n\n",
89 gettext("scadm: SC not responding to requests"));
90 exit(-1);
93 if ((msg->type != expectType) || (msg->len < expectSize)) {
94 (void) fprintf(stderr, "\n%s: 0x%08x:0x%08lx\n\n",
95 gettext("scadm: SC returned garbage"),
96 msg->type, msg->len);
97 exit(-1);
103 void
104 ADM_Free(rscp_msg_t *msg)
106 if (rscp_free_msg(msg) != 0) {
107 (void) fprintf(stderr, "\n%s\n\n",
108 gettext("scadm: SC unable to free up memory"));
109 exit(-1);