xref: /titanic_52/usr/src/uts/sun4u/sys/smc_if.h (revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_SMC_IF_H
28 #define	_SYS_SMC_IF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	_SCIOC	('s' << 8)
37 
38 /*
39  * SMC Driver IOCTL
40  */
41 #define	SCIOC_MSG_SPEC		(_SCIOC | 0x04)
42 #define	SCIOC_RESERVE_SEQN	(_SCIOC | 0x05)
43 #define	SCIOC_FREE_SEQN		(_SCIOC | 0x06)
44 #define	SCIOC_SEND_SYNC_CMD	(_SCIOC | 0x07)
45 
46 /*
47  * IOCTLs to facilitate debugging
48  */
49 #define	SCIOC_ECHO_ON_REQ	(_SCIOC | 0x08)
50 #define	SCIOC_ECHO_OFF_REQ	(_SCIOC | 0x09)
51 
52 /*
53  * A response message can be sent from any application
54  * to simulate a condition of watchdog expiry or receiving
55  * async messages
56  */
57 #define	SCIOC_ASYNC_SIM		(_SCIOC | 0x0A)
58 
59 #define	SC_SUCCESS	0
60 #define	SC_FAILURE	1
61 
62 /*
63  * structure definitions
64  */
65 typedef struct {
66 	uint8_t	msg_id;
67 	uint8_t	cmd;
68 	uint8_t	len;
69 } sc_reqhdr_t;
70 
71 typedef struct {
72 	uint8_t	msg_id;
73 	uint8_t	cmd;		/* Will be 0 is non-SMC response, e.g. wdog */
74 	uint8_t	len;		/* Length of message, including header */
75 	uint8_t	cc;			/* if non-SMC, contains MSG type */
76 } sc_rsphdr_t;
77 
78 #define	SC_SEND_HEADER	(sizeof (sc_reqhdr_t))
79 #define	SC_RECV_HEADER	(sizeof (sc_rsphdr_t))
80 
81 #define	SC_MSG_MAX_SIZE	0x3E
82 #define	SC_SEND_DSIZE	(SC_MSG_MAX_SIZE - SC_SEND_HEADER)
83 #define	SC_RECV_DSIZE	(SC_MSG_MAX_SIZE - SC_RECV_HEADER)
84 
85 #define	SMC_CMD_FAILED	-1
86 
87 typedef enum {
88 	SC_ATTR_SHARED,
89 	SC_ATTR_EXCLUSIVE,
90 	SC_ATTR_CLEAR,
91 	SC_ATTR_CLEARALL
92 } sc_cmd_attr_t;
93 
94 #define	MAX_CMDS	16
95 
96 typedef struct {
97 	uint8_t attribute;
98 	uint8_t args[MAX_CMDS];
99 } sc_cmdspec_t;
100 
101 #define	SC_CMDSPEC_ATTR(CMDSPEC)	((CMDSPEC).attribute)
102 #define	SC_CMDSPEC_ARGS(CMDSPEC)	((CMDSPEC).args)
103 
104 /*
105  * Entire SMC Request Message sent down-stream
106  */
107 typedef struct {
108 	sc_reqhdr_t hdr;
109 	uchar_t		data[SC_SEND_DSIZE];
110 } sc_reqmsg_t;
111 
112 /*
113  * Entire SMC Response Message forwarded up-stream
114  */
115 typedef struct {
116 	sc_rsphdr_t 	hdr;
117 	uchar_t			data[SC_RECV_DSIZE];
118 } sc_rspmsg_t;
119 
120 #define	SC_MSG_HDR(msg)		((msg)->hdr)
121 
122 #define	SC_SEND_DLENGTH(msg)	(SC_MSG_HDR(msg).len)
123 #define	SC_RECV_DLENGTH(msg)	(SC_MSG_HDR(msg).len)
124 
125 #define	SC_MSG_ID(msg)		(SC_MSG_HDR(msg).msg_id)
126 #define	SC_MSG_CMD(msg)		(SC_MSG_HDR(msg).cmd)
127 #define	SC_MSG_LEN(msg)		(SC_MSG_HDR(msg).len)
128 #define	SC_MSG_CC(msg)		(SC_MSG_HDR(msg).cc)
129 #define	SC_MSG_DATA(msg)	((msg)->data)
130 
131 /*
132  * IPMB sequence number request structure. Application can
133  * reserve a block of sequence numbers for communicating
134  * with each destination
135  */
136 #define	SC_SEQ_SZ	16
137 typedef struct {
138 	uint8_t	d_addr;	/* Destination micro-controller addr */
139 	int8_t	n_seqn;	/* Number of seq# requested, max 16, -1 => free all */
140 	uint8_t	seq_numbers[SC_SEQ_SZ];	/* Placeholder for seq# */
141 } sc_seqdesc_t;
142 
143 #define	SC_SEQN_DADDR(SEQDESC)		((SEQDESC).d_addr)
144 #define	SC_SEQN_COUNT(SEQDESC)		((SEQDESC).n_seqn)
145 #define	SC_SEQN_NUMBERS(SEQDESC)	((SEQDESC).seq_numbers)
146 
147 #ifdef	__cplusplus
148 }
149 #endif
150 
151 #endif	/* _SYS_SMC_IF_H */
152