1*a3114836SGerry Liu /* 2*a3114836SGerry Liu * CDDL HEADER START 3*a3114836SGerry Liu * 4*a3114836SGerry Liu * The contents of this file are subject to the terms of the 5*a3114836SGerry Liu * Common Development and Distribution License (the "License"). 6*a3114836SGerry Liu * You may not use this file except in compliance with the License. 7*a3114836SGerry Liu * 8*a3114836SGerry Liu * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*a3114836SGerry Liu * or http://www.opensolaris.org/os/licensing. 10*a3114836SGerry Liu * See the License for the specific language governing permissions 11*a3114836SGerry Liu * and limitations under the License. 12*a3114836SGerry Liu * 13*a3114836SGerry Liu * When distributing Covered Code, include this CDDL HEADER in each 14*a3114836SGerry Liu * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*a3114836SGerry Liu * If applicable, add the following below this CDDL HEADER, with the 16*a3114836SGerry Liu * fields enclosed by brackets "[]" replaced with your own identifying 17*a3114836SGerry Liu * information: Portions Copyright [yyyy] [name of copyright owner] 18*a3114836SGerry Liu * 19*a3114836SGerry Liu * CDDL HEADER END 20*a3114836SGerry Liu */ 21*a3114836SGerry Liu /* 22*a3114836SGerry Liu * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23*a3114836SGerry Liu * Use is subject to license terms. 24*a3114836SGerry Liu */ 25*a3114836SGerry Liu /* 26*a3114836SGerry Liu * Copyright (c) 2010, Intel Corporation. 27*a3114836SGerry Liu * All rights reserved. 28*a3114836SGerry Liu */ 29*a3114836SGerry Liu 30*a3114836SGerry Liu #ifndef _SYS_DR_H 31*a3114836SGerry Liu #define _SYS_DR_H 32*a3114836SGerry Liu #include <sys/types.h> 33*a3114836SGerry Liu #include <sys/note.h> 34*a3114836SGerry Liu #include <sys/processor.h> 35*a3114836SGerry Liu #include <sys/obpdefs.h> 36*a3114836SGerry Liu #include <sys/memlist.h> 37*a3114836SGerry Liu #include <sys/mem_config.h> 38*a3114836SGerry Liu #include <sys/param.h> /* for MAXPATHLEN */ 39*a3114836SGerry Liu #include <sys/varargs.h> 40*a3114836SGerry Liu #include <sys/sbd_ioctl.h> 41*a3114836SGerry Liu #include <sys/dr_util.h> 42*a3114836SGerry Liu #include <sys/drmach.h> 43*a3114836SGerry Liu 44*a3114836SGerry Liu #ifdef __cplusplus 45*a3114836SGerry Liu extern "C" { 46*a3114836SGerry Liu #endif 47*a3114836SGerry Liu 48*a3114836SGerry Liu /* 49*a3114836SGerry Liu * helper macros for constructing and reporting internal error messages. 50*a3114836SGerry Liu * NOTE: each module which uses one or more this these macros is expected 51*a3114836SGerry Liu * to supply a char *dr_ie_fmt string containing the SCCS filename 52*a3114836SGerry Liu * expansion macro (percent M percent) and a sprintf %d to render the 53*a3114836SGerry Liu * line number argument. 54*a3114836SGerry Liu */ 55*a3114836SGerry Liu #define DR_INTERNAL_ERROR(hp) \ 56*a3114836SGerry Liu drerr_new(1, ESBD_INTERNAL, dr_ie_fmt, __LINE__) 57*a3114836SGerry Liu 58*a3114836SGerry Liu #define DR_OP_INTERNAL_ERROR(hp) \ 59*a3114836SGerry Liu drerr_set_c(CE_WARN, &(hp)->h_err, \ 60*a3114836SGerry Liu ESBD_INTERNAL, dr_ie_fmt, __LINE__) 61*a3114836SGerry Liu 62*a3114836SGerry Liu #define DR_DEV_INTERNAL_ERROR(cp) \ 63*a3114836SGerry Liu drerr_set_c(CE_WARN, &(cp)->sbdev_error, \ 64*a3114836SGerry Liu ESBD_INTERNAL, dr_ie_fmt, __LINE__) 65*a3114836SGerry Liu 66*a3114836SGerry Liu /* 67*a3114836SGerry Liu * Macros for keeping an error code and an associated list of integers. 68*a3114836SGerry Liu */ 69*a3114836SGerry Liu #define DR_MAX_ERR_INT (32) 70*a3114836SGerry Liu #define DR_GET_E_CODE(sep) ((sep)->e_code) 71*a3114836SGerry Liu #define DR_SET_E_CODE(sep, en) ((sep)->e_code = (en)) 72*a3114836SGerry Liu #define DR_GET_E_RSC(sep) ((sep)->e_rsc) 73*a3114836SGerry Liu 74*a3114836SGerry Liu /* Number of device node types. */ 75*a3114836SGerry Liu #define DR_MAXNUM_NT 3 76*a3114836SGerry Liu 77*a3114836SGerry Liu /* used to map sbd_comp_type_t to array index */ 78*a3114836SGerry Liu #define DEVSET_NIX(t) \ 79*a3114836SGerry Liu (((t) == SBD_COMP_CPU) ? 0 : \ 80*a3114836SGerry Liu ((t) == SBD_COMP_MEM) ? 1 : \ 81*a3114836SGerry Liu ((t) == SBD_COMP_IO) ? 2 : \ 82*a3114836SGerry Liu ((t) == SBD_COMP_CMP) ? 0 : DR_MAXNUM_NT) 83*a3114836SGerry Liu 84*a3114836SGerry Liu /* 85*a3114836SGerry Liu * Format of dr_devset_t bit masks: 86*a3114836SGerry Liu * 87*a3114836SGerry Liu * 64 56 48 40 32 24 16 8 0 88*a3114836SGerry Liu * |....|IIII|IIII|IIII|IIII|MMMM|MMMM|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC| 89*a3114836SGerry Liu * 90*a3114836SGerry Liu * 1 = indicates respective component present/attached. 91*a3114836SGerry Liu * I = I/O, M = Memory, C = CPU. 92*a3114836SGerry Liu */ 93*a3114836SGerry Liu #define DEVSET_CPU_OFFSET 0 94*a3114836SGerry Liu #define DEVSET_CPU_NUMBER 32 95*a3114836SGerry Liu #define DEVSET_MEM_OFFSET (DEVSET_CPU_OFFSET + DEVSET_CPU_NUMBER) 96*a3114836SGerry Liu #define DEVSET_MEM_NUMBER 8 97*a3114836SGerry Liu #define DEVSET_IO_OFFSET (DEVSET_MEM_OFFSET + DEVSET_MEM_NUMBER) 98*a3114836SGerry Liu #define DEVSET_IO_NUMBER 16 99*a3114836SGerry Liu #define DEVSET_MAX_BITS (DEVSET_IO_OFFSET + DEVSET_IO_NUMBER) 100*a3114836SGerry Liu 101*a3114836SGerry Liu #define DEVSET_BIX(t) \ 102*a3114836SGerry Liu (((t) == SBD_COMP_CPU) ? DEVSET_CPU_OFFSET : \ 103*a3114836SGerry Liu ((t) == SBD_COMP_MEM) ? DEVSET_MEM_OFFSET : \ 104*a3114836SGerry Liu ((t) == SBD_COMP_IO) ? DEVSET_IO_OFFSET : \ 105*a3114836SGerry Liu ((t) == SBD_COMP_CMP) ? DEVSET_CPU_OFFSET : 0) 106*a3114836SGerry Liu 107*a3114836SGerry Liu #define DEVSET_NT2DEVPOS(t, u) (((t) == SBD_COMP_CMP) ?\ 108*a3114836SGerry Liu (DEVSET_BIX(t) + (u) * MAX_CORES_PER_CMP) : DEVSET_BIX(t) + (u)) 109*a3114836SGerry Liu 110*a3114836SGerry Liu #if (DEVSET_MAX_BITS <= 64) 111*a3114836SGerry Liu typedef uint64_t dr_devset_t; 112*a3114836SGerry Liu 113*a3114836SGerry Liu #define DEVSET_ONEUNIT ((dr_devset_t)1) 114*a3114836SGerry Liu #define DEVSET_ANYUNIT ((dr_devset_t)(-1)) 115*a3114836SGerry Liu #define DEVSET_CPU_NMASK ((dr_devset_t)((1ULL << DEVSET_CPU_NUMBER) - 1)) 116*a3114836SGerry Liu #define DEVSET_MEM_NMASK ((dr_devset_t)((1ULL << DEVSET_MEM_NUMBER) - 1)) 117*a3114836SGerry Liu #define DEVSET_IO_NMASK ((dr_devset_t)((1ULL << DEVSET_IO_NUMBER) - 1)) 118*a3114836SGerry Liu #define DEVSET_CMP_NMASK ((dr_devset_t)((1ULL << MAX_CORES_PER_CMP) - 1)) 119*a3114836SGerry Liu 120*a3114836SGerry Liu #define DEVSET_NMASK(t) \ 121*a3114836SGerry Liu (((t) == SBD_COMP_CPU) ? DEVSET_CPU_NMASK : \ 122*a3114836SGerry Liu ((t) == SBD_COMP_MEM) ? DEVSET_MEM_NMASK : \ 123*a3114836SGerry Liu ((t) == SBD_COMP_IO) ? DEVSET_IO_NMASK : \ 124*a3114836SGerry Liu ((t) == SBD_COMP_CMP) ? DEVSET_CPU_NMASK : 0) 125*a3114836SGerry Liu 126*a3114836SGerry Liu #define DEVSET_MASK \ 127*a3114836SGerry Liu ((DEVSET_CPU_NMASK << DEVSET_CPU_OFFSET) | \ 128*a3114836SGerry Liu (DEVSET_MEM_NMASK << DEVSET_MEM_OFFSET) | \ 129*a3114836SGerry Liu (DEVSET_IO_NMASK << DEVSET_IO_OFFSET)) 130*a3114836SGerry Liu 131*a3114836SGerry Liu #define DEVSET(t, u) \ 132*a3114836SGerry Liu (((u) == DEVSET_ANYUNIT) ? \ 133*a3114836SGerry Liu ((DEVSET_NMASK(t) << DEVSET_NT2DEVPOS((t), 0)) & \ 134*a3114836SGerry Liu DEVSET_MASK) : \ 135*a3114836SGerry Liu ((t) == SBD_COMP_CMP) ? \ 136*a3114836SGerry Liu (DEVSET_CMP_NMASK << DEVSET_NT2DEVPOS((t), (u))) : \ 137*a3114836SGerry Liu (DEVSET_ONEUNIT << DEVSET_NT2DEVPOS((t), (u)))) 138*a3114836SGerry Liu 139*a3114836SGerry Liu #define DEVSET_IS_NULL(ds) ((ds) == 0) 140*a3114836SGerry Liu #define DEVSET_IN_SET(ds, t, u) (((ds) & DEVSET((t), (u))) != 0) 141*a3114836SGerry Liu #define DEVSET_ADD(ds, t, u) ((ds) |= DEVSET((t), (u))) 142*a3114836SGerry Liu #define DEVSET_DEL(ds, t, u) ((ds) &= ~DEVSET((t), (u))) 143*a3114836SGerry Liu #define DEVSET_AND(ds1, ds2) ((ds1) & (ds2)) 144*a3114836SGerry Liu #define DEVSET_OR(ds1, ds2) ((ds1) | (ds2)) 145*a3114836SGerry Liu #define DEVSET_NAND(ds1, ds2) ((ds1) & ~(ds2)) 146*a3114836SGerry Liu #define DEVSET_GET_UNITSET(ds, t) \ 147*a3114836SGerry Liu (((ds) & DEVSET((t), DEVSET_ANYUNIT)) >> DEVSET_NT2DEVPOS((t), 0)) 148*a3114836SGerry Liu #define DEVSET_FMT_STR "0x%" PRIx64 "" 149*a3114836SGerry Liu #define DEVSET_FMT_ARG(ds) (ds) 150*a3114836SGerry Liu #else /* DEVSET_MAX_BITS <= 64 */ 151*a3114836SGerry Liu #error please implement devset with bitmap to support more 64 devices 152*a3114836SGerry Liu #endif /* DEVSET_MAX_BITS <= 64 */ 153*a3114836SGerry Liu 154*a3114836SGerry Liu /* 155*a3114836SGerry Liu * Ops for dr_board_t.b_dev_* 156*a3114836SGerry Liu */ 157*a3114836SGerry Liu #define DR_DEV_IS(ds, cp) DEVSET_IN_SET( \ 158*a3114836SGerry Liu (cp)->sbdev_bp->b_dev_##ds, \ 159*a3114836SGerry Liu (cp)->sbdev_type, \ 160*a3114836SGerry Liu (cp)->sbdev_unum) 161*a3114836SGerry Liu 162*a3114836SGerry Liu #define DR_DEV_ADD(ds, cp) DEVSET_ADD( \ 163*a3114836SGerry Liu (cp)->sbdev_bp->b_dev_##ds, \ 164*a3114836SGerry Liu (cp)->sbdev_type, \ 165*a3114836SGerry Liu (cp)->sbdev_unum) 166*a3114836SGerry Liu 167*a3114836SGerry Liu #define DR_DEV_DEL(ds, cp) DEVSET_DEL( \ 168*a3114836SGerry Liu (cp)->sbdev_bp->b_dev_##ds, \ 169*a3114836SGerry Liu (cp)->sbdev_type, \ 170*a3114836SGerry Liu (cp)->sbdev_unum) 171*a3114836SGerry Liu 172*a3114836SGerry Liu /* 173*a3114836SGerry Liu * Ops for dr_board_t.b_dev_present 174*a3114836SGerry Liu */ 175*a3114836SGerry Liu #define DR_DEV_IS_PRESENT(cp) DR_DEV_IS(present, cp) 176*a3114836SGerry Liu #define DR_DEV_SET_PRESENT(cp) DR_DEV_ADD(present, cp) 177*a3114836SGerry Liu #define DR_DEV_CLR_PRESENT(cp) DR_DEV_DEL(present, cp) 178*a3114836SGerry Liu 179*a3114836SGerry Liu /* 180*a3114836SGerry Liu * Ops for dr_board_t.b_dev_attached 181*a3114836SGerry Liu */ 182*a3114836SGerry Liu #define DR_DEV_IS_ATTACHED(cp) DR_DEV_IS(attached, cp) 183*a3114836SGerry Liu #define DR_DEV_SET_ATTACHED(cp) DR_DEV_ADD(attached, cp) 184*a3114836SGerry Liu #define DR_DEV_CLR_ATTACHED(cp) DR_DEV_DEL(attached, cp) 185*a3114836SGerry Liu 186*a3114836SGerry Liu /* 187*a3114836SGerry Liu * Ops for dr_board_t.b_dev_released 188*a3114836SGerry Liu */ 189*a3114836SGerry Liu #define DR_DEV_IS_RELEASED(cp) DR_DEV_IS(released, cp) 190*a3114836SGerry Liu #define DR_DEV_SET_RELEASED(cp) DR_DEV_ADD(released, cp) 191*a3114836SGerry Liu #define DR_DEV_CLR_RELEASED(cp) DR_DEV_DEL(released, cp) 192*a3114836SGerry Liu 193*a3114836SGerry Liu /* 194*a3114836SGerry Liu * Ops for dr_board_t.b_dev_unreferenced 195*a3114836SGerry Liu */ 196*a3114836SGerry Liu #define DR_DEV_IS_UNREFERENCED(cp) DR_DEV_IS(unreferenced, cp) 197*a3114836SGerry Liu #define DR_DEV_SET_UNREFERENCED(cp) DR_DEV_ADD(unreferenced, cp) 198*a3114836SGerry Liu #define DR_DEV_CLR_UNREFERENCED(cp) DR_DEV_DEL(unreferenced, cp) 199*a3114836SGerry Liu 200*a3114836SGerry Liu #define DR_DEVS_PRESENT(bp) \ 201*a3114836SGerry Liu ((bp)->b_dev_present) 202*a3114836SGerry Liu #define DR_DEVS_ATTACHED(bp) \ 203*a3114836SGerry Liu ((bp)->b_dev_attached) 204*a3114836SGerry Liu #define DR_DEVS_RELEASED(bp) \ 205*a3114836SGerry Liu ((bp)->b_dev_released) 206*a3114836SGerry Liu #define DR_DEVS_UNREFERENCED(bp) \ 207*a3114836SGerry Liu ((bp)->b_dev_unreferenced) 208*a3114836SGerry Liu #define DR_DEVS_UNATTACHED(bp) \ 209*a3114836SGerry Liu ((bp)->b_dev_present & ~(bp)->b_dev_attached) 210*a3114836SGerry Liu #define DR_DEVS_CONFIGURE(bp, devs) \ 211*a3114836SGerry Liu ((bp)->b_dev_attached = (devs)) 212*a3114836SGerry Liu #define DR_DEVS_DISCONNECT(bp, devs) \ 213*a3114836SGerry Liu ((bp)->b_dev_present &= ~(devs)) 214*a3114836SGerry Liu #define DR_DEVS_CANCEL(bp, devs) \ 215*a3114836SGerry Liu ((bp)->b_dev_released &= ~(devs), \ 216*a3114836SGerry Liu (bp)->b_dev_unreferenced &= ~(devs)) 217*a3114836SGerry Liu 218*a3114836SGerry Liu /* 219*a3114836SGerry Liu * CMP Specific Helpers 220*a3114836SGerry Liu */ 221*a3114836SGerry Liu #define DR_CMP_CORE_UNUM(cmp, core) ((cmp) * MAX_CORES_PER_CMP + (core)) 222*a3114836SGerry Liu 223*a3114836SGerry Liu /* 224*a3114836SGerry Liu * For CPU and CMP devices, DR_UNUM2SBD_UNUM is used to extract the physical 225*a3114836SGerry Liu * CPU/CMP id from the device id. 226*a3114836SGerry Liu */ 227*a3114836SGerry Liu #define DR_UNUM2SBD_UNUM(n, d) \ 228*a3114836SGerry Liu ((d) == SBD_COMP_CPU ? ((n) / MAX_CORES_PER_CMP) : \ 229*a3114836SGerry Liu (d) == SBD_COMP_CMP ? ((n) / MAX_CORES_PER_CMP) : (n)) 230*a3114836SGerry Liu 231*a3114836SGerry Liu /* 232*a3114836SGerry Liu * Some stuff to assist in debug. 233*a3114836SGerry Liu */ 234*a3114836SGerry Liu #ifdef DEBUG 235*a3114836SGerry Liu #define DRDBG_STATE 0x00000001 236*a3114836SGerry Liu #define DRDBG_QR 0x00000002 237*a3114836SGerry Liu #define DRDBG_CPU 0x00000004 238*a3114836SGerry Liu #define DRDBG_MEM 0x00000008 239*a3114836SGerry Liu #define DRDBG_IO 0x00000010 240*a3114836SGerry Liu 241*a3114836SGerry Liu #define PR_ALL if (dr_debug) printf 242*a3114836SGerry Liu #define PR_STATE if (dr_debug & DRDBG_STATE) printf 243*a3114836SGerry Liu #define PR_QR if (dr_debug & DRDBG_QR) prom_printf 244*a3114836SGerry Liu #define PR_CPU if (dr_debug & DRDBG_CPU) printf 245*a3114836SGerry Liu #define PR_MEM if (dr_debug & DRDBG_MEM) printf 246*a3114836SGerry Liu #define PR_IO if (dr_debug & DRDBG_IO) printf 247*a3114836SGerry Liu #define PR_MEMLIST_DUMP if (dr_debug & DRDBG_MEM) MEMLIST_DUMP 248*a3114836SGerry Liu 249*a3114836SGerry Liu extern uint_t dr_debug; 250*a3114836SGerry Liu #else /* DEBUG */ 251*a3114836SGerry Liu #define PR_ALL _NOTE(CONSTANTCONDITION) if (0) printf 252*a3114836SGerry Liu #define PR_STATE PR_ALL 253*a3114836SGerry Liu #define PR_QR PR_ALL 254*a3114836SGerry Liu #define PR_CPU PR_ALL 255*a3114836SGerry Liu #define PR_MEM PR_ALL 256*a3114836SGerry Liu #define PR_IO PR_ALL 257*a3114836SGerry Liu #define PR_MEMLIST_DUMP _NOTE(CONSTANTCONDITION) if (0) MEMLIST_DUMP 258*a3114836SGerry Liu 259*a3114836SGerry Liu #endif /* DEBUG */ 260*a3114836SGerry Liu 261*a3114836SGerry Liu /* 262*a3114836SGerry Liu * dr_board_t b_sflags. 263*a3114836SGerry Liu */ 264*a3114836SGerry Liu #define DR_BSLOCK 0x01 /* for blocking status (protected by b_slock) */ 265*a3114836SGerry Liu 266*a3114836SGerry Liu typedef const char *fn_t; 267*a3114836SGerry Liu 268*a3114836SGerry Liu /* 269*a3114836SGerry Liu * Unsafe devices based on dr.conf prop "unsupported-io-drivers" 270*a3114836SGerry Liu */ 271*a3114836SGerry Liu typedef struct { 272*a3114836SGerry Liu char **devnames; 273*a3114836SGerry Liu uint_t ndevs; 274*a3114836SGerry Liu } dr_unsafe_devs_t; 275*a3114836SGerry Liu 276*a3114836SGerry Liu /* 277*a3114836SGerry Liu * Device states. 278*a3114836SGerry Liu * PARTIAL state is really only relevant for board state. 279*a3114836SGerry Liu */ 280*a3114836SGerry Liu typedef enum { 281*a3114836SGerry Liu DR_STATE_EMPTY = 0, 282*a3114836SGerry Liu DR_STATE_OCCUPIED, 283*a3114836SGerry Liu DR_STATE_CONNECTED, 284*a3114836SGerry Liu DR_STATE_UNCONFIGURED, 285*a3114836SGerry Liu DR_STATE_PARTIAL, /* part connected, part configured */ 286*a3114836SGerry Liu DR_STATE_CONFIGURED, 287*a3114836SGerry Liu DR_STATE_RELEASE, 288*a3114836SGerry Liu DR_STATE_UNREFERENCED, 289*a3114836SGerry Liu DR_STATE_FATAL, 290*a3114836SGerry Liu DR_STATE_MAX 291*a3114836SGerry Liu } dr_state_t; 292*a3114836SGerry Liu 293*a3114836SGerry Liu typedef struct dr_handle { 294*a3114836SGerry Liu struct dr_board *h_bd; 295*a3114836SGerry Liu sbd_error_t *h_err; 296*a3114836SGerry Liu int h_op_intr; /* nz if op interrupted */ 297*a3114836SGerry Liu dev_t h_dev; /* dev_t of opened device */ 298*a3114836SGerry Liu int h_cmd; /* PIM ioctl argument */ 299*a3114836SGerry Liu int h_mode; /* device open mode */ 300*a3114836SGerry Liu sbd_cmd_t h_sbdcmd; /* copied-in ioctl cmd struct */ 301*a3114836SGerry Liu sbd_ioctl_arg_t *h_iap; /* ptr to caller-space cmd struct */ 302*a3114836SGerry Liu dr_devset_t h_devset; /* based on h_dev */ 303*a3114836SGerry Liu uint_t h_ndi; 304*a3114836SGerry Liu drmach_opts_t h_opts; /* command-line platform options */ 305*a3114836SGerry Liu } dr_handle_t; 306*a3114836SGerry Liu 307*a3114836SGerry Liu typedef struct dr_common_unit { 308*a3114836SGerry Liu dr_state_t sbdev_state; 309*a3114836SGerry Liu sbd_state_t sbdev_ostate; 310*a3114836SGerry Liu sbd_cond_t sbdev_cond; 311*a3114836SGerry Liu time_t sbdev_time; 312*a3114836SGerry Liu int sbdev_busy; 313*a3114836SGerry Liu struct dr_board *sbdev_bp; 314*a3114836SGerry Liu int sbdev_unum; 315*a3114836SGerry Liu sbd_comp_type_t sbdev_type; 316*a3114836SGerry Liu drmachid_t sbdev_id; 317*a3114836SGerry Liu char sbdev_path[MAXNAMELEN]; 318*a3114836SGerry Liu sbd_error_t *sbdev_error; 319*a3114836SGerry Liu } dr_common_unit_t; 320*a3114836SGerry Liu 321*a3114836SGerry Liu typedef struct dr_mem_unit { 322*a3114836SGerry Liu dr_common_unit_t sbm_cm; /* mem-unit state */ 323*a3114836SGerry Liu uint_t sbm_flags; 324*a3114836SGerry Liu pfn_t sbm_basepfn; 325*a3114836SGerry Liu pgcnt_t sbm_npages; 326*a3114836SGerry Liu pgcnt_t sbm_pageslost; 327*a3114836SGerry Liu struct memlist *sbm_dyn_segs; /* kphysm_add_dynamic segs */ 328*a3114836SGerry Liu /* 329*a3114836SGerry Liu * The following fields are used during 330*a3114836SGerry Liu * the memory detach process only. sbm_mlist 331*a3114836SGerry Liu * will be used to store the board memlist 332*a3114836SGerry Liu * following a detach. The memlist will be 333*a3114836SGerry Liu * used to re-attach the board when configuring 334*a3114836SGerry Liu * the unit directly after an unconfigure. 335*a3114836SGerry Liu */ 336*a3114836SGerry Liu struct dr_mem_unit *sbm_peer; 337*a3114836SGerry Liu struct memlist *sbm_mlist; 338*a3114836SGerry Liu struct memlist *sbm_del_mlist; 339*a3114836SGerry Liu memhandle_t sbm_memhandle; 340*a3114836SGerry Liu uint64_t sbm_alignment_mask; 341*a3114836SGerry Liu uint64_t sbm_slice_base; 342*a3114836SGerry Liu uint64_t sbm_slice_top; 343*a3114836SGerry Liu uint64_t sbm_slice_size; 344*a3114836SGerry Liu } dr_mem_unit_t; 345*a3114836SGerry Liu 346*a3114836SGerry Liu /* 347*a3114836SGerry Liu * Currently only maintain state information for individual 348*a3114836SGerry Liu * components. 349*a3114836SGerry Liu */ 350*a3114836SGerry Liu typedef struct dr_cpu_unit { 351*a3114836SGerry Liu dr_common_unit_t sbc_cm; /* cpu-unit state */ 352*a3114836SGerry Liu processorid_t sbc_cpu_id; 353*a3114836SGerry Liu cpu_flag_t sbc_cpu_flags; /* snapshot of CPU flags */ 354*a3114836SGerry Liu ushort_t sbc_pad1; /* padded for compatibility */ 355*a3114836SGerry Liu int sbc_speed; 356*a3114836SGerry Liu int sbc_ecache; 357*a3114836SGerry Liu int sbc_cpu_impl; 358*a3114836SGerry Liu } dr_cpu_unit_t; 359*a3114836SGerry Liu 360*a3114836SGerry Liu typedef struct dr_io_unit { 361*a3114836SGerry Liu dr_common_unit_t sbi_cm; /* io-unit state */ 362*a3114836SGerry Liu } dr_io_unit_t; 363*a3114836SGerry Liu 364*a3114836SGerry Liu typedef union { 365*a3114836SGerry Liu dr_common_unit_t du_common; 366*a3114836SGerry Liu dr_mem_unit_t du_mem; 367*a3114836SGerry Liu dr_cpu_unit_t du_cpu; 368*a3114836SGerry Liu dr_io_unit_t du_io; 369*a3114836SGerry Liu } dr_dev_unit_t; 370*a3114836SGerry Liu 371*a3114836SGerry Liu typedef struct dr_board { 372*a3114836SGerry Liu kmutex_t b_lock; /* lock for this board struct */ 373*a3114836SGerry Liu kmutex_t b_slock; /* lock for status on the board */ 374*a3114836SGerry Liu kcondvar_t b_scv; /* condvar for status on the board */ 375*a3114836SGerry Liu int b_sflags; /* for serializing status */ 376*a3114836SGerry Liu sbd_state_t b_rstate; /* board's cfgadm receptacle state */ 377*a3114836SGerry Liu sbd_state_t b_ostate; /* board's cfgadm occupant state */ 378*a3114836SGerry Liu sbd_cond_t b_cond; /* cfgadm condition */ 379*a3114836SGerry Liu int b_busy; 380*a3114836SGerry Liu int b_assigned; 381*a3114836SGerry Liu time_t b_time; /* time of last board operation */ 382*a3114836SGerry Liu char b_type[MAXNAMELEN]; 383*a3114836SGerry Liu drmachid_t b_id; 384*a3114836SGerry Liu int b_num; /* board number */ 385*a3114836SGerry Liu int b_ndev; /* # of devices on board */ 386*a3114836SGerry Liu dev_info_t *b_dip; /* dip for make-nodes */ 387*a3114836SGerry Liu dr_state_t b_state; /* board DR state */ 388*a3114836SGerry Liu dr_devset_t b_dev_present; /* present mask */ 389*a3114836SGerry Liu dr_devset_t b_dev_attached; /* attached mask */ 390*a3114836SGerry Liu dr_devset_t b_dev_released; /* released mask */ 391*a3114836SGerry Liu dr_devset_t b_dev_unreferenced; /* unreferenced mask */ 392*a3114836SGerry Liu char b_path[MAXNAMELEN]; 393*a3114836SGerry Liu dr_dev_unit_t *b_dev[DR_MAXNUM_NT]; 394*a3114836SGerry Liu } dr_board_t; 395*a3114836SGerry Liu 396*a3114836SGerry Liu /* 397*a3114836SGerry Liu * dr_quiesce.c interfaces 398*a3114836SGerry Liu */ 399*a3114836SGerry Liu struct dr_sr_handle; 400*a3114836SGerry Liu typedef struct dr_sr_handle dr_sr_handle_t; 401*a3114836SGerry Liu 402*a3114836SGerry Liu extern dr_sr_handle_t *dr_get_sr_handle(dr_handle_t *handle); 403*a3114836SGerry Liu extern void dr_release_sr_handle(dr_sr_handle_t *srh); 404*a3114836SGerry Liu extern int dr_suspend(dr_sr_handle_t *srh); 405*a3114836SGerry Liu extern void dr_resume(dr_sr_handle_t *srh); 406*a3114836SGerry Liu extern void dr_check_devices(dev_info_t *dip, int *refcount, 407*a3114836SGerry Liu dr_handle_t *handle, uint64_t *arr, int *idx, 408*a3114836SGerry Liu int len, int *refcount_non_gldv3); 409*a3114836SGerry Liu extern int dr_pt_test_suspend(dr_handle_t *hp); 410*a3114836SGerry Liu 411*a3114836SGerry Liu /* 412*a3114836SGerry Liu * dr_cpu.c interface 413*a3114836SGerry Liu */ 414*a3114836SGerry Liu extern void dr_init_cpu_unit(dr_cpu_unit_t *cp); 415*a3114836SGerry Liu extern int dr_pre_attach_cpu(dr_handle_t *hp, 416*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 417*a3114836SGerry Liu extern void dr_attach_cpu(dr_handle_t *hp, dr_common_unit_t *cp); 418*a3114836SGerry Liu extern int dr_post_attach_cpu(dr_handle_t *hp, 419*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 420*a3114836SGerry Liu extern int dr_pre_release_cpu(dr_handle_t *hp, 421*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 422*a3114836SGerry Liu extern int dr_pre_detach_cpu(dr_handle_t *hp, 423*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 424*a3114836SGerry Liu extern void dr_detach_cpu(dr_handle_t *hp, dr_common_unit_t *cp); 425*a3114836SGerry Liu extern int dr_post_detach_cpu(dr_handle_t *hp, 426*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 427*a3114836SGerry Liu extern int dr_cpu_status(dr_handle_t *hp, dr_devset_t devset, 428*a3114836SGerry Liu sbd_dev_stat_t *dsp); 429*a3114836SGerry Liu extern int dr_cancel_cpu(dr_cpu_unit_t *cp); 430*a3114836SGerry Liu extern int dr_disconnect_cpu(dr_cpu_unit_t *cp); 431*a3114836SGerry Liu 432*a3114836SGerry Liu 433*a3114836SGerry Liu /* 434*a3114836SGerry Liu * dr_mem.c interface 435*a3114836SGerry Liu */ 436*a3114836SGerry Liu extern void dr_init_mem_unit(dr_mem_unit_t *mp); 437*a3114836SGerry Liu extern int dr_pre_attach_mem(dr_handle_t *hp, 438*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 439*a3114836SGerry Liu extern void dr_attach_mem(dr_handle_t *hp, dr_common_unit_t *cp); 440*a3114836SGerry Liu extern int dr_post_attach_mem(dr_handle_t *hp, 441*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 442*a3114836SGerry Liu extern int dr_pre_release_mem(dr_handle_t *hp, 443*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 444*a3114836SGerry Liu extern void dr_release_mem(dr_common_unit_t *cp); 445*a3114836SGerry Liu extern void dr_release_mem_done(dr_common_unit_t *cp); 446*a3114836SGerry Liu extern int dr_pre_detach_mem(dr_handle_t *hp, 447*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 448*a3114836SGerry Liu extern void dr_detach_mem(dr_handle_t *, dr_common_unit_t *); 449*a3114836SGerry Liu extern int dr_post_detach_mem(dr_handle_t *hp, 450*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 451*a3114836SGerry Liu extern int dr_mem_status(dr_handle_t *hp, dr_devset_t devset, 452*a3114836SGerry Liu sbd_dev_stat_t *dsp); 453*a3114836SGerry Liu extern int dr_cancel_mem(dr_mem_unit_t *mp); 454*a3114836SGerry Liu extern int dr_disconnect_mem(dr_mem_unit_t *mp); 455*a3114836SGerry Liu 456*a3114836SGerry Liu /* 457*a3114836SGerry Liu * dr_io.c interface 458*a3114836SGerry Liu */ 459*a3114836SGerry Liu extern void dr_init_io_unit(dr_io_unit_t *io); 460*a3114836SGerry Liu extern int dr_pre_attach_io(dr_handle_t *hp, 461*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 462*a3114836SGerry Liu extern void dr_attach_io(dr_handle_t *hp, dr_common_unit_t *cp); 463*a3114836SGerry Liu extern int dr_post_attach_io(dr_handle_t *hp, 464*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 465*a3114836SGerry Liu extern int dr_pre_release_io(dr_handle_t *hp, 466*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 467*a3114836SGerry Liu extern int dr_pre_detach_io(dr_handle_t *hp, 468*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 469*a3114836SGerry Liu extern void dr_detach_io(dr_handle_t *hp, dr_common_unit_t *cp); 470*a3114836SGerry Liu extern int dr_post_detach_io(dr_handle_t *hp, 471*a3114836SGerry Liu dr_common_unit_t **devlist, int devnum); 472*a3114836SGerry Liu extern int dr_io_status(dr_handle_t *hp, dr_devset_t devset, 473*a3114836SGerry Liu sbd_dev_stat_t *dsp); 474*a3114836SGerry Liu extern int dr_disconnect_io(dr_io_unit_t *ip); 475*a3114836SGerry Liu 476*a3114836SGerry Liu 477*a3114836SGerry Liu /* 478*a3114836SGerry Liu * dr.c interface 479*a3114836SGerry Liu */ 480*a3114836SGerry Liu extern void dr_op_err(int ce, dr_handle_t *hp, int code, char *fmt, ...); 481*a3114836SGerry Liu extern void dr_dev_err(int ce, dr_common_unit_t *cp, int code); 482*a3114836SGerry Liu 483*a3114836SGerry Liu extern dr_cpu_unit_t *dr_get_cpu_unit(dr_board_t *bp, int unit_num); 484*a3114836SGerry Liu extern dr_mem_unit_t *dr_get_mem_unit(dr_board_t *bp, int unit_num); 485*a3114836SGerry Liu extern dr_io_unit_t *dr_get_io_unit(dr_board_t *bp, int unit_num); 486*a3114836SGerry Liu 487*a3114836SGerry Liu extern dr_board_t *dr_lookup_board(int board_num); 488*a3114836SGerry Liu extern int dr_release_dev_done(dr_common_unit_t *cp); 489*a3114836SGerry Liu extern char *dr_nt_to_dev_type(int type); 490*a3114836SGerry Liu extern void dr_device_transition(dr_common_unit_t *cp, 491*a3114836SGerry Liu dr_state_t new_state); 492*a3114836SGerry Liu extern void dr_lock_status(dr_board_t *bp); 493*a3114836SGerry Liu extern void dr_unlock_status(dr_board_t *bp); 494*a3114836SGerry Liu extern int dr_cmd_flags(dr_handle_t *hp); 495*a3114836SGerry Liu 496*a3114836SGerry Liu #ifdef __cplusplus 497*a3114836SGerry Liu } 498*a3114836SGerry Liu #endif 499*a3114836SGerry Liu 500*a3114836SGerry Liu #endif /* _SYS_DR_H */ 501