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