summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/serengeti/sys/sbdp_priv.h
blob: d9fc5de892b6525be4676f113db6e3101bba363b (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
 * 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 _SBDP_PRIV_H
#define	_SBDP_PRIV_H

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

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/sbd.h>
#include <sys/sbdp_mbox.h>
#include <sys/conf.h>
#include <sys/ddi_impldefs.h>
#include <sys/serengeti.h>

#ifdef DEBUG
#define	SBDPDBG_STATE	0x00000001
#define	SBDPDBG_QR	0x00000002
#define	SBDPDBG_CPU	0x00000004
#define	SBDPDBG_MEM	0x00000008
#define	SBDPDBG_IO	0x00000010
#define	SBDPDBG_MBOX	0x00000020
#define	SBDPDBG_ERR	0x00000040
#define	SBDPDBG_MISC	0x00000080
#define	SBDPDBG_FUNC	0x00000100

extern uint_t sbdp_debug;

#define	SBDP_DBG_ALL	if (sbdp_debug)				prom_printf
#define	SBDP_DBG_STATE	if (sbdp_debug & SBDPDBG_STATE)		prom_printf
#define	SBDP_DBG_QR	if (sbdp_debug & SBDPDBG_QR)		prom_printf
#define	SBDP_DBG_CPU	if (sbdp_debug & SBDPDBG_CPU)		prom_printf
#define	SBDP_DBG_MEM	if (sbdp_debug & SBDPDBG_MEM)		prom_printf
#define	SBDP_DBG_IO	if (sbdp_debug & SBDPDBG_IO)		prom_printf
#define	SBDP_DBG_MBOX	if (sbdp_debug & SBDPDBG_MBOX)		prom_printf
#define	SBDP_DBG_ERR	if (sbdp_debug & SBDPDBG_ERR)		prom_printf
#define	SBDP_DBG_MISC	if (sbdp_debug & SBDPDBG_MISC)		prom_printf
#define	SBDP_DBG_FUNC	if (sbdp_debug & SBDPDBG_FUNC)		prom_printf

#else /* DEBUG */

#define	SBDP_DBG_ALL
#define	SBDP_DBG_STATE
#define	SBDP_DBG_QR
#define	SBDP_DBG_CPU
#define	SBDP_DBG_MEM
#define	SBDP_DBG_IO
#define	SBDP_DBG_MBOX
#define	SBDP_DBG_ERR
#define	SBDP_DBG_MISC
#define	SBDP_DBG_FUNC
#endif /* DEBUG */

#define	PORTID_BAD	-1
#define	OBP_PORTID	"portid"
#define	SBDP_MAX_BOARDS  plat_max_boards()
#define	SBDP_MAX_MEM_NODES_PER_BOARD	4
#define	SBDP_MAX_NODES	32
#define	SBDP_MAX_WNODES	16

/*
 * CPU present macros
 */
#define	SBDP_SET_CPU_PRESENT(bdp, unit)\
			((bdp)->cpus_present |= (1 << (unit)))

#define	SBDP_IS_CPU_PRESENT(bdp, unit)\
			(((bdp)->cpus_present & (1 << (unit))) != 0)

/*
 * CPU reset macros
 */
#define	SBDP_SET_CPU_IN_RESET(bdp, unit)\
			((bdp)->cpus_in_reset |= (1 << (unit)))
#define	SBDP_UNSET_CPU_IN_RESET(bdp, unit)\
			((bdp)->cpus_in_reset &= ~(1 << (unit)))
#define	SBDP_IS_CPU_IN_RESET(bdp, unit)\
			(((bdp)->cpus_in_reset & (1 << (unit))) != 0)
#define	SBDP_SET_ALL_CPUS_IN_RESET(bdp)\
			((bdp)->cpus_in_reset |= 0xf)
#define	SBDP_UNSET_ALL_CPUS_IN_RESET(bdp)\
			((bdp)->cpus_in_reset = 0x0)
#define	SBDP_ALL_CPUS	-1

/*
 * These definitions come from the SC. Should the SC change them
 * then we need to changed them
 */
#define	SBDP_DIAG_OFF		0x00
#define	SBDP_DIAG_INIT		0x07
#define	SBDP_DIAG_QUICK		0x10
#define	SBDP_DIAG_MIN		0x20
#define	SBDP_DIAG_DEFAULT	0x40
#define	SBDP_DIAG_MEM1		0x60
#define	SBDP_DIAG_MEM2		0x7f
#define	SBDP_DIAG_NVCI		0xffff	/* Use stored value in nvci */

int		*slices;

#define	SBDP_INIT_PLATOPTS	(uint_t)-1
#define	SBDP_PLATFORM_OPTS(s_platopts)  ((s_platopts) = SBDP_INIT_PLATOPTS, \
		SBD_SET_PLATOPTS(SBD_CMD_TEST, (s_platopts)), \
		SBD_SET_PLATOPTS(SBD_CMD_PASSTHRU, (s_platopts)))

