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