summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/serengeti/sys/sgsbbc_iosram_priv.h
blob: 0f82aac4eddde34b08327410c4895a9cfd2e1b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_SGSBBC_IOSRAM_PRIV_H
#define	_SYS_SGSBBC_IOSRAM_PRIV_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include  <sys/errno.h>
#include <sys/sgsbbc_priv.h>
#include <sys/sgsbbc_iosram.h>

/*
 * The following keys are in I/O SRAM TOC
 * and  used by the OS and SC-APP
 * These are mapped to the numeric values below
 *
 * NB These must be kept in sync with POST/SC keys.
 */
#define	TOCKEY_DOMSTAT	"DOMSTAT"	/* SBBC_DOMAIN_KEY */
#define	TOCKEY_KEYSWPO	"KEYSWPO"	/* SBBC_KEYSWITCH_KEY */
#define	TOCKEY_TODDATA	"TODDATA"	/* SBBC_TOD_KEY */
#define	TOCKEY_SOLCONS	"SOLCONS"	/* SBBC_CONSOLE_KEY */
#define	TOCKEY_SOLMBOX	"SOLMBOX"	/* SBBC_MAILBOX_KEY */
#define	TOCKEY_SOLSCIR	"SOLSCIR"	/* SBBC_INTR_SC_KEY */
#define	TOCKEY_SCSOLIR	"SCSOLIR"	/* SBBC_SC_INTR_KEY */
#define	TOCKEY_ENVINFO	"ENVINFO"	/* SBBC_ENVCTRL_KEY */
/*
 * Interrupts enabled that SC can send to OS
 * read/only for SC
 */
#define	TOCKEY_SOLSCIE	"SOLSCIE"	/* SBBC_SC_INTR_ENABLED_KEY */
/*
 * Interrupts enabled that OS can send to SC
 * read/only for OS
 */
#define	TOCKEY_SCSOLIE	"SCSOLIE"	/* SBBC_INTR_SC_ENABLED_KEY */
/*
 * CPU/Domain signatures block
 */
#define	TOCKEY_SIGBLCK	"SIGBLCK"	/* SBBC_SIGBLCK_KEY */


/*
 * different sram types
 */
#define	CPU_SRAM		1
#define	LOCAL_IO_SRAM		2
#define	GLOBAL_IO_SRAM		3
#define	WCI_SRAM		4

#define	INVALID_KEY(tunnel, x)  (tunnel->tunnel_keys[(x)].key == 0)

/*
 * Macros used for version checking
 * The SBBC driver will check the major version number in the IOSRAM
 * TOC entry.  If the major version number in the TOC entry is larger
 * than the maximum number Solaris supports, Solaris will panic.
 */
#define	IOSRAM_TOC_VER_SHIFT	0x8	/* top 8 bit for major */
#define	IOSRAM_TOC_VER_MASK	0xff	/* 8-bit for major, 8-bit for minor */

/*
 * IOSRAM/TOC propertes on chosen node
 */
#define	IOSRAM_CHOSEN_PROP	"iosram"
#define	IOSRAM_TOC_PROP		"iosram-toc"

typedef struct tunnel_key {
	int			key;
	caddr_t			base;	/* VA of this tunnel SRAM area */
	int			size;
	ddi_acc_handle_t	reg_handle;
} tunnel_key_t;

typedef struct tunnel {
	tunnel_key_t	tunnel_keys[SBBC_MAX_KEYS];
} tunnel_t;

struct chosen_iosram {
	/*
	 * Global IOSRAM lock
	 */
	kmutex_t	iosram_lock;
	/*
	 * Tunnel lock to synchronize IOSRAM access
	 */
	krwlock_t	tunnel_lock;
	/*
	 * 'chosen' SBBC
	 */
	sbbc_softstate_t *iosram_sbbc;
	sbbc_softstate_t *sgsbbc;	/* cross reference */

	/*
	 * pointer to an array of SBBC_MAX_KEYS tunnel entries
	 */
	tunnel_t	*tunnel;
	/*
	 * interrupt handlers
	 */
	sbbc_intrs_t	intrs[SBBC_MAX_INTRS];
};


extern void	iosram_init(void);
extern void	iosram_fini(void);
extern int	sgsbbc_iosram_is_chosen(sbbc_softstate_t *);

/*
 * tunnel switch related routines
 */
extern int	iosram_tunnel_init(sbbc_softstate_t *);
extern int	sgsbbc_iosram_switchfrom(sbbc_softstate_t *);
extern int	iosram_switch_tunnel(int);

extern struct chosen_iosram *master_iosram;
extern struct sbbc_softstate *sgsbbc_instances;

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_SGSBBC_IOSRAM_PRIV_H */