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