1*1708Sstevel /* 2*1708Sstevel * CDDL HEADER START 3*1708Sstevel * 4*1708Sstevel * The contents of this file are subject to the terms of the 5*1708Sstevel * Common Development and Distribution License (the "License"). 6*1708Sstevel * You may not use this file except in compliance with the License. 7*1708Sstevel * 8*1708Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*1708Sstevel * or http://www.opensolaris.org/os/licensing. 10*1708Sstevel * See the License for the specific language governing permissions 11*1708Sstevel * and limitations under the License. 12*1708Sstevel * 13*1708Sstevel * When distributing Covered Code, include this CDDL HEADER in each 14*1708Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*1708Sstevel * If applicable, add the following below this CDDL HEADER, with the 16*1708Sstevel * fields enclosed by brackets "[]" replaced with your own identifying 17*1708Sstevel * information: Portions Copyright [yyyy] [name of copyright owner] 18*1708Sstevel * 19*1708Sstevel * CDDL HEADER END 20*1708Sstevel */ 21*1708Sstevel 22*1708Sstevel /* 23*1708Sstevel * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*1708Sstevel * Use is subject to license terms. 25*1708Sstevel */ 26*1708Sstevel 27*1708Sstevel #ifndef _SBDP_PRIV_H 28*1708Sstevel #define _SBDP_PRIV_H 29*1708Sstevel 30*1708Sstevel #pragma ident "%Z%%M% %I% %E% SMI" 31*1708Sstevel 32*1708Sstevel #ifdef __cplusplus 33*1708Sstevel extern "C" { 34*1708Sstevel #endif 35*1708Sstevel 36*1708Sstevel #include <sys/sbd.h> 37*1708Sstevel #include <sys/sbdp_mbox.h> 38*1708Sstevel #include <sys/conf.h> 39*1708Sstevel #include <sys/ddi_impldefs.h> 40*1708Sstevel #include <sys/serengeti.h> 41*1708Sstevel 42*1708Sstevel #ifdef DEBUG 43*1708Sstevel #define SBDPDBG_STATE 0x00000001 44*1708Sstevel #define SBDPDBG_QR 0x00000002 45*1708Sstevel #define SBDPDBG_CPU 0x00000004 46*1708Sstevel #define SBDPDBG_MEM 0x00000008 47*1708Sstevel #define SBDPDBG_IO 0x00000010 48*1708Sstevel #define SBDPDBG_MBOX 0x00000020 49*1708Sstevel #define SBDPDBG_ERR 0x00000040 50*1708Sstevel #define SBDPDBG_MISC 0x00000080 51*1708Sstevel #define SBDPDBG_FUNC 0x00000100 52*1708Sstevel 53*1708Sstevel extern uint_t sbdp_debug; 54*1708Sstevel 55*1708Sstevel #define SBDP_DBG_ALL if (sbdp_debug) prom_printf 56*1708Sstevel #define SBDP_DBG_STATE if (sbdp_debug & SBDPDBG_STATE) prom_printf 57*1708Sstevel #define SBDP_DBG_QR if (sbdp_debug & SBDPDBG_QR) prom_printf 58*1708Sstevel #define SBDP_DBG_CPU if (sbdp_debug & SBDPDBG_CPU) prom_printf 59*1708Sstevel #define SBDP_DBG_MEM if (sbdp_debug & SBDPDBG_MEM) prom_printf 60*1708Sstevel #define SBDP_DBG_IO if (sbdp_debug & SBDPDBG_IO) prom_printf 61*1708Sstevel #define SBDP_DBG_MBOX if (sbdp_debug & SBDPDBG_MBOX) prom_printf 62*1708Sstevel #define SBDP_DBG_ERR if (sbdp_debug & SBDPDBG_ERR) prom_printf 63*1708Sstevel #define SBDP_DBG_MISC if (sbdp_debug & SBDPDBG_MISC) prom_printf 64*1708Sstevel #define SBDP_DBG_FUNC if (sbdp_debug & SBDPDBG_FUNC) prom_printf 65*1708Sstevel 66*1708Sstevel #else /* DEBUG */ 67*1708Sstevel 68*1708Sstevel #define SBDP_DBG_ALL 69*1708Sstevel #define SBDP_DBG_STATE 70*1708Sstevel #define SBDP_DBG_QR 71*1708Sstevel #define SBDP_DBG_CPU 72*1708Sstevel #define SBDP_DBG_MEM 73*1708Sstevel #define SBDP_DBG_IO 74*1708Sstevel #define SBDP_DBG_MBOX 75*1708Sstevel #define SBDP_DBG_ERR 76*1708Sstevel #define SBDP_DBG_MISC 77*1708Sstevel #define SBDP_DBG_FUNC 78*1708Sstevel #endif /* DEBUG */ 79*1708Sstevel 80*1708Sstevel #define PORTID_BAD -1 81*1708Sstevel #define OBP_PORTID "portid" 82*1708Sstevel #define SBDP_MAX_BOARDS plat_max_boards() 83*1708Sstevel #define SBDP_MAX_MEM_NODES_PER_BOARD 4 84*1708Sstevel #define SBDP_MAX_NODES 32 85*1708Sstevel #define SBDP_MAX_WNODES 16 86*1708Sstevel 87*1708Sstevel /* 88*1708Sstevel * CPU present macros 89*1708Sstevel */ 90*1708Sstevel #define SBDP_SET_CPU_PRESENT(bdp, unit)\ 91*1708Sstevel ((bdp)->cpus_present |= (1 << (unit))) 92*1708Sstevel 93*1708Sstevel #define SBDP_IS_CPU_PRESENT(bdp, unit)\ 94*1708Sstevel (((bdp)->cpus_present & (1 << (unit))) != 0) 95*1708Sstevel 96*1708Sstevel /* 97*1708Sstevel * CPU reset macros 98*1708Sstevel */ 99*1708Sstevel #define SBDP_SET_CPU_IN_RESET(bdp, unit)\ 100*1708Sstevel ((bdp)->cpus_in_reset |= (1 << (unit))) 101*1708Sstevel #define SBDP_UNSET_CPU_IN_RESET(bdp, unit)\ 102*1708Sstevel ((bdp)->cpus_in_reset &= ~(1 << (unit))) 103*1708Sstevel #define SBDP_IS_CPU_IN_RESET(bdp, unit)\ 104*1708Sstevel (((bdp)->cpus_in_reset & (1 << (unit))) != 0) 105*1708Sstevel #define SBDP_SET_ALL_CPUS_IN_RESET(bdp)\ 106*1708Sstevel ((bdp)->cpus_in_reset |= 0xf) 107*1708Sstevel #define SBDP_UNSET_ALL_CPUS_IN_RESET(bdp)\ 108*1708Sstevel ((bdp)->cpus_in_reset = 0x0) 109*1708Sstevel #define SBDP_ALL_CPUS -1 110*1708Sstevel 111*1708Sstevel /* 112*1708Sstevel * These definitions come from the SC. Should the SC change them 113*1708Sstevel * then we need to changed them 114*1708Sstevel */ 115*1708Sstevel #define SBDP_DIAG_OFF 0x00 116*1708Sstevel #define SBDP_DIAG_INIT 0x07 117*1708Sstevel #define SBDP_DIAG_QUICK 0x10 118*1708Sstevel #define SBDP_DIAG_MIN 0x20 119*1708Sstevel #define SBDP_DIAG_DEFAULT 0x40 120*1708Sstevel #define SBDP_DIAG_MEM1 0x60 121*1708Sstevel #define SBDP_DIAG_MEM2 0x7f 122*1708Sstevel #define SBDP_DIAG_NVCI 0xffff /* Use stored value in nvci */ 123*1708Sstevel 124*1708Sstevel int *slices; 125*1708Sstevel 126*1708Sstevel #define SBDP_INIT_PLATOPTS (uint_t)-1 127*1708Sstevel #define SBDP_PLATFORM_OPTS(s_platopts) ((s_platopts) = SBDP_INIT_PLATOPTS, \ 128*1708Sstevel SBD_SET_PLATOPTS(SBD_CMD_TEST, (s_platopts)), \ 129*1708Sstevel SBD_SET_PLATOPTS(SBD_CMD_PASSTHRU, (s_platopts))) 130*1708Sstevel 131*1708Sstevel typedef struct sbdp_bank { 132*1708Sstevel int id; 133*1708Sstevel ushort_t valid; 134*1708Sstevel ushort_t uk; 135*1708Sstevel uint_t um; 136*1708Sstevel uchar_t lk; 137*1708Sstevel uchar_t lm; 138*1708Sstevel struct sbdp_bank *bd_next; /* in the board */ 139*1708Sstevel struct sbdp_bank *seg_next; /* in the segment */ 140*1708Sstevel } sbdp_bank_t; 141*1708Sstevel 142*1708Sstevel typedef struct sbdp_segs { 143*1708Sstevel int id; 144*1708Sstevel int intlv; /* interleave for this segment */ 145*1708Sstevel uint64_t base; /* base address for this segment */ 146*1708Sstevel uint64_t size; /* size of this segment */ 147*1708Sstevel int nbanks; /* number of banks in this segment */ 148*1708Sstevel sbdp_bank_t *banks; /* pointer to the banks of this seg */ 149*1708Sstevel struct sbdp_segs *next; 150*1708Sstevel } sbdp_seg_t; 151*1708Sstevel 152*1708Sstevel typedef struct { 153*1708Sstevel int bd; 154*1708Sstevel int wnode; 155*1708Sstevel uint64_t bpa; /* base physical addr for this board */ 156*1708Sstevel int nnum; /* number of nodes */ 157*1708Sstevel struct memlist *ml; /* memlist for this board */ 158*1708Sstevel pnode_t nodes[SBDP_MAX_MEM_NODES_PER_BOARD]; 159*1708Sstevel kmutex_t bd_mutex; /* mutex for this board */ 160*1708Sstevel show_board_t *bd_sc; /* info obtained from the SC */ 161*1708Sstevel int valid_cp; /* Is this a valid copy of show_board */ 162*1708Sstevel sbdp_bank_t *banks; /* Banks for this board */ 163*1708Sstevel int cpus_in_reset; 164*1708Sstevel int cpus_present; 165*1708Sstevel } sbdp_bd_t; 166*1708Sstevel 167*1708Sstevel typedef struct sbdp_wnode { 168*1708Sstevel int wnode; /* wildcat node */ 169*1708Sstevel int nbds; /* number of bds for this node */ 170*1708Sstevel sbdp_bd_t *bds; /* pointer to the list of bds */ 171*1708Sstevel struct sbdp_wnode *next; /* ptr to nex wnode */ 172*1708Sstevel struct sbdp_wnode *prev; /* ptr to prev node */ 173*1708Sstevel } sbdp_wnode_t; 174*1708Sstevel 175*1708Sstevel typedef struct { 176*1708Sstevel uint_t regspec_addr_hi; 177*1708Sstevel uint_t regspec_addr_lo; 178*1708Sstevel uint_t regspec_size_hi; 179*1708Sstevel uint_t regspec_size_lo; 180*1708Sstevel } regspace_t; 181*1708Sstevel 182*1708Sstevel /* 183*1708Sstevel * Suspend states used internally by sbdp_suspend and 184*1708Sstevel * sbdp_resume 185*1708Sstevel */ 186*1708Sstevel typedef enum sbd_suspend_state { 187*1708Sstevel SBDP_SRSTATE_BEGIN = 0, 188*1708Sstevel SBDP_SRSTATE_USER, 189*1708Sstevel SBDP_SRSTATE_DRIVER, 190*1708Sstevel SBDP_SRSTATE_FULL 191*1708Sstevel } suspend_state_t; 192*1708Sstevel 193*1708Sstevel /* 194*1708Sstevel * specific suspend/resume interface handle 195*1708Sstevel */ 196*1708Sstevel typedef struct { 197*1708Sstevel sbd_error_t sep; 198*1708Sstevel dev_info_t *sr_failed_dip; 199*1708Sstevel suspend_state_t sr_suspend_state; 200*1708Sstevel uint_t sr_flags; 201*1708Sstevel uint_t sh_ndi; 202*1708Sstevel } sbdp_sr_handle_t; 203*1708Sstevel 204*1708Sstevel typedef struct sbdp_shutdown { 205*1708Sstevel uint64_t estack; 206*1708Sstevel uint64_t flushaddr; 207*1708Sstevel uint32_t size; 208*1708Sstevel uint32_t linesize; 209*1708Sstevel uint64_t physaddr; 210*1708Sstevel } sbdp_shutdown_t; 211*1708Sstevel 212*1708Sstevel extern int plat_max_boards(); 213*1708Sstevel 214*1708Sstevel typedef struct { 215*1708Sstevel int node; /* wildcat node */ 216*1708Sstevel int board; 217*1708Sstevel pnode_t nodes[SBDP_MAX_NODES]; 218*1708Sstevel int num_of_nodes; 219*1708Sstevel int flags; 220*1708Sstevel int error; 221*1708Sstevel dev_info_t *top_node; 222*1708Sstevel char *errstr; 223*1708Sstevel } attach_pkt_t; 224*1708Sstevel 225*1708Sstevel extern uint64_t *sbdp_valp; 226*1708Sstevel 227*1708Sstevel sbdp_sr_handle_t *sbdp_get_sr_handle(void); 228*1708Sstevel void sbdp_release_sr_handle(sbdp_sr_handle_t *); 229*1708Sstevel int sbdp_suspend(sbdp_sr_handle_t *); 230*1708Sstevel void sbdp_resume(sbdp_sr_handle_t *); 231*1708Sstevel void sbdp_set_err(sbd_error_t *ep, int ecode, char *rsc); 232*1708Sstevel int sbdp_is_node_bad(pnode_t); 233*1708Sstevel void sbdp_walk_prom_tree(pnode_t, int(*)(pnode_t, void *, uint_t), void *); 234*1708Sstevel int sbdp_detach_bd(int node, int board, sbd_error_t *sep); 235*1708Sstevel void sbdp_attach_bd(int, int); 236*1708Sstevel int sbdp_get_bd_and_wnode_num(pnode_t, int *, int *); 237*1708Sstevel void sbdp_update_bd_info(sbdp_bd_t *); 238*1708Sstevel sbdp_bd_t *sbdp_get_bd_info(int, int); 239*1708Sstevel int sbdp_make_bd_mem_contigous(int); 240*1708Sstevel sbd_cond_t sbdp_get_comp_status(pnode_t); 241*1708Sstevel void sbdp_init_bd_banks(sbdp_bd_t *); 242*1708Sstevel void sbdp_swap_list_of_banks(sbdp_bd_t *, sbdp_bd_t *); 243*1708Sstevel void sbdp_fini_bd_banks(sbdp_bd_t *); 244*1708Sstevel void sbdp_print_bd_banks(sbdp_bd_t *); 245*1708Sstevel void sbdp_add_new_bd_info(int, int); 246*1708Sstevel void sbdp_cleanup_bd(int, int); 247*1708Sstevel void sbdp_cpu_in_reset(int, int, int, int); 248*1708Sstevel int sbdp_is_cpu_in_reset(int, int, int); 249*1708Sstevel int sbdp_set_cpu_present(int, int, int); 250*1708Sstevel int sbdp_is_cpu_present(int, int, int); 251*1708Sstevel int sbdp_swap_slices(int, int); 252*1708Sstevel #ifdef DEBUG 253*1708Sstevel void sbdp_print_all_segs(void); 254*1708Sstevel int sbdp_passthru_test_quiesce(sbdp_handle_t *hp, void *); 255*1708Sstevel #endif 256*1708Sstevel int sbdp_select_top_nodes(pnode_t, void *, uint_t); 257*1708Sstevel pnode_t sbdp_find_nearby_cpu_by_portid(pnode_t, processorid_t); 258*1708Sstevel int sbdp_board_non_panther_cpus(int, int); 259*1708Sstevel 260*1708Sstevel #ifdef __cplusplus 261*1708Sstevel } 262*1708Sstevel #endif 263*1708Sstevel 264*1708Sstevel #endif /* _SBDP_PRIV_H */ 265