typedef struct sbdp_bank {
	int			id;
	ushort_t		valid;
	ushort_t		uk;
	uint_t			um;
	uchar_t			lk;
	uchar_t			lm;
	struct sbdp_bank	*bd_next;	/* in the board */
	struct sbdp_bank	*seg_next;	/* in the segment */
} sbdp_bank_t;

typedef struct sbdp_segs {
	int			id;
	int			intlv;	/* interleave for this segment */
	uint64_t		base;	/* base address for this segment */
	uint64_t		size;	/* size of this segment */
	int			nbanks;	/* number of banks in this segment */
	sbdp_bank_t		*banks;	/* pointer to the banks of this seg */
	struct sbdp_segs	*next;
} sbdp_seg_t;

typedef struct {
	int		bd;
	int		wnode;
	uint64_t	bpa;	/* base physical addr for this board */
	int		nnum;	/* number of nodes */
	struct memlist	*ml;	/* memlist for this board */
	pnode_t		nodes[SBDP_MAX_MEM_NODES_PER_BOARD];
	kmutex_t	bd_mutex; /* mutex for this board */
	show_board_t	*bd_sc;	/* info obtained from the SC */
	int		valid_cp; /* Is this a valid copy of show_board */
	sbdp_bank_t	*banks;	/* Banks for this board */
	int		cpus_in_reset;
	int		cpus_present;
} sbdp_bd_t;

typedef struct sbdp_wnode {
	int			wnode;	/* wildcat node */
	int			nbds;	/* number of bds for this node */
	sbdp_bd_t		*bds;	/* pointer to the list of bds */
	struct sbdp_wnode	*next;	/* ptr to nex wnode */
	struct sbdp_wnode	*prev;	/* ptr to prev node */
} sbdp_wnode_t;

typedef struct {
	uint_t  regspec_addr_hi;
	uint_t  regspec_addr_lo;
	uint_t  regspec_size_hi;
	uint_t  regspec_size_lo;
} regspace_t;

/*
 * Suspend states used internally by sbdp_suspend and
 * sbdp_resume
 */
typedef enum sbd_suspend_state {
	SBDP_SRSTATE_BEGIN = 0,
	SBDP_SRSTATE_USER,
	SBDP_SRSTATE_DRIVER,
	SBDP_SRSTATE_FULL
} suspend_state_t;

/*
 * specific suspend/resume interface handle
 */
typedef struct {
	sbd_error_t		sep;
	dev_info_t		*sr_failed_dip;
	suspend_state_t		sr_suspend_state;
	uint_t			sr_flags;
	uint_t			sh_ndi;
} sbdp_sr_handle_t;

typedef struct sbdp_shutdown {
	uint64_t	estack;
	uint64_t	flushaddr;
	uint32_t	size;
	uint32_t	linesize;
	uint64_t	physaddr;
} sbdp_shutdown_t;

extern int plat_max_boards();

typedef struct {
	int		node;		/* wildcat node */
	int		board;
	pnode_t		nodes[SBDP_MAX_NODES];
	int		num_of_nodes;
	int		flags;
	int		error;
	dev_info_t	*top_node;
	char		*errstr;
} attach_pkt_t;

extern uint64_t *sbdp_valp;

sbdp_sr_handle_t *sbdp_get_sr_handle(void);
void sbdp_release_sr_handle(sbdp_sr_handle_t *);
int sbdp_suspend(sbdp_sr_handle_t *);
void sbdp_resume(sbdp_sr_handle_t *);
void sbdp_set_err(sbd_error_t *ep, int ecode, char *rsc);
int sbdp_is_node_bad(pnode_t);
void sbdp_walk_prom_tree(pnode_t, int(*)(pnode_t, void *, uint_t), void *);
int sbdp_detach_bd(int node, int board, sbd_error_t *sep);
void sbdp_attach_bd(int, int);
int sbdp_get_bd_and_wnode_num(pnode_t, int *, int *);
void sbdp_update_bd_info(sbdp_bd_t *);
sbdp_bd_t *sbdp_get_bd_info(int, int);
int sbdp_make_bd_mem_contigous(int);
sbd_cond_t sbdp_get_comp_status(pnode_t);
void sbdp_init_bd_banks(sbdp_bd_t *);
void sbdp_swap_list_of_banks(sbdp_bd_t *, sbdp_bd_t *);
void sbdp_fini_bd_banks(sbdp_bd_t *);
void sbdp_print_bd_banks(sbdp_bd_t *);
void sbdp_add_new_bd_info(int, int);
void sbdp_cleanup_bd(int, int);
void sbdp_cpu_in_reset(int, int, int, int);
int sbdp_is_cpu_in_reset(int, int, int);
int sbdp_set_cpu_present(int, int, int);
int sbdp_is_cpu_present(int, int, int);
int sbdp_swap_slices(int, int);
#ifdef DEBUG
void sbdp_print_all_segs(void);
int sbdp_passthru_test_quiesce(sbdp_handle_t *hp, void *);
#endif
int sbdp_select_top_nodes(pnode_t, void *, uint_t);
pnode_t sbdp_find_nearby_cpu_by_portid(pnode_t, processorid_t);
int sbdp_board_non_panther_cpus(int, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _SBDP_PRIV_H */