17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 525cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 625cf1a30Sjl139090 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*df3cd224SVijay S Balakrishna * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_DR_H 277c478bd9Sstevel@tonic-gate #define _SYS_DR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/types.h> 347c478bd9Sstevel@tonic-gate #include <sys/processor.h> 357c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h> 367c478bd9Sstevel@tonic-gate #include <sys/memlist.h> 377c478bd9Sstevel@tonic-gate #include <sys/sbd_ioctl.h> 387c478bd9Sstevel@tonic-gate #include <sys/mem_config.h> 397c478bd9Sstevel@tonic-gate #include <sys/dr_util.h> 407c478bd9Sstevel@tonic-gate #include <sys/drmach.h> 417c478bd9Sstevel@tonic-gate #include <sys/param.h> /* for MAXPATHLEN */ 427c478bd9Sstevel@tonic-gate #include <sys/varargs.h> 437c478bd9Sstevel@tonic-gate #include <sys/note.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define DR_MAXNUM_NT 3 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* used to map sbd_comp_type_t to array index */ 487c478bd9Sstevel@tonic-gate #define NIX(t) \ 497c478bd9Sstevel@tonic-gate (((t) == SBD_COMP_CPU) ? 0 : \ 507c478bd9Sstevel@tonic-gate ((t) == SBD_COMP_MEM) ? 1 : \ 517c478bd9Sstevel@tonic-gate ((t) == SBD_COMP_IO) ? 2 : \ 527c478bd9Sstevel@tonic-gate ((t) == SBD_COMP_CMP) ? 0 : DR_MAXNUM_NT) 537c478bd9Sstevel@tonic-gate 5425cf1a30Sjl139090 #define BIX(t) \ 5525cf1a30Sjl139090 (((t) == SBD_COMP_CPU) ? 0 : \ 5625cf1a30Sjl139090 ((t) == SBD_COMP_MEM) ? 32 : \ 5725cf1a30Sjl139090 ((t) == SBD_COMP_IO) ? 40 : \ 5825cf1a30Sjl139090 ((t) == SBD_COMP_CMP) ? 0 : 0) 5925cf1a30Sjl139090 6025cf1a30Sjl139090 #define NMASK(t) \ 6125cf1a30Sjl139090 (((t) == SBD_COMP_CPU) ? ((dr_devset_t)0xffffffff) : \ 6225cf1a30Sjl139090 ((t) == SBD_COMP_MEM) ? ((dr_devset_t)0x1) : \ 6325cf1a30Sjl139090 ((t) == SBD_COMP_IO) ? ((dr_devset_t)0x1ff) : \ 6425cf1a30Sjl139090 ((t) == SBD_COMP_CMP) ? ((dr_devset_t)0xffffffff) : 0) 6525cf1a30Sjl139090 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * helper macros for constructing and reporting internal error messages. 687c478bd9Sstevel@tonic-gate * NOTE: each module which uses one or more this these macros is expected 697c478bd9Sstevel@tonic-gate * to supply a char *dr_ie_fmt string containing the SCCS filename 707c478bd9Sstevel@tonic-gate * expansion macro (percent M percent) and a sprintf %d to render the 717c478bd9Sstevel@tonic-gate * line number argument. 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate #define DR_INTERNAL_ERROR(hp) \ 747c478bd9Sstevel@tonic-gate drerr_new(1, ESBD_INTERNAL, dr_ie_fmt, __LINE__) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate #define DR_OP_INTERNAL_ERROR(hp) \ 777c478bd9Sstevel@tonic-gate drerr_set_c(CE_WARN, &(hp)->h_err, \ 787c478bd9Sstevel@tonic-gate ESBD_INTERNAL, dr_ie_fmt, __LINE__) 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define DR_DEV_INTERNAL_ERROR(cp) \ 817c478bd9Sstevel@tonic-gate drerr_set_c(CE_WARN, &(cp)->sbdev_error, \ 827c478bd9Sstevel@tonic-gate ESBD_INTERNAL, dr_ie_fmt, __LINE__) 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * TODO: Simplify or get rid of this. 867c478bd9Sstevel@tonic-gate * Macros for keeping an error code and an associated list of integers. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate #define DR_MAX_ERR_INT (32) 897c478bd9Sstevel@tonic-gate #define DR_GET_E_CODE(sep) ((sep)->e_code) 907c478bd9Sstevel@tonic-gate #define DR_SET_E_CODE(sep, en) ((sep)->e_code = (en)) 917c478bd9Sstevel@tonic-gate #define DR_GET_E_RSC(sep) ((sep)->e_rsc) 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Format of dr_devset_t bit masks: 957c478bd9Sstevel@tonic-gate * 9625cf1a30Sjl139090 * 64 48 40 32 24 16 8 0 9725cf1a30Sjl139090 * |....|...I|IIII|IIII|....|...M|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC| 987c478bd9Sstevel@tonic-gate * 997c478bd9Sstevel@tonic-gate * 1 = indicates respective component present/attached. 1007c478bd9Sstevel@tonic-gate * I = I/O, M = Memory, C = CPU. 1017c478bd9Sstevel@tonic-gate */ 10225cf1a30Sjl139090 #define _NT2DEVPOS(t, u) (BIX(t) + (u)) 10325cf1a30Sjl139090 #define _DEVSET_MASK ((dr_devset_t)0x1ff01ffffffff) 10425cf1a30Sjl139090 #define _CMP_DEVSET_MASK ((dr_devset_t)0x11111111) 10525cf1a30Sjl139090 #define DEVSET_ONEUNIT ((dr_devset_t)1) 10625cf1a30Sjl139090 #define DEVSET_ANYUNIT (dr_devset_t)(-1) 1077c478bd9Sstevel@tonic-gate #define DEVSET(t, u) \ 1087c478bd9Sstevel@tonic-gate (((u) == DEVSET_ANYUNIT) ? \ 10925cf1a30Sjl139090 ((NMASK(t) << _NT2DEVPOS((t), 0)) & _DEVSET_MASK) : \ 1107c478bd9Sstevel@tonic-gate ((t) == SBD_COMP_CMP) ? \ 11125cf1a30Sjl139090 (_CMP_DEVSET_MASK << _NT2DEVPOS((t), (u))) : \ 11225cf1a30Sjl139090 (DEVSET_ONEUNIT << _NT2DEVPOS((t), (u)))) 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #define DEVSET_IN_SET(ds, t, u) (((ds) & DEVSET((t), (u))) != 0) 1157c478bd9Sstevel@tonic-gate #define DEVSET_ADD(ds, t, u) ((ds) |= DEVSET((t), (u))) 1167c478bd9Sstevel@tonic-gate #define DEVSET_DEL(ds, t, u) ((ds) &= ~DEVSET((t), (u))) 1177c478bd9Sstevel@tonic-gate #define DEVSET_GET_UNITSET(ds, t) \ 1187c478bd9Sstevel@tonic-gate (((ds) & DEVSET((t), DEVSET_ANYUNIT)) >> _NT2DEVPOS((t), 0)) 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_* 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate #define DR_DEV_IS(ds, cp) DEVSET_IN_SET( \ 1247c478bd9Sstevel@tonic-gate (cp)->sbdev_bp->b_dev_##ds, \ 1257c478bd9Sstevel@tonic-gate (cp)->sbdev_type, \ 1267c478bd9Sstevel@tonic-gate (cp)->sbdev_unum) 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #define DR_DEV_ADD(ds, cp) DEVSET_ADD( \ 1297c478bd9Sstevel@tonic-gate (cp)->sbdev_bp->b_dev_##ds, \ 1307c478bd9Sstevel@tonic-gate (cp)->sbdev_type, \ 1317c478bd9Sstevel@tonic-gate (cp)->sbdev_unum) 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #define DR_DEV_DEL(ds, cp) DEVSET_DEL( \ 1347c478bd9Sstevel@tonic-gate (cp)->sbdev_bp->b_dev_##ds, \ 1357c478bd9Sstevel@tonic-gate (cp)->sbdev_type, \ 1367c478bd9Sstevel@tonic-gate (cp)->sbdev_unum) 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_present 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate #define DR_DEV_IS_PRESENT(cp) DR_DEV_IS(present, cp) 1427c478bd9Sstevel@tonic-gate #define DR_DEV_SET_PRESENT(cp) DR_DEV_ADD(present, cp) 1437c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_PRESENT(cp) DR_DEV_DEL(present, cp) 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_attached 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate #define DR_DEV_IS_ATTACHED(cp) DR_DEV_IS(attached, cp) 1497c478bd9Sstevel@tonic-gate #define DR_DEV_SET_ATTACHED(cp) DR_DEV_ADD(attached, cp) 1507c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_ATTACHED(cp) DR_DEV_DEL(attached, cp) 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_released 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate #define DR_DEV_IS_RELEASED(cp) DR_DEV_IS(released, cp) 1567c478bd9Sstevel@tonic-gate #define DR_DEV_SET_RELEASED(cp) DR_DEV_ADD(released, cp) 1577c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_RELEASED(cp) DR_DEV_DEL(released, cp) 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* 1607c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_unreferenced 1617c478bd9Sstevel@tonic-gate */ 1627c478bd9Sstevel@tonic-gate #define DR_DEV_IS_UNREFERENCED(cp) DR_DEV_IS(unreferenced, cp) 1637c478bd9Sstevel@tonic-gate #define DR_DEV_SET_UNREFERENCED(cp) DR_DEV_ADD(unreferenced, cp) 1647c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_UNREFERENCED(cp) DR_DEV_DEL(unreferenced, cp) 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate #define DR_DEVS_PRESENT(bp) \ 1677c478bd9Sstevel@tonic-gate ((bp)->b_dev_present) 1687c478bd9Sstevel@tonic-gate #define DR_DEVS_ATTACHED(bp) \ 1697c478bd9Sstevel@tonic-gate ((bp)->b_dev_attached) 1707c478bd9Sstevel@tonic-gate #define DR_DEVS_RELEASED(bp) \ 1717c478bd9Sstevel@tonic-gate ((bp)->b_dev_released) 1727c478bd9Sstevel@tonic-gate #define DR_DEVS_UNREFERENCED(bp) \ 1737c478bd9Sstevel@tonic-gate ((bp)->b_dev_unreferenced) 1747c478bd9Sstevel@tonic-gate #define DR_DEVS_UNATTACHED(bp) \ 1757c478bd9Sstevel@tonic-gate ((bp)->b_dev_present & ~(bp)->b_dev_attached) 1767c478bd9Sstevel@tonic-gate #define DR_DEVS_CONFIGURE(bp, devs) \ 1777c478bd9Sstevel@tonic-gate ((bp)->b_dev_attached = (devs)) 1787c478bd9Sstevel@tonic-gate #define DR_DEVS_DISCONNECT(bp, devs) \ 1797c478bd9Sstevel@tonic-gate ((bp)->b_dev_present &= ~(devs)) 1807c478bd9Sstevel@tonic-gate #define DR_DEVS_CANCEL(bp, devs) \ 1817c478bd9Sstevel@tonic-gate ((bp)->b_dev_released &= ~(devs), \ 1827c478bd9Sstevel@tonic-gate (bp)->b_dev_unreferenced &= ~(devs)) 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* 1857c478bd9Sstevel@tonic-gate * CMP Specific Helpers 1867c478bd9Sstevel@tonic-gate */ 1877c478bd9Sstevel@tonic-gate #define DR_CMP_CORE_UNUM(cmp, core) (cmp + (core * 4)) 18825cf1a30Sjl139090 /* 18925cf1a30Sjl139090 * DR_UNUM2SBD_UNUM should be set to (unum & (max #of CMP on board - 1)) 19025cf1a30Sjl139090 * for all the platforms. So far, all sun4u platforms supported have 19125cf1a30Sjl139090 * the same limit so 0x3 works. One day we might have to make this 19225cf1a30Sjl139090 * a platform specific macro. 19325cf1a30Sjl139090 */ 19425cf1a30Sjl139090 19525cf1a30Sjl139090 #define DR_UNUM2SBD_UNUM(n, d) ((d == SBD_COMP_IO) ? (n & 0xf) : \ 19625cf1a30Sjl139090 (d == SBD_COMP_CPU) ? (n & 0x3) : \ 19725cf1a30Sjl139090 (d == SBD_COMP_CMP) ? (n & 0x3) : \ 19825cf1a30Sjl139090 (n)) 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * Some stuff to assist in debug. 2027c478bd9Sstevel@tonic-gate */ 2037c478bd9Sstevel@tonic-gate #ifdef DEBUG 2047c478bd9Sstevel@tonic-gate #define DRDBG_STATE 0x00000001 2057c478bd9Sstevel@tonic-gate #define DRDBG_QR 0x00000002 2067c478bd9Sstevel@tonic-gate #define DRDBG_CPU 0x00000004 2077c478bd9Sstevel@tonic-gate #define DRDBG_MEM 0x00000008 2087c478bd9Sstevel@tonic-gate #define DRDBG_IO 0x00000010 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate #define PR_ALL if (dr_debug) printf 2117c478bd9Sstevel@tonic-gate #define PR_STATE if (dr_debug & DRDBG_STATE) printf 2127c478bd9Sstevel@tonic-gate #define PR_QR if (dr_debug & DRDBG_QR) prom_printf 2137c478bd9Sstevel@tonic-gate #define PR_CPU if (dr_debug & DRDBG_CPU) printf 2147c478bd9Sstevel@tonic-gate #define PR_MEM if (dr_debug & DRDBG_MEM) printf 2157c478bd9Sstevel@tonic-gate #define PR_IO if (dr_debug & DRDBG_IO) printf 2167c478bd9Sstevel@tonic-gate #define PR_MEMLIST_DUMP if (dr_debug & DRDBG_MEM) MEMLIST_DUMP 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate extern uint_t dr_debug; 2197c478bd9Sstevel@tonic-gate #else /* DEBUG */ 2207c478bd9Sstevel@tonic-gate #define PR_ALL _NOTE(CONSTANTCONDITION) if (0) printf 2217c478bd9Sstevel@tonic-gate #define PR_STATE PR_ALL 2227c478bd9Sstevel@tonic-gate #define PR_QR PR_ALL 2237c478bd9Sstevel@tonic-gate #define PR_CPU PR_ALL 2247c478bd9Sstevel@tonic-gate #define PR_MEM PR_ALL 2257c478bd9Sstevel@tonic-gate #define PR_IO PR_ALL 2267c478bd9Sstevel@tonic-gate #define PR_MEMLIST_DUMP _NOTE(CONSTANTCONDITION) if (0) MEMLIST_DUMP 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate /* 2317c478bd9Sstevel@tonic-gate * dr_board_t b_sflags. 2327c478bd9Sstevel@tonic-gate */ 2337c478bd9Sstevel@tonic-gate #define DR_BSLOCK 0x01 /* for blocking status (protected by b_slock) */ 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate typedef const char *fn_t; 23625cf1a30Sjl139090 typedef uint64_t dr_devset_t; /* TODO: fix limitation */ 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * Unsafe devices based on dr.conf prop "unsupported-io-drivers" 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate typedef struct { 2427c478bd9Sstevel@tonic-gate char **devnames; 2437c478bd9Sstevel@tonic-gate uint_t ndevs; 2447c478bd9Sstevel@tonic-gate } dr_unsafe_devs_t; 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate /* 2477c478bd9Sstevel@tonic-gate * Device states. 2487c478bd9Sstevel@tonic-gate * PARTIAL state is really only relevant for board state. 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate typedef enum { 2517c478bd9Sstevel@tonic-gate DR_STATE_EMPTY = 0, 2527c478bd9Sstevel@tonic-gate DR_STATE_OCCUPIED, 2537c478bd9Sstevel@tonic-gate DR_STATE_CONNECTED, 2547c478bd9Sstevel@tonic-gate DR_STATE_UNCONFIGURED, 2557c478bd9Sstevel@tonic-gate DR_STATE_PARTIAL, /* part connected, part configured */ 2567c478bd9Sstevel@tonic-gate DR_STATE_CONFIGURED, 2577c478bd9Sstevel@tonic-gate DR_STATE_RELEASE, 2587c478bd9Sstevel@tonic-gate DR_STATE_UNREFERENCED, 2597c478bd9Sstevel@tonic-gate DR_STATE_FATAL, 2607c478bd9Sstevel@tonic-gate DR_STATE_MAX 2617c478bd9Sstevel@tonic-gate } dr_state_t; 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate typedef struct dr_handle { 2647c478bd9Sstevel@tonic-gate struct dr_board *h_bd; 2657c478bd9Sstevel@tonic-gate sbd_error_t *h_err; 2667c478bd9Sstevel@tonic-gate int h_op_intr; /* nz if op interrupted */ 2677c478bd9Sstevel@tonic-gate dev_t h_dev; /* dev_t of opened device */ 2687c478bd9Sstevel@tonic-gate int h_cmd; /* PIM ioctl argument */ 2697c478bd9Sstevel@tonic-gate int h_mode; /* device open mode */ 2707c478bd9Sstevel@tonic-gate sbd_cmd_t h_sbdcmd; /* copied-in ioctl cmd struct */ 2717c478bd9Sstevel@tonic-gate sbd_ioctl_arg_t *h_iap; /* ptr to caller-space cmd struct */ 2727c478bd9Sstevel@tonic-gate dr_devset_t h_devset; /* based on h_dev */ 2737c478bd9Sstevel@tonic-gate uint_t h_ndi; 2747c478bd9Sstevel@tonic-gate drmach_opts_t h_opts; /* command-line platform options */ 2757c478bd9Sstevel@tonic-gate } dr_handle_t; 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate typedef struct dr_common_unit { 2787c478bd9Sstevel@tonic-gate dr_state_t sbdev_state; 2797c478bd9Sstevel@tonic-gate sbd_state_t sbdev_ostate; 2807c478bd9Sstevel@tonic-gate sbd_cond_t sbdev_cond; 2817c478bd9Sstevel@tonic-gate time_t sbdev_time; 2827c478bd9Sstevel@tonic-gate int sbdev_busy; 2837c478bd9Sstevel@tonic-gate struct dr_board *sbdev_bp; 2847c478bd9Sstevel@tonic-gate int sbdev_unum; 2857c478bd9Sstevel@tonic-gate sbd_comp_type_t sbdev_type; 2867c478bd9Sstevel@tonic-gate drmachid_t sbdev_id; 2877c478bd9Sstevel@tonic-gate char sbdev_path[MAXNAMELEN]; 2887c478bd9Sstevel@tonic-gate sbd_error_t *sbdev_error; 2897c478bd9Sstevel@tonic-gate } dr_common_unit_t; 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate typedef struct dr_mem_unit { 2927c478bd9Sstevel@tonic-gate dr_common_unit_t sbm_cm; /* mem-unit state */ 2937c478bd9Sstevel@tonic-gate uint_t sbm_flags; 2947c478bd9Sstevel@tonic-gate pfn_t sbm_basepfn; 2957c478bd9Sstevel@tonic-gate pgcnt_t sbm_npages; 2967c478bd9Sstevel@tonic-gate pgcnt_t sbm_pageslost; 2977c478bd9Sstevel@tonic-gate struct memlist *sbm_dyn_segs; /* kphysm_add_dynamic segs */ 2987c478bd9Sstevel@tonic-gate /* 2997c478bd9Sstevel@tonic-gate * The following fields are used during 3007c478bd9Sstevel@tonic-gate * the memory detach process only. sbm_mlist 3017c478bd9Sstevel@tonic-gate * will be used to store the board memlist 3027c478bd9Sstevel@tonic-gate * following a detach. The memlist will be 3037c478bd9Sstevel@tonic-gate * used to re-attach the board when configuring 3047c478bd9Sstevel@tonic-gate * the unit directly after an unconfigure. 3057c478bd9Sstevel@tonic-gate */ 3067c478bd9Sstevel@tonic-gate struct dr_mem_unit *sbm_peer; 3077c478bd9Sstevel@tonic-gate struct memlist *sbm_mlist; 3087c478bd9Sstevel@tonic-gate struct memlist *sbm_del_mlist; 3097c478bd9Sstevel@tonic-gate memhandle_t sbm_memhandle; 3107c478bd9Sstevel@tonic-gate pfn_t sbm_alignment_mask; 3117c478bd9Sstevel@tonic-gate pfn_t sbm_slice_offset; 3127c478bd9Sstevel@tonic-gate uint64_t sbm_slice_size; 3137c478bd9Sstevel@tonic-gate } dr_mem_unit_t; 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate /* 3167c478bd9Sstevel@tonic-gate * Currently only maintain state information for individual 3177c478bd9Sstevel@tonic-gate * components. 3187c478bd9Sstevel@tonic-gate */ 3197c478bd9Sstevel@tonic-gate typedef struct dr_cpu_unit { 3207c478bd9Sstevel@tonic-gate dr_common_unit_t sbc_cm; /* cpu-unit state */ 3217c478bd9Sstevel@tonic-gate processorid_t sbc_cpu_id; 3227c478bd9Sstevel@tonic-gate cpu_flag_t sbc_cpu_flags; /* snapshot of CPU flags */ 3237c478bd9Sstevel@tonic-gate ushort_t sbc_pad1; /* padded for compatibility */ 3247c478bd9Sstevel@tonic-gate int sbc_speed; 3257c478bd9Sstevel@tonic-gate int sbc_ecache; 3267c478bd9Sstevel@tonic-gate int sbc_cpu_impl; 3277c478bd9Sstevel@tonic-gate } dr_cpu_unit_t; 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate typedef struct dr_io_unit { 3307c478bd9Sstevel@tonic-gate dr_common_unit_t sbi_cm; /* io-unit state */ 3317c478bd9Sstevel@tonic-gate } dr_io_unit_t; 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate typedef union { 3347c478bd9Sstevel@tonic-gate dr_common_unit_t du_common; 3357c478bd9Sstevel@tonic-gate dr_mem_unit_t du_mem; 3367c478bd9Sstevel@tonic-gate dr_cpu_unit_t du_cpu; 3377c478bd9Sstevel@tonic-gate dr_io_unit_t du_io; 3387c478bd9Sstevel@tonic-gate } dr_dev_unit_t; 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate typedef struct dr_board { 3417c478bd9Sstevel@tonic-gate kmutex_t b_lock; /* lock for this board struct */ 3427c478bd9Sstevel@tonic-gate kmutex_t b_slock; /* lock for status on the board */ 3437c478bd9Sstevel@tonic-gate kcondvar_t b_scv; /* condvar for status on the board */ 3447c478bd9Sstevel@tonic-gate int b_sflags; /* for serializing status */ 3457c478bd9Sstevel@tonic-gate sbd_state_t b_rstate; /* board's cfgadm receptacle state */ 3467c478bd9Sstevel@tonic-gate sbd_state_t b_ostate; /* board's cfgadm occupant state */ 3477c478bd9Sstevel@tonic-gate sbd_cond_t b_cond; /* cfgadm condition */ 3487c478bd9Sstevel@tonic-gate int b_busy; 3497c478bd9Sstevel@tonic-gate int b_assigned; 3507c478bd9Sstevel@tonic-gate time_t b_time; /* time of last board operation */ 3517c478bd9Sstevel@tonic-gate char b_type[MAXNAMELEN]; 3527c478bd9Sstevel@tonic-gate drmachid_t b_id; 3537c478bd9Sstevel@tonic-gate int b_num; /* board number */ 3547c478bd9Sstevel@tonic-gate int b_ndev; /* # of devices on board */ 3557c478bd9Sstevel@tonic-gate dev_info_t *b_dip; /* dip for make-nodes */ 3567c478bd9Sstevel@tonic-gate dr_state_t b_state; /* board DR state */ 3577c478bd9Sstevel@tonic-gate dr_devset_t b_dev_present; /* present mask */ 3587c478bd9Sstevel@tonic-gate dr_devset_t b_dev_attached; /* attached mask */ 3597c478bd9Sstevel@tonic-gate dr_devset_t b_dev_released; /* released mask */ 3607c478bd9Sstevel@tonic-gate dr_devset_t b_dev_unreferenced; /* unreferenced mask */ 3617c478bd9Sstevel@tonic-gate char b_path[MAXNAMELEN]; 3627c478bd9Sstevel@tonic-gate dr_dev_unit_t *b_dev[DR_MAXNUM_NT]; 3637c478bd9Sstevel@tonic-gate } dr_board_t; 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate /* 3667c478bd9Sstevel@tonic-gate * dr_quiesce.c interfaces 3677c478bd9Sstevel@tonic-gate */ 3687c478bd9Sstevel@tonic-gate struct dr_sr_handle; 3697c478bd9Sstevel@tonic-gate typedef struct dr_sr_handle dr_sr_handle_t; 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate extern dr_sr_handle_t *dr_get_sr_handle(dr_handle_t *handle); 3727c478bd9Sstevel@tonic-gate extern void dr_release_sr_handle(dr_sr_handle_t *srh); 3737c478bd9Sstevel@tonic-gate extern int dr_suspend(dr_sr_handle_t *srh); 3747c478bd9Sstevel@tonic-gate extern void dr_resume(dr_sr_handle_t *srh); 3757c478bd9Sstevel@tonic-gate extern void dr_check_devices(dev_info_t *dip, int *refcount, 376*df3cd224SVijay S Balakrishna dr_handle_t *handle, uint64_t *arr, int *idx, 377*df3cd224SVijay S Balakrishna int len, int *refcount_non_gldv3); 3787c478bd9Sstevel@tonic-gate extern int dr_pt_test_suspend(dr_handle_t *hp); 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate /* 3817c478bd9Sstevel@tonic-gate * dr_cpu.c interface 3827c478bd9Sstevel@tonic-gate */ 3837c478bd9Sstevel@tonic-gate extern void dr_init_cpu_unit(dr_cpu_unit_t *cp); 3847c478bd9Sstevel@tonic-gate extern int dr_pre_attach_cpu(dr_handle_t *hp, 3857c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3867c478bd9Sstevel@tonic-gate extern void dr_attach_cpu(dr_handle_t *hp, dr_common_unit_t *cp); 3877c478bd9Sstevel@tonic-gate extern int dr_post_attach_cpu(dr_handle_t *hp, 3887c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3897c478bd9Sstevel@tonic-gate extern int dr_pre_release_cpu(dr_handle_t *hp, 3907c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3917c478bd9Sstevel@tonic-gate extern int dr_pre_detach_cpu(dr_handle_t *hp, 3927c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3937c478bd9Sstevel@tonic-gate extern void dr_detach_cpu(dr_handle_t *hp, dr_common_unit_t *cp); 3947c478bd9Sstevel@tonic-gate extern int dr_post_detach_cpu(dr_handle_t *hp, 3957c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3967c478bd9Sstevel@tonic-gate extern int dr_cpu_status(dr_handle_t *hp, dr_devset_t devset, 3977c478bd9Sstevel@tonic-gate sbd_dev_stat_t *dsp); 3987c478bd9Sstevel@tonic-gate extern int dr_cancel_cpu(dr_cpu_unit_t *cp); 3997c478bd9Sstevel@tonic-gate extern int dr_disconnect_cpu(dr_cpu_unit_t *cp); 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate 4027c478bd9Sstevel@tonic-gate /* 4037c478bd9Sstevel@tonic-gate * dr_mem.c interface 4047c478bd9Sstevel@tonic-gate */ 4057c478bd9Sstevel@tonic-gate extern void dr_init_mem_unit(dr_mem_unit_t *mp); 4067c478bd9Sstevel@tonic-gate extern int dr_pre_attach_mem(dr_handle_t *hp, 4077c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4087c478bd9Sstevel@tonic-gate extern void dr_attach_mem(dr_handle_t *hp, dr_common_unit_t *cp); 4097c478bd9Sstevel@tonic-gate extern int dr_post_attach_mem(dr_handle_t *hp, 4107c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4117c478bd9Sstevel@tonic-gate extern int dr_pre_release_mem(dr_handle_t *hp, 4127c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4137c478bd9Sstevel@tonic-gate extern void dr_release_mem(dr_common_unit_t *cp); 4147c478bd9Sstevel@tonic-gate extern void dr_release_mem_done(dr_common_unit_t *cp); 4157c478bd9Sstevel@tonic-gate extern int dr_pre_detach_mem(dr_handle_t *hp, 4167c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4177c478bd9Sstevel@tonic-gate extern void dr_detach_mem(dr_handle_t *, dr_common_unit_t *); 4187c478bd9Sstevel@tonic-gate extern int dr_post_detach_mem(dr_handle_t *hp, 4197c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4207c478bd9Sstevel@tonic-gate extern int dr_mem_status(dr_handle_t *hp, dr_devset_t devset, 4217c478bd9Sstevel@tonic-gate sbd_dev_stat_t *dsp); 4227c478bd9Sstevel@tonic-gate extern int dr_cancel_mem(dr_mem_unit_t *mp); 4237c478bd9Sstevel@tonic-gate extern int dr_disconnect_mem(dr_mem_unit_t *mp); 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate /* 4267c478bd9Sstevel@tonic-gate * dr_io.c interface 4277c478bd9Sstevel@tonic-gate */ 4287c478bd9Sstevel@tonic-gate extern void dr_init_io_unit(dr_io_unit_t *io); 4297c478bd9Sstevel@tonic-gate extern int dr_disconnect_io(dr_io_unit_t *ip); 4307c478bd9Sstevel@tonic-gate extern int dr_pre_attach_io(dr_handle_t *hp, 4317c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4327c478bd9Sstevel@tonic-gate extern void dr_attach_io(dr_handle_t *hp, dr_common_unit_t *cp); 4337c478bd9Sstevel@tonic-gate extern int dr_post_attach_io(dr_handle_t *hp, 4347c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4357c478bd9Sstevel@tonic-gate extern int dr_pre_release_io(dr_handle_t *hp, 4367c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4377c478bd9Sstevel@tonic-gate extern int dr_pre_detach_io(dr_handle_t *hp, 4387c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4397c478bd9Sstevel@tonic-gate extern void dr_detach_io(dr_handle_t *hp, dr_common_unit_t *cp); 4407c478bd9Sstevel@tonic-gate extern int dr_post_detach_io(dr_handle_t *hp, 4417c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4427c478bd9Sstevel@tonic-gate extern int dr_io_status(dr_handle_t *hp, dr_devset_t devset, 4437c478bd9Sstevel@tonic-gate sbd_dev_stat_t *dsp); 4447c478bd9Sstevel@tonic-gate 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate /* 4477c478bd9Sstevel@tonic-gate * dr.c interface 4487c478bd9Sstevel@tonic-gate */ 4497c478bd9Sstevel@tonic-gate extern void dr_op_err(int ce, dr_handle_t *hp, int code, char *fmt, ...); 4507c478bd9Sstevel@tonic-gate extern void dr_dev_err(int ce, dr_common_unit_t *cp, int code); 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate extern dr_cpu_unit_t *dr_get_cpu_unit(dr_board_t *bp, int unit_num); 4537c478bd9Sstevel@tonic-gate extern dr_mem_unit_t *dr_get_mem_unit(dr_board_t *bp, int unit_num); 4547c478bd9Sstevel@tonic-gate extern dr_io_unit_t *dr_get_io_unit(dr_board_t *bp, int unit_num); 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate extern dr_board_t *dr_lookup_board(int board_num); 4577c478bd9Sstevel@tonic-gate extern int dr_release_dev_done(dr_common_unit_t *cp); 4587c478bd9Sstevel@tonic-gate extern char *dr_nt_to_dev_type(int type); 4597c478bd9Sstevel@tonic-gate extern void dr_device_transition(dr_common_unit_t *cp, 4607c478bd9Sstevel@tonic-gate dr_state_t new_state); 4617c478bd9Sstevel@tonic-gate extern void dr_lock_status(dr_board_t *bp); 4627c478bd9Sstevel@tonic-gate extern void dr_unlock_status(dr_board_t *bp); 4637c478bd9Sstevel@tonic-gate extern int dr_cmd_flags(dr_handle_t *hp); 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4667c478bd9Sstevel@tonic-gate } 4677c478bd9Sstevel@tonic-gate #endif 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate #endif /* _SYS_DR_H */ 470