xref: /titanic_44/usr/src/uts/sun4u/sys/rmc_comm_drvintf.h (revision 8d96d5b3a759119baa5937624b8716c8abb4d572)
17c478bd9Sstevel@tonic-gate /*
2*8d96d5b3Sjroberts  * CDDL HEADER START
3*8d96d5b3Sjroberts  *
4*8d96d5b3Sjroberts  * The contents of this file are subject to the terms of the
5*8d96d5b3Sjroberts  * Common Development and Distribution License (the "License").
6*8d96d5b3Sjroberts  * You may not use this file except in compliance with the License.
7*8d96d5b3Sjroberts  *
8*8d96d5b3Sjroberts  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*8d96d5b3Sjroberts  * or http://www.opensolaris.org/os/licensing.
10*8d96d5b3Sjroberts  * See the License for the specific language governing permissions
11*8d96d5b3Sjroberts  * and limitations under the License.
12*8d96d5b3Sjroberts  *
13*8d96d5b3Sjroberts  * When distributing Covered Code, include this CDDL HEADER in each
14*8d96d5b3Sjroberts  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*8d96d5b3Sjroberts  * If applicable, add the following below this CDDL HEADER, with the
16*8d96d5b3Sjroberts  * fields enclosed by brackets "[]" replaced with your own identifying
17*8d96d5b3Sjroberts  * information: Portions Copyright [yyyy] [name of copyright owner]
18*8d96d5b3Sjroberts  *
19*8d96d5b3Sjroberts  * CDDL HEADER END
20*8d96d5b3Sjroberts  */
21*8d96d5b3Sjroberts 
22*8d96d5b3Sjroberts /*
23*8d96d5b3Sjroberts  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_RMC_COMM_DRVINTF_H
287c478bd9Sstevel@tonic-gate #define	_SYS_RMC_COMM_DRVINTF_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/rmc_comm_hproto.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * this struct is used by client programs to request message services:
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate typedef struct rmc_comm_msg {
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate 	uint8_t	msg_type;	/* message type */
457c478bd9Sstevel@tonic-gate 	int16_t	msg_len;	/* size of the message buffer */
467c478bd9Sstevel@tonic-gate 	int16_t	msg_bytes;	/* number of bytes returned */
477c478bd9Sstevel@tonic-gate 	caddr_t	msg_buf;	/* message buffer */
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate } rmc_comm_msg_t;
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /* list of error codes for RMC comm */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #define	RCNOERR		(0)	/* cmd sent, reply/ACK received */
557c478bd9Sstevel@tonic-gate #define	RCENOSOFTSTATE	(-1)	/* invalid/NULL soft state structure */
567c478bd9Sstevel@tonic-gate #define	RCENODATALINK	(-2)	/* data link down */
577c478bd9Sstevel@tonic-gate #define	RCENOMEM	(-3)	/* no memory */
587c478bd9Sstevel@tonic-gate #define	RCECANTRESEND	(-4)	/* resend failed */
597c478bd9Sstevel@tonic-gate #define	RCEMAXRETRIES	(-5)	/* maximum number of retries exceeded */
607c478bd9Sstevel@tonic-gate #define	RCETIMEOUT	(-6)	/* timeout error */
617c478bd9Sstevel@tonic-gate #define	RCEINVCMD	(-7)	/* invalid data protocol command */
627c478bd9Sstevel@tonic-gate #define	RCEINVARG	(-8)	/* invalid argument(s) */
637c478bd9Sstevel@tonic-gate #define	RCECANTREGINTR	(-9)	/* interrupt handler registration failure */
647c478bd9Sstevel@tonic-gate #define	RCEALREADYREG	(-10)	/* interrupt handler already registered */
657c478bd9Sstevel@tonic-gate #define	RCEREPTOOBIG	(-11)	/* reply message too big */
667c478bd9Sstevel@tonic-gate #define	RCEGENERIC	(-15)	/* generic error */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * possible value for the 'state' variable provided by the driver
707c478bd9Sstevel@tonic-gate  * (registration for an asynchronous message notification -
717c478bd9Sstevel@tonic-gate  * see rmc_comm_reg_intr). The state variable tells whether the driver
727c478bd9Sstevel@tonic-gate  * interrupt handler is currently processing an asynchronous notification or
737c478bd9Sstevel@tonic-gate  * not.
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #define	RMC_COMM_INTR_IDLE	0x01
777c478bd9Sstevel@tonic-gate #define	RMC_COMM_INTR_RUNNING	0x02
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * structure used to store a request (only one per time!) that is delivered
827c478bd9Sstevel@tonic-gate  * later. Some leaf driver (TOD for instance) cannot wait for the completion
837c478bd9Sstevel@tonic-gate  * of the trasmission of a request message so they calls a specific interface
847c478bd9Sstevel@tonic-gate  * (rmc_comm_request_nowait) which stores the request in this structure and
857c478bd9Sstevel@tonic-gate  * signals a thread to deliver the request asynchronously.
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate typedef struct rmc_comm_drvintf_state {
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 	kt_did_t	dreq_tid;
907c478bd9Sstevel@tonic-gate 	kmutex_t	dreq_mutex[1];
917c478bd9Sstevel@tonic-gate 	kcondvar_t	dreq_sig_cv[1];
927c478bd9Sstevel@tonic-gate 	uint8_t		dreq_state;
937c478bd9Sstevel@tonic-gate 	rmc_comm_msg_t	dreq_request;
947c478bd9Sstevel@tonic-gate 	char		dreq_request_buf[ DP_MAX_MSGLEN ];
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate } rmc_comm_drvintf_state_t;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * possible value for dreq_state field
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate enum rmc_comm_dreq_state {
1027c478bd9Sstevel@tonic-gate 	RMC_COMM_DREQ_ST_NOTSTARTED = 0,
1037c478bd9Sstevel@tonic-gate 	RMC_COMM_DREQ_ST_READY,
1047c478bd9Sstevel@tonic-gate 	RMC_COMM_DREQ_ST_WAIT,
1057c478bd9Sstevel@tonic-gate 	RMC_COMM_DREQ_ST_PROCESS,
1067c478bd9Sstevel@tonic-gate 	RMC_COMM_DREQ_ST_EXIT
1077c478bd9Sstevel@tonic-gate };
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * default timeout value for requests sent from the thread
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate #define	RMC_COMM_DREQ_DEFAULT_TIME	10000
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate  * flag which tells if a request has to be sent even if a pending request is
1167c478bd9Sstevel@tonic-gate  * in process. This flag must only be used when trying to send a request in
1177c478bd9Sstevel@tonic-gate  * critical condition (while the system is shutting down for instance and the
1187c478bd9Sstevel@tonic-gate  * CPU signature has to be sent). Otherwise, the request is stored in a
1197c478bd9Sstevel@tonic-gate  * temporary location and delivered by a thread.
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	RMC_COMM_DREQ_URGENT		0x01
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /* function prototypes (interface to the drivers) */
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate int rmc_comm_request_response(rmc_comm_msg_t *, rmc_comm_msg_t *, uint32_t);
1287c478bd9Sstevel@tonic-gate int rmc_comm_request_nowait(rmc_comm_msg_t *, uint8_t);
1297c478bd9Sstevel@tonic-gate int rmc_comm_request_response_bp(rmc_comm_msg_t *, rmc_comm_msg_t *, uint32_t);
1307c478bd9Sstevel@tonic-gate int rmc_comm_reg_intr(uint8_t, rmc_comm_intrfunc_t, rmc_comm_msg_t *, uint_t *,
1317c478bd9Sstevel@tonic-gate 			kmutex_t *);
1327c478bd9Sstevel@tonic-gate int rmc_comm_unreg_intr(uint8_t, rmc_comm_intrfunc_t);
1337c478bd9Sstevel@tonic-gate int rmc_comm_send_srecord_bp(caddr_t, int, rmc_comm_msg_t *, uint32_t);
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1367c478bd9Sstevel@tonic-gate }
1377c478bd9Sstevel@tonic-gate #endif
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #endif	/* _SYS_RMC_COMM_DRVINTF_H */
140