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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef __ADM_H__
28 #define	__ADM_H__
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * adm.h: defines and function prototypes for scadm
36  */
37 
38 #include <stdio.h>
39 #include <time.h>
40 
41 #include "librsc.h"
42 
43 
44 /* DEFINES */
45 #define	ADM_TIMEOUT		2  /* RX timeout for normal messages */
46 #define	ADM_SEPROM_TIMEOUT	10 /* timeout for messages requiring serial */
47 				    /* eprom update */
48 #define	ADM_BOOT_INIT_TIMEOUT	1  /* RX timeout for BOOT_INIT message */
49 #define	ADM_BOOT_LOAD_TIMEOUT	10 /* RX timeout for BOOT s-record message */
50 #define	ADM_BOOT_RETRY		5  /* Number of times to retry BOOT messages */
51 #define	ADM_LINE_SIZE		1024 /* Max s-record line size */
52 #define	ADM_BP_BUFF_SIZE	20
53 
54 /*
55  * By default, how much of an extended log will be displayed (for character-
56  * based logs.)
57  */
58 #define	ADM_DEFAULT_LOG_LENGTH	8192
59 
60 /* Default number of events we ask ALOM for (for event-based logs.) */
61 #define	DEFAULT_NUM_EVENTS 100
62 
63 
64 /* Return values for ADM_Valid_srecord() */
65 #define	SREC_OK			0
66 #define	SREC_ERR_LINE_TOO_BIG	-1
67 #define	SREC_ERR_LINE_TOO_SMALL	-2
68 #define	SREC_ERR_BAD_HEADER	-3
69 #define	SREC_ERR_WRONG_LENGTH	-4
70 #define	SREC_ERR_BAD_CRC	-5
71 
72 
73 /* SPEC'S */
74 void  ADM_Init();
75 void  ADM_Cleanup();
76 void  ADM_Exit(int errorCode);
77 
78 void  ADM_Process_command(int argc, char *argv[]);
79 void  ADM_Process_help();
80 void  ADM_Process_modem_setup();
81 void  ADM_Process_status();
82 void  ADM_Process_send_event(int argc, char *argv[]);
83 void  ADM_Process_date(int argc, char *argv[]);
84 void  ADM_Process_set(int argc, char *argv[]);
85 void  ADM_Process_show(int argc, char *argv[]);
86 void  ADM_Process_reset(int argc, char *argv[]);
87 void  ADM_Process_download(int argc, char *argv[]);
88 void  ADM_Process_useradd(int argc, char *argv[]);
89 void  ADM_Process_userdel(int argc, char *argv[]);
90 void  ADM_Process_usershow(int argc, char *argv[]);
91 void  ADM_Process_userpassword(int argc, char *argv[]);
92 void  ADM_Process_userperm(int argc, char *argv[]);
93 void  ADM_Process_show_network();
94 void  ADM_Process_event_log(int all);
95 void  ADM_Process_console_log(int all);
96 void  ADM_Process_fru_log(int all);
97 
98 void  ADM_Usage();
99 void  ADM_Callback(bp_msg_t *Message);
100 int   ADM_Valid_srecord(FILE  *FilePtr);
101 int   ADM_Send_file(FILE  *FilePtr);
102 void  ADM_Display_download_error(int cmd, int dat1); /* in send_file.c */
103 
104 /* rscp_register_bpmsg_cb() must be called before using */
105 /* rscp_send_bpmsg() or ADM_Boot_Recv() */
106 int  ADM_Boot_recv(bp_msg_t *MessagePtr, struct timespec *Timeout);
107 
108 
109 /* Wrappers for rscp routines */
110 void ADM_Start();
111 void ADM_Send(rscp_msg_t *msg);
112 int ADM_Send_ret(rscp_msg_t *msg);
113 void ADM_Recv(rscp_msg_t *msg, struct timespec *timeout, int expectType,
114     int expectSize);
115 void ADM_Free(rscp_msg_t  *msg);
116 
117 #ifdef	__cplusplus
118 }
119 #endif
120 
121 #endif /* __ADM_H__ */
122