xref: /onnv-gate/usr/src/uts/sun4u/ngdr/sys/dr.h (revision 1772:78cca3d2cc4b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1772Sjl139090  * Common Development and Distribution License (the "License").
6*1772Sjl139090  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1772Sjl139090  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_DR_H
270Sstevel@tonic-gate #define	_SYS_DR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/types.h>
360Sstevel@tonic-gate #include <sys/processor.h>
370Sstevel@tonic-gate #include <sys/obpdefs.h>
380Sstevel@tonic-gate #include <sys/memlist.h>
390Sstevel@tonic-gate #include <sys/sbd_ioctl.h>
400Sstevel@tonic-gate #include <sys/mem_config.h>
410Sstevel@tonic-gate #include <sys/dr_util.h>
420Sstevel@tonic-gate #include <sys/drmach.h>
430Sstevel@tonic-gate #include <sys/param.h>			/* for MAXPATHLEN */
440Sstevel@tonic-gate #include <sys/varargs.h>
450Sstevel@tonic-gate #include <sys/note.h>
460Sstevel@tonic-gate 
470Sstevel@tonic-gate #define	DR_MAXNUM_NT		3
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /* used to map sbd_comp_type_t to array index */
50*1772Sjl139090 #define	NIX(t)							\
51*1772Sjl139090 	(((t) == SBD_COMP_CPU) ? 0 :				\
52*1772Sjl139090 	((t) == SBD_COMP_MEM) ? 1 :				\
53*1772Sjl139090 	((t) == SBD_COMP_IO) ? 2 :				\
540Sstevel@tonic-gate 	((t) == SBD_COMP_CMP) ? 0 : DR_MAXNUM_NT)
550Sstevel@tonic-gate 
56*1772Sjl139090 #define	BIX(t)							\
57*1772Sjl139090 	(((t) == SBD_COMP_CPU) ? 0 :				\
58*1772Sjl139090 	((t) == SBD_COMP_MEM) ? 32 :				\
59*1772Sjl139090 	((t) == SBD_COMP_IO) ? 40 :				\
60*1772Sjl139090 	((t) == SBD_COMP_CMP) ? 0 : 0)
61*1772Sjl139090 
62*1772Sjl139090 #define	NMASK(t)						\
63*1772Sjl139090 	(((t) == SBD_COMP_CPU) ? ((dr_devset_t)0xffffffff) :	\
64*1772Sjl139090 	((t) == SBD_COMP_MEM) ? ((dr_devset_t)0x1) :		\
65*1772Sjl139090 	((t) == SBD_COMP_IO) ? ((dr_devset_t)0x1ff) :		\
66*1772Sjl139090 	((t) == SBD_COMP_CMP) ? ((dr_devset_t)0xffffffff) : 0)
67*1772Sjl139090 
680Sstevel@tonic-gate /*
690Sstevel@tonic-gate  * helper macros for constructing and reporting internal error messages.
700Sstevel@tonic-gate  * NOTE: each module which uses one or more this these macros is expected
710Sstevel@tonic-gate  * to supply a char *dr_ie_fmt string containing the SCCS filename
720Sstevel@tonic-gate  * expansion macro (percent M percent) and a sprintf %d to render the
730Sstevel@tonic-gate  * line number argument.
740Sstevel@tonic-gate  */
750Sstevel@tonic-gate #define	DR_INTERNAL_ERROR(hp)				\
760Sstevel@tonic-gate 	drerr_new(1, ESBD_INTERNAL, dr_ie_fmt, __LINE__)
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #define	DR_OP_INTERNAL_ERROR(hp)			\
790Sstevel@tonic-gate 	drerr_set_c(CE_WARN, &(hp)->h_err,		\
800Sstevel@tonic-gate 		ESBD_INTERNAL, dr_ie_fmt, __LINE__)
810Sstevel@tonic-gate 
820Sstevel@tonic-gate #define	DR_DEV_INTERNAL_ERROR(cp)			\
830Sstevel@tonic-gate 	drerr_set_c(CE_WARN, &(cp)->sbdev_error,	\
840Sstevel@tonic-gate 		ESBD_INTERNAL, dr_ie_fmt, __LINE__)
850Sstevel@tonic-gate 
860Sstevel@tonic-gate /*
870Sstevel@tonic-gate  * TODO: Simplify or get rid of this.
880Sstevel@tonic-gate  * Macros for keeping an error code and an associated list of integers.
890Sstevel@tonic-gate  */
900Sstevel@tonic-gate #define	DR_MAX_ERR_INT		(32)
910Sstevel@tonic-gate #define	DR_GET_E_CODE(sep)	((sep)->e_code)
920Sstevel@tonic-gate #define	DR_SET_E_CODE(sep, en)	((sep)->e_code = (en))
930Sstevel@tonic-gate #define	DR_GET_E_RSC(sep)	((sep)->e_rsc)
940Sstevel@tonic-gate 
950Sstevel@tonic-gate /*
960Sstevel@tonic-gate  * Format of dr_devset_t bit masks:
970Sstevel@tonic-gate  *
98*1772Sjl139090  * 64        48        40        32        24        16        8         0
99*1772Sjl139090  *  |....|...I|IIII|IIII|....|...M|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|
1000Sstevel@tonic-gate  *
1010Sstevel@tonic-gate  * 1 = indicates respective component present/attached.
1020Sstevel@tonic-gate  * I = I/O, M = Memory, C = CPU.
1030Sstevel@tonic-gate  */
104*1772Sjl139090 #define	_NT2DEVPOS(t, u)	(BIX(t) + (u))
105*1772Sjl139090 #define	_DEVSET_MASK		((dr_devset_t)0x1ff01ffffffff)
106*1772Sjl139090 #define	_CMP_DEVSET_MASK	((dr_devset_t)0x11111111)
107*1772Sjl139090 #define	DEVSET_ONEUNIT		((dr_devset_t)1)
108*1772Sjl139090 #define	DEVSET_ANYUNIT		(dr_devset_t)(-1)
1090Sstevel@tonic-gate #define	DEVSET(t, u) \
1100Sstevel@tonic-gate 	(((u) == DEVSET_ANYUNIT) ? \
111*1772Sjl139090 		((NMASK(t) << _NT2DEVPOS((t), 0)) & _DEVSET_MASK) : \
1120Sstevel@tonic-gate 	((t) == SBD_COMP_CMP) ? \
113*1772Sjl139090 		(_CMP_DEVSET_MASK << _NT2DEVPOS((t), (u))) : \
114*1772Sjl139090 		(DEVSET_ONEUNIT << _NT2DEVPOS((t), (u))))
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate #define	DEVSET_IN_SET(ds, t, u)	(((ds) & DEVSET((t), (u))) != 0)
1170Sstevel@tonic-gate #define	DEVSET_ADD(ds, t, u)	((ds) |= DEVSET((t), (u)))
1180Sstevel@tonic-gate #define	DEVSET_DEL(ds, t, u)	((ds) &= ~DEVSET((t), (u)))
1190Sstevel@tonic-gate #define	DEVSET_GET_UNITSET(ds, t) \
1200Sstevel@tonic-gate 	(((ds) & DEVSET((t), DEVSET_ANYUNIT)) >> _NT2DEVPOS((t), 0))
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate /*
1230Sstevel@tonic-gate  * Ops for dr_board_t.b_dev_*
1240Sstevel@tonic-gate  */
1250Sstevel@tonic-gate #define	DR_DEV_IS(ds, cp)	DEVSET_IN_SET( \
1260Sstevel@tonic-gate 					(cp)->sbdev_bp->b_dev_##ds, \
1270Sstevel@tonic-gate 					(cp)->sbdev_type, \
1280Sstevel@tonic-gate 					(cp)->sbdev_unum)
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate #define	DR_DEV_ADD(ds, cp)	DEVSET_ADD( \
1310Sstevel@tonic-gate 					(cp)->sbdev_bp->b_dev_##ds, \
1320Sstevel@tonic-gate 					(cp)->sbdev_type, \
1330Sstevel@tonic-gate 					(cp)->sbdev_unum)
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate #define	DR_DEV_DEL(ds, cp)	DEVSET_DEL( \
1360Sstevel@tonic-gate 					(cp)->sbdev_bp->b_dev_##ds, \
1370Sstevel@tonic-gate 					(cp)->sbdev_type, \
1380Sstevel@tonic-gate 					(cp)->sbdev_unum)
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate /*
1410Sstevel@tonic-gate  * Ops for dr_board_t.b_dev_present
1420Sstevel@tonic-gate  */
1430Sstevel@tonic-gate #define	DR_DEV_IS_PRESENT(cp)		DR_DEV_IS(present, cp)
1440Sstevel@tonic-gate #define	DR_DEV_SET_PRESENT(cp)		DR_DEV_ADD(present, cp)
1450Sstevel@tonic-gate #define	DR_DEV_CLR_PRESENT(cp)		DR_DEV_DEL(present, cp)
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate /*
1480Sstevel@tonic-gate  * Ops for dr_board_t.b_dev_attached
1490Sstevel@tonic-gate  */
1500Sstevel@tonic-gate #define	DR_DEV_IS_ATTACHED(cp)		DR_DEV_IS(attached, cp)
1510Sstevel@tonic-gate #define	DR_DEV_SET_ATTACHED(cp)		DR_DEV_ADD(attached, cp)
1520Sstevel@tonic-gate #define	DR_DEV_CLR_ATTACHED(cp)		DR_DEV_DEL(attached, cp)
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate /*
1550Sstevel@tonic-gate  * Ops for dr_board_t.b_dev_released
1560Sstevel@tonic-gate  */
1570Sstevel@tonic-gate #define	DR_DEV_IS_RELEASED(cp)		DR_DEV_IS(released, cp)
1580Sstevel@tonic-gate #define	DR_DEV_SET_RELEASED(cp)		DR_DEV_ADD(released, cp)
1590Sstevel@tonic-gate #define	DR_DEV_CLR_RELEASED(cp)		DR_DEV_DEL(released, cp)
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate /*
1620Sstevel@tonic-gate  * Ops for dr_board_t.b_dev_unreferenced
1630Sstevel@tonic-gate  */
1640Sstevel@tonic-gate #define	DR_DEV_IS_UNREFERENCED(cp)	DR_DEV_IS(unreferenced, cp)
1650Sstevel@tonic-gate #define	DR_DEV_SET_UNREFERENCED(cp)	DR_DEV_ADD(unreferenced, cp)
1660Sstevel@tonic-gate #define	DR_DEV_CLR_UNREFERENCED(cp)	DR_DEV_DEL(unreferenced, cp)
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #define	DR_DEVS_PRESENT(bp) \
1690Sstevel@tonic-gate 			((bp)->b_dev_present)
1700Sstevel@tonic-gate #define	DR_DEVS_ATTACHED(bp) \
1710Sstevel@tonic-gate 			((bp)->b_dev_attached)
1720Sstevel@tonic-gate #define	DR_DEVS_RELEASED(bp) \
1730Sstevel@tonic-gate 			((bp)->b_dev_released)
1740Sstevel@tonic-gate #define	DR_DEVS_UNREFERENCED(bp) \
1750Sstevel@tonic-gate 			((bp)->b_dev_unreferenced)
1760Sstevel@tonic-gate #define	DR_DEVS_UNATTACHED(bp) \
1770Sstevel@tonic-gate 			((bp)->b_dev_present & ~(bp)->b_dev_attached)
1780Sstevel@tonic-gate #define	DR_DEVS_CONFIGURE(bp, devs) \
1790Sstevel@tonic-gate 			((bp)->b_dev_attached = (devs))
1800Sstevel@tonic-gate #define	DR_DEVS_DISCONNECT(bp, devs) \
1810Sstevel@tonic-gate 			((bp)->b_dev_present &= ~(devs))
1820Sstevel@tonic-gate #define	DR_DEVS_CANCEL(bp, devs) \
1830Sstevel@tonic-gate 			((bp)->b_dev_released &= ~(devs), \
1840Sstevel@tonic-gate 			(bp)->b_dev_unreferenced &= ~(devs))
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /*
1870Sstevel@tonic-gate  * CMP Specific Helpers
1880Sstevel@tonic-gate  */
1890Sstevel@tonic-gate #define	DR_CMP_CORE_UNUM(cmp, core)	(cmp + (core * 4))
190*1772Sjl139090 /*
191*1772Sjl139090  * DR_UNUM2SBD_UNUM should be set to (unum & (max #of CMP on board - 1))
192*1772Sjl139090  * for all the platforms.  So far, all sun4u platforms supported have
193*1772Sjl139090  * the same limit so 0x3 works.  One day we might have to make this
194*1772Sjl139090  * a platform specific macro.
195*1772Sjl139090  */
196*1772Sjl139090 
197*1772Sjl139090 #define	DR_UNUM2SBD_UNUM(n, d)		((d == SBD_COMP_IO) ? (n & 0xf) : \
198*1772Sjl139090 					(d == SBD_COMP_CPU) ? (n & 0x3) : \
199*1772Sjl139090 					(d == SBD_COMP_CMP) ? (n & 0x3) : \
200*1772Sjl139090 						(n))
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /*
2030Sstevel@tonic-gate  * Some stuff to assist in debug.
2040Sstevel@tonic-gate  */
2050Sstevel@tonic-gate #ifdef DEBUG
2060Sstevel@tonic-gate #define	DRDBG_STATE	0x00000001
2070Sstevel@tonic-gate #define	DRDBG_QR	0x00000002
2080Sstevel@tonic-gate #define	DRDBG_CPU	0x00000004
2090Sstevel@tonic-gate #define	DRDBG_MEM	0x00000008
2100Sstevel@tonic-gate #define	DRDBG_IO	0x00000010
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate #define	PR_ALL		if (dr_debug)			printf
2130Sstevel@tonic-gate #define	PR_STATE	if (dr_debug & DRDBG_STATE)	printf
2140Sstevel@tonic-gate #define	PR_QR		if (dr_debug & DRDBG_QR)	prom_printf
2150Sstevel@tonic-gate #define	PR_CPU		if (dr_debug & DRDBG_CPU)	printf
2160Sstevel@tonic-gate #define	PR_MEM		if (dr_debug & DRDBG_MEM)	printf
2170Sstevel@tonic-gate #define	PR_IO		if (dr_debug & DRDBG_IO)	printf
2180Sstevel@tonic-gate #define	PR_MEMLIST_DUMP	if (dr_debug & DRDBG_MEM)	MEMLIST_DUMP
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate extern uint_t	dr_debug;
2210Sstevel@tonic-gate #else /* DEBUG */
2220Sstevel@tonic-gate #define	PR_ALL		_NOTE(CONSTANTCONDITION) if (0) printf
2230Sstevel@tonic-gate #define	PR_STATE	PR_ALL
2240Sstevel@tonic-gate #define	PR_QR		PR_ALL
2250Sstevel@tonic-gate #define	PR_CPU		PR_ALL
2260Sstevel@tonic-gate #define	PR_MEM		PR_ALL
2270Sstevel@tonic-gate #define	PR_IO		PR_ALL
2280Sstevel@tonic-gate #define	PR_MEMLIST_DUMP	_NOTE(CONSTANTCONDITION) if (0) MEMLIST_DUMP
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate #endif /* DEBUG */
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate /*
2330Sstevel@tonic-gate  * dr_board_t b_sflags.
2340Sstevel@tonic-gate  */
2350Sstevel@tonic-gate #define	DR_BSLOCK	0x01	/* for blocking status (protected by b_slock) */
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate typedef const char	*fn_t;
238*1772Sjl139090 typedef uint64_t	dr_devset_t;	/* TODO: fix limitation */
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate /*
2410Sstevel@tonic-gate  * Unsafe devices based on dr.conf prop "unsupported-io-drivers"
2420Sstevel@tonic-gate  */
2430Sstevel@tonic-gate typedef struct {
2440Sstevel@tonic-gate 	char	**devnames;
2450Sstevel@tonic-gate 	uint_t	ndevs;
2460Sstevel@tonic-gate } dr_unsafe_devs_t;
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate /*
2490Sstevel@tonic-gate  * Device states.
2500Sstevel@tonic-gate  * PARTIAL state is really only relevant for board state.
2510Sstevel@tonic-gate  */
2520Sstevel@tonic-gate typedef enum {
2530Sstevel@tonic-gate 	DR_STATE_EMPTY = 0,
2540Sstevel@tonic-gate 	DR_STATE_OCCUPIED,
2550Sstevel@tonic-gate 	DR_STATE_CONNECTED,
2560Sstevel@tonic-gate 	DR_STATE_UNCONFIGURED,
2570Sstevel@tonic-gate 	DR_STATE_PARTIAL,		/* part connected, part configured */
2580Sstevel@tonic-gate 	DR_STATE_CONFIGURED,
2590Sstevel@tonic-gate 	DR_STATE_RELEASE,
2600Sstevel@tonic-gate 	DR_STATE_UNREFERENCED,
2610Sstevel@tonic-gate 	DR_STATE_FATAL,
2620Sstevel@tonic-gate 	DR_STATE_MAX
2630Sstevel@tonic-gate } dr_state_t;
2640Sstevel@tonic-gate 
2650Sstevel@tonic-gate typedef struct dr_handle {
2660Sstevel@tonic-gate 	struct dr_board	*h_bd;
2670Sstevel@tonic-gate 	sbd_error_t	*h_err;
2680Sstevel@tonic-gate 	int		h_op_intr;	/* nz if op interrupted */
2690Sstevel@tonic-gate 	dev_t		h_dev;		/* dev_t of opened device */
2700Sstevel@tonic-gate 	int		h_cmd;		/* PIM ioctl argument */
2710Sstevel@tonic-gate 	int		h_mode;		/* device open mode */
2720Sstevel@tonic-gate 	sbd_cmd_t 	h_sbdcmd;	/* copied-in ioctl cmd struct */
2730Sstevel@tonic-gate 	sbd_ioctl_arg_t	*h_iap;		/* ptr to caller-space cmd struct */
2740Sstevel@tonic-gate 	dr_devset_t	h_devset;	/* based on h_dev */
2750Sstevel@tonic-gate 	uint_t		h_ndi;
2760Sstevel@tonic-gate 	drmach_opts_t	h_opts;		/* command-line platform options */
2770Sstevel@tonic-gate } dr_handle_t;
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate typedef struct dr_common_unit {
2800Sstevel@tonic-gate 	dr_state_t		sbdev_state;
2810Sstevel@tonic-gate 	sbd_state_t		sbdev_ostate;
2820Sstevel@tonic-gate 	sbd_cond_t		sbdev_cond;
2830Sstevel@tonic-gate 	time_t			sbdev_time;
2840Sstevel@tonic-gate 	int			sbdev_busy;
2850Sstevel@tonic-gate 	struct dr_board		*sbdev_bp;
2860Sstevel@tonic-gate 	int			sbdev_unum;
2870Sstevel@tonic-gate 	sbd_comp_type_t		sbdev_type;
2880Sstevel@tonic-gate 	drmachid_t		sbdev_id;
2890Sstevel@tonic-gate 	char			sbdev_path[MAXNAMELEN];
2900Sstevel@tonic-gate 	sbd_error_t		*sbdev_error;
2910Sstevel@tonic-gate } dr_common_unit_t;
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate typedef struct dr_mem_unit {
2940Sstevel@tonic-gate 	dr_common_unit_t	sbm_cm;		/* mem-unit state */
2950Sstevel@tonic-gate 	uint_t			sbm_flags;
2960Sstevel@tonic-gate 	pfn_t			sbm_basepfn;
2970Sstevel@tonic-gate 	pgcnt_t			sbm_npages;
2980Sstevel@tonic-gate 	pgcnt_t			sbm_pageslost;
2990Sstevel@tonic-gate 	struct memlist		*sbm_dyn_segs;	/* kphysm_add_dynamic segs */
3000Sstevel@tonic-gate 	/*
3010Sstevel@tonic-gate 	 * The following fields are used during
3020Sstevel@tonic-gate 	 * the memory detach process only. sbm_mlist
3030Sstevel@tonic-gate 	 * will be used to store the board memlist
3040Sstevel@tonic-gate 	 * following a detach.  The memlist will be
3050Sstevel@tonic-gate 	 * used to re-attach the board when configuring
3060Sstevel@tonic-gate 	 * the unit directly after an unconfigure.
3070Sstevel@tonic-gate 	 */
3080Sstevel@tonic-gate 	struct dr_mem_unit	*sbm_peer;
3090Sstevel@tonic-gate 	struct memlist		*sbm_mlist;
3100Sstevel@tonic-gate 	struct memlist		*sbm_del_mlist;
3110Sstevel@tonic-gate 	memhandle_t		sbm_memhandle;
3120Sstevel@tonic-gate 	pfn_t			sbm_alignment_mask;
3130Sstevel@tonic-gate 	pfn_t			sbm_slice_offset;
3140Sstevel@tonic-gate 	uint64_t		sbm_slice_size;
3150Sstevel@tonic-gate } dr_mem_unit_t;
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate /*
3180Sstevel@tonic-gate  * Currently only maintain state information for individual
3190Sstevel@tonic-gate  * components.
3200Sstevel@tonic-gate  */
3210Sstevel@tonic-gate typedef struct dr_cpu_unit {
3220Sstevel@tonic-gate 	dr_common_unit_t	sbc_cm;		/* cpu-unit state */
3230Sstevel@tonic-gate 	processorid_t		sbc_cpu_id;
3240Sstevel@tonic-gate 	cpu_flag_t		sbc_cpu_flags;	/* snapshot of CPU flags */
3250Sstevel@tonic-gate 	ushort_t		sbc_pad1;	/* padded for compatibility */
3260Sstevel@tonic-gate 	int			sbc_speed;
3270Sstevel@tonic-gate 	int			sbc_ecache;
3280Sstevel@tonic-gate 	int			sbc_cpu_impl;
3290Sstevel@tonic-gate } dr_cpu_unit_t;
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate typedef struct dr_io_unit {
3320Sstevel@tonic-gate 	dr_common_unit_t	sbi_cm;		/* io-unit state */
3330Sstevel@tonic-gate } dr_io_unit_t;
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate typedef union {
3360Sstevel@tonic-gate 	dr_common_unit_t	du_common;
3370Sstevel@tonic-gate 	dr_mem_unit_t		du_mem;
3380Sstevel@tonic-gate 	dr_cpu_unit_t		du_cpu;
3390Sstevel@tonic-gate 	dr_io_unit_t		du_io;
3400Sstevel@tonic-gate } dr_dev_unit_t;
3410Sstevel@tonic-gate 
3420Sstevel@tonic-gate typedef struct dr_board {
3430Sstevel@tonic-gate 	kmutex_t	b_lock;		/* lock for this board struct */
3440Sstevel@tonic-gate 	kmutex_t	b_slock;	/* lock for status on the board */
3450Sstevel@tonic-gate 	kcondvar_t	b_scv;		/* condvar for status on the board */
3460Sstevel@tonic-gate 	int		b_sflags;	/* for serializing status */
3470Sstevel@tonic-gate 	sbd_state_t	b_rstate;	/* board's cfgadm receptacle state */
3480Sstevel@tonic-gate 	sbd_state_t	b_ostate;	/* board's cfgadm occupant state */
3490Sstevel@tonic-gate 	sbd_cond_t	b_cond;		/* cfgadm condition */
3500Sstevel@tonic-gate 	int		b_busy;
3510Sstevel@tonic-gate 	int		b_assigned;
3520Sstevel@tonic-gate 	time_t		b_time;		/* time of last board operation */
3530Sstevel@tonic-gate 	char		b_type[MAXNAMELEN];
3540Sstevel@tonic-gate 	drmachid_t	b_id;
3550Sstevel@tonic-gate 	int		b_num;			/* board number */
3560Sstevel@tonic-gate 	int		b_ndev;			/* # of devices on board */
3570Sstevel@tonic-gate 	dev_info_t	*b_dip;			/* dip for make-nodes */
3580Sstevel@tonic-gate 	dr_state_t	b_state;		/* board DR state */
3590Sstevel@tonic-gate 	dr_devset_t	b_dev_present;		/* present mask */
3600Sstevel@tonic-gate 	dr_devset_t	b_dev_attached;		/* attached mask */
3610Sstevel@tonic-gate 	dr_devset_t	b_dev_released;		/* released mask */
3620Sstevel@tonic-gate 	dr_devset_t	b_dev_unreferenced;	/* unreferenced mask */
3630Sstevel@tonic-gate 	char		b_path[MAXNAMELEN];
3640Sstevel@tonic-gate 	dr_dev_unit_t	*b_dev[DR_MAXNUM_NT];
3650Sstevel@tonic-gate } dr_board_t;
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate /*
3680Sstevel@tonic-gate  * dr_quiesce.c interfaces
3690Sstevel@tonic-gate  */
3700Sstevel@tonic-gate struct dr_sr_handle;
3710Sstevel@tonic-gate typedef struct dr_sr_handle dr_sr_handle_t;
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate extern dr_sr_handle_t	*dr_get_sr_handle(dr_handle_t *handle);
3740Sstevel@tonic-gate extern void		dr_release_sr_handle(dr_sr_handle_t *srh);
3750Sstevel@tonic-gate extern int		dr_suspend(dr_sr_handle_t *srh);
3760Sstevel@tonic-gate extern void		dr_resume(dr_sr_handle_t *srh);
3770Sstevel@tonic-gate extern void		dr_check_devices(dev_info_t *dip, int *refcount,
3780Sstevel@tonic-gate 					dr_handle_t *handle, uint64_t *arr,
3790Sstevel@tonic-gate 					int *idx, int len);
3800Sstevel@tonic-gate extern int		dr_pt_test_suspend(dr_handle_t *hp);
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate /*
3830Sstevel@tonic-gate  * dr_cpu.c interface
3840Sstevel@tonic-gate  */
3850Sstevel@tonic-gate extern void		dr_init_cpu_unit(dr_cpu_unit_t *cp);
3860Sstevel@tonic-gate extern int		dr_pre_attach_cpu(dr_handle_t *hp,
3870Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
3880Sstevel@tonic-gate extern void		dr_attach_cpu(dr_handle_t *hp, dr_common_unit_t *cp);
3890Sstevel@tonic-gate extern int		dr_post_attach_cpu(dr_handle_t *hp,
3900Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
3910Sstevel@tonic-gate extern int		dr_pre_release_cpu(dr_handle_t *hp,
3920Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
3930Sstevel@tonic-gate extern int		dr_pre_detach_cpu(dr_handle_t *hp,
3940Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
3950Sstevel@tonic-gate extern void		dr_detach_cpu(dr_handle_t *hp, dr_common_unit_t *cp);
3960Sstevel@tonic-gate extern int		dr_post_detach_cpu(dr_handle_t *hp,
3970Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
3980Sstevel@tonic-gate extern int		dr_cpu_status(dr_handle_t *hp, dr_devset_t devset,
3990Sstevel@tonic-gate 					sbd_dev_stat_t *dsp);
4000Sstevel@tonic-gate extern int		dr_cancel_cpu(dr_cpu_unit_t *cp);
4010Sstevel@tonic-gate extern int		dr_disconnect_cpu(dr_cpu_unit_t *cp);
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate /*
4050Sstevel@tonic-gate  * dr_mem.c interface
4060Sstevel@tonic-gate  */
4070Sstevel@tonic-gate extern void		dr_init_mem_unit(dr_mem_unit_t *mp);
4080Sstevel@tonic-gate extern int		dr_pre_attach_mem(dr_handle_t *hp,
4090Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4100Sstevel@tonic-gate extern void		dr_attach_mem(dr_handle_t *hp, dr_common_unit_t *cp);
4110Sstevel@tonic-gate extern int		dr_post_attach_mem(dr_handle_t *hp,
4120Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4130Sstevel@tonic-gate extern int		dr_pre_release_mem(dr_handle_t *hp,
4140Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4150Sstevel@tonic-gate extern void		dr_release_mem(dr_common_unit_t *cp);
4160Sstevel@tonic-gate extern void		dr_release_mem_done(dr_common_unit_t *cp);
4170Sstevel@tonic-gate extern int		dr_pre_detach_mem(dr_handle_t *hp,
4180Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4190Sstevel@tonic-gate extern void		dr_detach_mem(dr_handle_t *, dr_common_unit_t *);
4200Sstevel@tonic-gate extern int		dr_post_detach_mem(dr_handle_t *hp,
4210Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4220Sstevel@tonic-gate extern int		dr_mem_status(dr_handle_t *hp, dr_devset_t devset,
4230Sstevel@tonic-gate 					sbd_dev_stat_t *dsp);
4240Sstevel@tonic-gate extern int		dr_cancel_mem(dr_mem_unit_t *mp);
4250Sstevel@tonic-gate extern int		dr_disconnect_mem(dr_mem_unit_t *mp);
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate /*
4280Sstevel@tonic-gate  * dr_io.c interface
4290Sstevel@tonic-gate  */
4300Sstevel@tonic-gate extern void		dr_init_io_unit(dr_io_unit_t *io);
4310Sstevel@tonic-gate extern int		dr_disconnect_io(dr_io_unit_t *ip);
4320Sstevel@tonic-gate extern int		dr_pre_attach_io(dr_handle_t *hp,
4330Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4340Sstevel@tonic-gate extern void		dr_attach_io(dr_handle_t *hp, dr_common_unit_t *cp);
4350Sstevel@tonic-gate extern int		dr_post_attach_io(dr_handle_t *hp,
4360Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4370Sstevel@tonic-gate extern int		dr_pre_release_io(dr_handle_t *hp,
4380Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4390Sstevel@tonic-gate extern int		dr_pre_detach_io(dr_handle_t *hp,
4400Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4410Sstevel@tonic-gate extern void		dr_detach_io(dr_handle_t *hp, dr_common_unit_t *cp);
4420Sstevel@tonic-gate extern int		dr_post_detach_io(dr_handle_t *hp,
4430Sstevel@tonic-gate 				dr_common_unit_t **devlist, int devnum);
4440Sstevel@tonic-gate extern int		dr_io_status(dr_handle_t *hp, dr_devset_t devset,
4450Sstevel@tonic-gate 					sbd_dev_stat_t *dsp);
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate 
4480Sstevel@tonic-gate /*
4490Sstevel@tonic-gate  * dr.c interface
4500Sstevel@tonic-gate  */
4510Sstevel@tonic-gate extern void dr_op_err(int ce, dr_handle_t *hp, int code, char *fmt, ...);
4520Sstevel@tonic-gate extern void dr_dev_err(int ce, dr_common_unit_t *cp, int code);
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate extern dr_cpu_unit_t	*dr_get_cpu_unit(dr_board_t *bp, int unit_num);
4550Sstevel@tonic-gate extern dr_mem_unit_t	*dr_get_mem_unit(dr_board_t *bp, int unit_num);
4560Sstevel@tonic-gate extern dr_io_unit_t	*dr_get_io_unit(dr_board_t *bp, int unit_num);
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate extern dr_board_t	*dr_lookup_board(int board_num);
4590Sstevel@tonic-gate extern int		dr_release_dev_done(dr_common_unit_t *cp);
4600Sstevel@tonic-gate extern char		*dr_nt_to_dev_type(int type);
4610Sstevel@tonic-gate extern void		dr_device_transition(dr_common_unit_t *cp,
4620Sstevel@tonic-gate 				dr_state_t new_state);
4630Sstevel@tonic-gate extern void		dr_lock_status(dr_board_t *bp);
4640Sstevel@tonic-gate extern void		dr_unlock_status(dr_board_t *bp);
4650Sstevel@tonic-gate extern int		dr_cmd_flags(dr_handle_t *hp);
4660Sstevel@tonic-gate 
4670Sstevel@tonic-gate #ifdef	__cplusplus
4680Sstevel@tonic-gate }
4690Sstevel@tonic-gate #endif
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate #endif /* _SYS_DR_H */
472