xref: /titanic_50/usr/src/uts/sun4u/starcat/sys/iosramio.h (revision 0bb073995ac5a95bd35f2dd790df1ea3d8c2d507)
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 2000 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_IOSRAMIO_H
28 #define	_SYS_IOSRAMIO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 /*
38  * data_valid flag values
39  */
40 #define	IOSRAM_DATA_INVALID	0
41 #define	IOSRAM_DATA_VALID	1
42 
43 /*
44  * int_pending flag values
45  */
46 #define	IOSRAM_INT_NONE		0
47 #define	IOSRAM_INT_TO_SSC	1
48 #define	IOSRAM_INT_TO_DOM	2
49 
50 /*
51  * IOSRAM control commands, for use in iosram_ctrl().
52  */
53 #define	IOSRAM_CMD_CHUNKLEN			1
54 
55 /*
56  * IOSRAM header control commands, for use in iosram_hdr_ctrl _only_ by the
57  * Mailbox Protocol implementation
58  */
59 #define	IOSRAM_HDRCMD_GET_SMS_MBOX_VER		1
60 #define	IOSRAM_HDRCMD_SET_OS_MBOX_VER		2
61 #define	IOSRAM_HDRCMD_REG_CALLBACK		3
62 
63 /*
64  * Extern prototypes for kernel drivers/modules
65  */
66 extern int iosram_rd(uint32_t key, uint32_t off, uint32_t len, caddr_t dptr);
67 extern int iosram_wr(uint32_t key, uint32_t off, uint32_t len, caddr_t dptr);
68 extern int iosram_force_write(uint32_t key, uint32_t off, uint32_t len,
69 	caddr_t dptr);
70 extern int iosram_get_flag(uint32_t key, uint8_t *data_valid,
71 	uint8_t *int_pending);
72 extern int iosram_set_flag(uint32_t key, uint8_t data_valid,
73 	uint8_t int_pending);
74 extern int iosram_send_intr();
75 extern int iosram_register(uint32_t key, void (*handler)(), void *arg);
76 extern int iosram_unregister(uint32_t key);
77 extern int iosram_ctrl(uint32_t key, uint32_t cmd, void *arg);
78 
79 /*
80  * This function is only intended to be called by DR.
81  */
82 extern int iosram_switchfrom(int instance);
83 
84 /*
85  * The following functions are only to be used by the Mailbox Protocol
86  * implementation.
87  */
88 extern int iosram_sema_acquire(uint32_t *);
89 extern int iosram_sema_release(void);
90 extern int iosram_hdr_ctrl(uint32_t cmd, void *arg);
91 
92 
93 #if defined(DEBUG)
94 
95 /*
96  * ioctls for testing purposes only
97  */
98 
99 #define	IOSRAM_IOC			('i' << 8)
100 
101 #define	IOSRAM_RD		(int)(IOSRAM_IOC|1)
102 #define	IOSRAM_WR		(int)(IOSRAM_IOC|2)
103 #define	IOSRAM_GET_FLAG		(int)(IOSRAM_IOC|3)
104 #define	IOSRAM_SET_FLAG		(int)(IOSRAM_IOC|4)
105 #define	IOSRAM_TOC		(int)(IOSRAM_IOC|5)
106 #define	IOSRAM_SEND_INTR	(int)(IOSRAM_IOC|6)
107 #define	IOSRAM_REG_CBACK	(int)(IOSRAM_IOC|7)
108 #define	IOSRAM_UNREG_CBACK	(int)(IOSRAM_IOC|8)
109 #define	IOSRAM_PRINT_CBACK	(int)(IOSRAM_IOC|9)
110 #define	IOSRAM_PRINT_STATE	(int)(IOSRAM_IOC|10)
111 #define	IOSRAM_PRINT_LOG	(int)(IOSRAM_IOC|11)
112 #define	IOSRAM_PRINT_FLAGS	(int)(IOSRAM_IOC|12)
113 #define	IOSRAM_TUNNEL_SWITCH	(int)(IOSRAM_IOC|13)
114 #define	IOSRAM_PRINT_STATS	(int)(IOSRAM_IOC|14)
115 #define	IOSRAM_SEMA_ACQUIRE	(int)(IOSRAM_IOC|15)
116 #define	IOSRAM_SEMA_RELEASE	(int)(IOSRAM_IOC|16)
117 
118 
119 /*
120  * struct iosram_io:
121  *	Used for testing purposes to invoke IOSRAM internal
122  *	interface from user level via ioctl() interface.
123  */
124 typedef struct iosram_io {
125 	uint32_t cmd;		/* read or write */
126 	uint32_t key;		/* IOSRAM chunk key */
127 	uint32_t off;		/* offset within IOSRAM chunk */
128 	uint32_t len;		/* size of read or write */
129 	uint32_t bufp;		/* buffer pointer */
130 	uint32_t retval;	/* provided by driver */
131 	uint32_t data_valid;	/* flag being get/set */
132 	uint32_t int_pending;	/* flag being get/set */
133 } iosram_io_t;
134 
135 #endif /* DEBUG */
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_IOSRAMIO_H */
142