xref: /titanic_51/usr/src/uts/sun4u/sys/rmc_comm_drvintf.h (revision 19449258028e6813f0b7a606b554b2fa37a390ec)
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 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_RMC_COMM_DRVINTF_H
28 #define	_SYS_RMC_COMM_DRVINTF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 
33 #include <sys/rmc_comm_hproto.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * this struct is used by client programs to request message services:
41  */
42 typedef struct rmc_comm_msg {
43 
44 	uint8_t	msg_type;	/* message type */
45 	int16_t	msg_len;	/* size of the message buffer */
46 	int16_t	msg_bytes;	/* number of bytes returned */
47 	caddr_t	msg_buf;	/* message buffer */
48 
49 } rmc_comm_msg_t;
50 
51 
52 /* list of error codes for RMC comm */
53 
54 #define	RCNOERR		(0)	/* cmd sent, reply/ACK received */
55 #define	RCENOSOFTSTATE	(-1)	/* invalid/NULL soft state structure */
56 #define	RCENODATALINK	(-2)	/* data link down */
57 #define	RCENOMEM	(-3)	/* no memory */
58 #define	RCECANTRESEND	(-4)	/* resend failed */
59 #define	RCEMAXRETRIES	(-5)	/* maximum number of retries exceeded */
60 #define	RCETIMEOUT	(-6)	/* timeout error */
61 #define	RCEINVCMD	(-7)	/* invalid data protocol command */
62 #define	RCEINVARG	(-8)	/* invalid argument(s) */
63 #define	RCECANTREGINTR	(-9)	/* interrupt handler registration failure */
64 #define	RCEALREADYREG	(-10)	/* interrupt handler already registered */
65 #define	RCEREPTOOBIG	(-11)	/* reply message too big */
66 #define	RCEGENERIC	(-15)	/* generic error */
67 
68 /*
69  * possible value for the 'state' variable provided by the driver
70  * (registration for an asynchronous message notification -
71  * see rmc_comm_reg_intr). The state variable tells whether the driver
72  * interrupt handler is currently processing an asynchronous notification or
73  * not.
74  */
75 
76 #define	RMC_COMM_INTR_IDLE	0x01
77 #define	RMC_COMM_INTR_RUNNING	0x02
78 
79 
80 /*
81  * structure used to store a request (only one per time!) that is delivered
82  * later. Some leaf driver (TOD for instance) cannot wait for the completion
83  * of the trasmission of a request message so they calls a specific interface
84  * (rmc_comm_request_nowait) which stores the request in this structure and
85  * signals a thread to deliver the request asynchronously.
86  */
87 typedef struct rmc_comm_drvintf_state {
88 
89 	kt_did_t	dreq_tid;
90 	kmutex_t	dreq_mutex[1];
91 	kcondvar_t	dreq_sig_cv[1];
92 	uint8_t		dreq_state;
93 	rmc_comm_msg_t	dreq_request;
94 	char		dreq_request_buf[ DP_MAX_MSGLEN ];
95 
96 } rmc_comm_drvintf_state_t;
97 
98 /*
99  * possible value for dreq_state field
100  */
101 enum rmc_comm_dreq_state {
102 	RMC_COMM_DREQ_ST_NOTSTARTED = 0,
103 	RMC_COMM_DREQ_ST_READY,
104 	RMC_COMM_DREQ_ST_WAIT,
105 	RMC_COMM_DREQ_ST_PROCESS,
106 	RMC_COMM_DREQ_ST_EXIT
107 };
108 
109 /*
110  * default timeout value for requests sent from the thread
111  */
112 #define	RMC_COMM_DREQ_DEFAULT_TIME	10000
113 
114 /*
115  * flag which tells if a request has to be sent even if a pending request is
116  * in process. This flag must only be used when trying to send a request in
117  * critical condition (while the system is shutting down for instance and the
118  * CPU signature has to be sent). Otherwise, the request is stored in a
119  * temporary location and delivered by a thread.
120  */
121 
122 #define	RMC_COMM_DREQ_URGENT		0x01
123 
124 
125 /* function prototypes (interface to the drivers) */
126 
127 int rmc_comm_request_response(rmc_comm_msg_t *, rmc_comm_msg_t *, uint32_t);
128 int rmc_comm_request_nowait(rmc_comm_msg_t *, uint8_t);
129 int rmc_comm_request_response_bp(rmc_comm_msg_t *, rmc_comm_msg_t *, uint32_t);
130 int rmc_comm_reg_intr(uint8_t, rmc_comm_intrfunc_t, rmc_comm_msg_t *, uint_t *,
131 			kmutex_t *);
132 int rmc_comm_unreg_intr(uint8_t, rmc_comm_intrfunc_t);
133 int rmc_comm_send_srecord_bp(caddr_t, int, rmc_comm_msg_t *, uint32_t);
134 
135 #ifdef	__cplusplus
136 }
137 #endif
138 
139 #endif	/* _SYS_RMC_COMM_DRVINTF_H */
140