xref: /illumos-gate/usr/src/uts/sun4u/serengeti/sys/sgsbbc_iosram_priv.h (revision d8d810637042c2a73a269f125dee75e8ed1421d1)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SGSBBC_IOSRAM_PRIV_H
28 #define	_SYS_SGSBBC_IOSRAM_PRIV_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include  <sys/errno.h>
38 #include <sys/sgsbbc_priv.h>
39 #include <sys/sgsbbc_iosram.h>
40 
41 /*
42  * The following keys are in I/O SRAM TOC
43  * and  used by the OS and SC-APP
44  * These are mapped to the numeric values below
45  *
46  * NB These must be kept in sync with POST/SC keys.
47  */
48 #define	TOCKEY_DOMSTAT	"DOMSTAT"	/* SBBC_DOMAIN_KEY */
49 #define	TOCKEY_KEYSWPO	"KEYSWPO"	/* SBBC_KEYSWITCH_KEY */
50 #define	TOCKEY_TODDATA	"TODDATA"	/* SBBC_TOD_KEY */
51 #define	TOCKEY_SOLCONS	"SOLCONS"	/* SBBC_CONSOLE_KEY */
52 #define	TOCKEY_SOLMBOX	"SOLMBOX"	/* SBBC_MAILBOX_KEY */
53 #define	TOCKEY_SOLSCIR	"SOLSCIR"	/* SBBC_INTR_SC_KEY */
54 #define	TOCKEY_SCSOLIR	"SCSOLIR"	/* SBBC_SC_INTR_KEY */
55 #define	TOCKEY_ENVINFO	"ENVINFO"	/* SBBC_ENVCTRL_KEY */
56 /*
57  * Interrupts enabled that SC can send to OS
58  * read/only for SC
59  */
60 #define	TOCKEY_SOLSCIE	"SOLSCIE"	/* SBBC_SC_INTR_ENABLED_KEY */
61 /*
62  * Interrupts enabled that OS can send to SC
63  * read/only for OS
64  */
65 #define	TOCKEY_SCSOLIE	"SCSOLIE"	/* SBBC_INTR_SC_ENABLED_KEY */
66 /*
67  * CPU/Domain signatures block
68  */
69 #define	TOCKEY_SIGBLCK	"SIGBLCK"	/* SBBC_SIGBLCK_KEY */
70 
71 
72 /*
73  * different sram types
74  */
75 #define	CPU_SRAM		1
76 #define	LOCAL_IO_SRAM		2
77 #define	GLOBAL_IO_SRAM		3
78 #define	WCI_SRAM		4
79 
80 #define	INVALID_KEY(tunnel, x)  (tunnel->tunnel_keys[(x)].key == 0)
81 
82 /*
83  * Macros used for version checking
84  * The SBBC driver will check the major version number in the IOSRAM
85  * TOC entry.  If the major version number in the TOC entry is larger
86  * than the maximum number Solaris supports, Solaris will panic.
87  */
88 #define	IOSRAM_TOC_VER_SHIFT	0x8	/* top 8 bit for major */
89 #define	IOSRAM_TOC_VER_MASK	0xff	/* 8-bit for major, 8-bit for minor */
90 
91 /*
92  * IOSRAM/TOC propertes on chosen node
93  */
94 #define	IOSRAM_CHOSEN_PROP	"iosram"
95 #define	IOSRAM_TOC_PROP		"iosram-toc"
96 
97 typedef struct tunnel_key {
98 	int			key;
99 	caddr_t			base;	/* VA of this tunnel SRAM area */
100 	int			size;
101 	ddi_acc_handle_t	reg_handle;
102 } tunnel_key_t;
103 
104 typedef struct tunnel {
105 	tunnel_key_t	tunnel_keys[SBBC_MAX_KEYS];
106 } tunnel_t;
107 
108 struct chosen_iosram {
109 	/*
110 	 * Global IOSRAM lock
111 	 */
112 	kmutex_t	iosram_lock;
113 	/*
114 	 * Tunnel lock to synchronize IOSRAM access
115 	 */
116 	krwlock_t	tunnel_lock;
117 	/*
118 	 * 'chosen' SBBC
119 	 */
120 	sbbc_softstate_t *iosram_sbbc;
121 	sbbc_softstate_t *sgsbbc;	/* cross reference */
122 
123 	/*
124 	 * pointer to an array of SBBC_MAX_KEYS tunnel entries
125 	 */
126 	tunnel_t	*tunnel;
127 	/*
128 	 * interrupt handlers
129 	 */
130 	sbbc_intrs_t	intrs[SBBC_MAX_INTRS];
131 };
132 
133 
134 extern void	iosram_init(void);
135 extern void	iosram_fini(void);
136 extern int	sgsbbc_iosram_is_chosen(sbbc_softstate_t *);
137 
138 /*
139  * tunnel switch related routines
140  */
141 extern int	iosram_tunnel_init(sbbc_softstate_t *);
142 extern int	sgsbbc_iosram_switchfrom(sbbc_softstate_t *);
143 extern int	iosram_switch_tunnel(int);
144 
145 extern struct chosen_iosram *master_iosram;
146 extern struct sbbc_softstate *sgsbbc_instances;
147 
148 #ifdef	__cplusplus
149 }
150 #endif
151 
152 #endif	/* _SYS_SGSBBC_IOSRAM_PRIV_H */
153