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-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_LIBRSC_H
28 #define	_LIBRSC_H
29 
30 #include <sys/rmc_comm_lproto.h>
31 #include <sys/rmc_comm_hproto.h>
32 #include <sys/rmc_comm_dp_boot.h>
33 #include <sys/rmcadm.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * The structure used to pass messages into and out of this layer.
41  */
42 typedef struct rscp_msg {
43 	rsci8   type;
44 	rsci32  len;
45 	void   *data;
46 	void   *private;
47 } rscp_msg_t;
48 
49 typedef void rscp_bpmsg_cb_t(bp_msg_t *msg);
50 
51 #define	RSC_RMCADM_DRV		"/devices/pseudo/rmcadm@0:rmcadm"
52 
53 #define	RSC_MAX_RX_BUFFER	DP_MAX_MSGLEN
54 
55 
56 /*
57  * this table is used to match request/response in order to provide
58  * backward compatibility to obsolete functions: rscp_send(), rscp_recv(),
59  *
60  * in the old way, send and receive were decoupled: applications sent a
61  * request (rscp_send) and waited for a reply (rscp_recv) using two different
62  * calls.
63  * As the ioctl to the communication driver is a single call, send and receive
64  * cannot be decoupled. So, when the rscp_send is called, this table will tell
65  * which reply is expected and in what time. The reply is then stored in a
66  * temporary buffer. When the rscp_recv is called, it will return the
67  * content of the temporary buffer (if a reply was received) or an error
68  */
69 typedef struct req_resp_table {
70 
71 	uint8_t		req_type;
72 	uint8_t		resp_type;
73 	uint16_t	resp_size;
74 	uint_t		timeout;
75 
76 } req_resp_table_t;
77 
78 
79 /* timeout value (millisecs) for request/response sessions */
80 
81 #define	RR_TIMEOUT		10000
82 #define	RR_SEPROM_TIMEOUT	10000
83 
84 #define	RR_BOOT_INIT_TIMEOUT	1000
85 #define	RR_BOOT_LOAD_TIMEOUT	10000
86 #define	RR_BOOT_RESET_TIMEOUT	0
87 #define	RR_BP_TIMEOUT		1000
88 
89 
90 /* function prototypes */
91 
92 int rscp_init(void);
93 int rscp_send_recv(rscp_msg_t *, rscp_msg_t *, struct timespec *);
94 int rsc_nmi(void);
95 
96 
97 /* function prototypes for firmware download */
98 
99 int rscp_register_bpmsg_cb(rscp_bpmsg_cb_t *);
100 int rscp_unregister_bpmsg_cb(rscp_bpmsg_cb_t *);
101 void rscp_send_bpmsg(bp_msg_t *);
102 int rsc_raw_write(char *, int);
103 
104 
105 /* prototypes of obsolete functions */
106 
107 int rscp_send(rscp_msg_t *);
108 int rscp_recv(rscp_msg_t *, struct timespec *);
109 int rscp_start(void);
110 int rscp_free_msg(rscp_msg_t *);
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif /* _LIBRSC_H */
117