1*25cf1a30Sjl /* 2*25cf1a30Sjl * CDDL HEADER START 3*25cf1a30Sjl * 4*25cf1a30Sjl * The contents of this file are subject to the terms of the 5*25cf1a30Sjl * Common Development and Distribution License (the "License"). 6*25cf1a30Sjl * You may not use this file except in compliance with the License. 7*25cf1a30Sjl * 8*25cf1a30Sjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*25cf1a30Sjl * or http://www.opensolaris.org/os/licensing. 10*25cf1a30Sjl * See the License for the specific language governing permissions 11*25cf1a30Sjl * and limitations under the License. 12*25cf1a30Sjl * 13*25cf1a30Sjl * When distributing Covered Code, include this CDDL HEADER in each 14*25cf1a30Sjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*25cf1a30Sjl * If applicable, add the following below this CDDL HEADER, with the 16*25cf1a30Sjl * fields enclosed by brackets "[]" replaced with your own identifying 17*25cf1a30Sjl * information: Portions Copyright [yyyy] [name of copyright owner] 18*25cf1a30Sjl * 19*25cf1a30Sjl * CDDL HEADER END 20*25cf1a30Sjl */ 21*25cf1a30Sjl /* 22*25cf1a30Sjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*25cf1a30Sjl * Use is subject to license terms. 24*25cf1a30Sjl */ 25*25cf1a30Sjl 26*25cf1a30Sjl #ifndef _SYS_PCMU_UTIL_H 27*25cf1a30Sjl #define _SYS_PCMU_UTIL_H 28*25cf1a30Sjl 29*25cf1a30Sjl #pragma ident "%Z%%M% %I% %E% SMI" 30*25cf1a30Sjl 31*25cf1a30Sjl #ifdef __cplusplus 32*25cf1a30Sjl extern "C" { 33*25cf1a30Sjl #endif 34*25cf1a30Sjl 35*25cf1a30Sjl 36*25cf1a30Sjl /* 37*25cf1a30Sjl * Prototypes 38*25cf1a30Sjl */ 39*25cf1a30Sjl extern int pcmu_init_child(pcmu_t *, dev_info_t *); 40*25cf1a30Sjl extern int pcmu_uninit_child(pcmu_t *, dev_info_t *); 41*25cf1a30Sjl extern int pcmu_report_dev(dev_info_t *); 42*25cf1a30Sjl extern int get_pcmu_properties(pcmu_t *, dev_info_t *); 43*25cf1a30Sjl extern void free_pcmu_properties(pcmu_t *); 44*25cf1a30Sjl extern int pcmu_get_portid(dev_info_t *); 45*25cf1a30Sjl extern int pcmu_reloc_reg(dev_info_t *, dev_info_t *, pcmu_t *, 46*25cf1a30Sjl pci_regspec_t *); 47*25cf1a30Sjl extern int pcmu_xlate_reg(pcmu_t *, pci_regspec_t *, struct regspec *); 48*25cf1a30Sjl extern off_t pcmu_get_reg_set_size(dev_info_t *, int); 49*25cf1a30Sjl extern uint_t pcmu_get_nreg_set(dev_info_t *); 50*25cf1a30Sjl extern uint64_t pcmu_get_cfg_pabase(pcmu_t *); 51*25cf1a30Sjl extern int pcmu_cfg_report(dev_info_t *, ddi_fm_error_t *, 52*25cf1a30Sjl pcmu_errstate_t *, int, uint32_t); 53*25cf1a30Sjl 54*25cf1a30Sjl #ifdef DEBUG 55*25cf1a30Sjl 56*25cf1a30Sjl extern uint64_t pcmu_debug_flags; 57*25cf1a30Sjl 58*25cf1a30Sjl typedef struct pcmu_dflag_to_str { 59*25cf1a30Sjl uint64_t flag; 60*25cf1a30Sjl char *string; 61*25cf1a30Sjl } pcmu_dflag_to_str_t; 62*25cf1a30Sjl 63*25cf1a30Sjl #define PCMU_DBG_ATTACH 0x1ull 64*25cf1a30Sjl #define PCMU_DBG_DETACH 0x2ull 65*25cf1a30Sjl #define PCMU_DBG_MAP 0x4ull 66*25cf1a30Sjl #define PCMU_DBG_A_INTX 0x8ull 67*25cf1a30Sjl #define PCMU_DBG_R_INTX 0x10ull 68*25cf1a30Sjl #define PCMU_DBG_INIT_CLD 0x20ull 69*25cf1a30Sjl #define PCMU_DBG_CTLOPS 0x40ull 70*25cf1a30Sjl #define PCMU_DBG_INTR 0x80ull 71*25cf1a30Sjl #define PCMU_DBG_ERR_INTR 0x100ull 72*25cf1a30Sjl #define PCMU_DBG_BUS_FAULT 0x200ull 73*25cf1a30Sjl #define PCMU_DBG_IB (0x20ull << 32) 74*25cf1a30Sjl #define PCMU_DBG_CB (0x40ull << 32) 75*25cf1a30Sjl #define PCMU_DBG_PBM (0x80ull << 32) 76*25cf1a30Sjl #define PCMU_DBG_CONT (0x100ull << 32) 77*25cf1a30Sjl #define PCMU_DBG_OPEN (0x1000ull << 32) 78*25cf1a30Sjl #define PCMU_DBG_CLOSE (0x2000ull << 32) 79*25cf1a30Sjl #define PCMU_DBG_IOCTL (0x4000ull << 32) 80*25cf1a30Sjl #define PCMU_DBG_PWR (0x8000ull << 32) 81*25cf1a30Sjl 82*25cf1a30Sjl 83*25cf1a30Sjl #define PCMU_DBG0(flag, dip, fmt) \ 84*25cf1a30Sjl pcmu_debug(flag, dip, fmt, 0, 0, 0, 0, 0); 85*25cf1a30Sjl 86*25cf1a30Sjl #define PCMU_DBG1(flag, dip, fmt, a1) \ 87*25cf1a30Sjl pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0); 88*25cf1a30Sjl 89*25cf1a30Sjl #define PCMU_DBG2(flag, dip, fmt, a1, a2) \ 90*25cf1a30Sjl pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0); 91*25cf1a30Sjl 92*25cf1a30Sjl #define PCMU_DBG3(flag, dip, fmt, a1, a2, a3) \ 93*25cf1a30Sjl pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), \ 94*25cf1a30Sjl (uintptr_t)(a2), (uintptr_t)(a3), 0, 0); 95*25cf1a30Sjl 96*25cf1a30Sjl #define PCMU_DBG4(flag, dip, fmt, a1, a2, a3, a4) \ 97*25cf1a30Sjl pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), \ 98*25cf1a30Sjl (uintptr_t)(a2), (uintptr_t)(a3), \ 99*25cf1a30Sjl (uintptr_t)(a4), 0); 100*25cf1a30Sjl 101*25cf1a30Sjl #define PCMU_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) \ 102*25cf1a30Sjl pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), \ 103*25cf1a30Sjl (uintptr_t)(a2), (uintptr_t)(a3), \ 104*25cf1a30Sjl (uintptr_t)(a4), (uintptr_t)(a5)); 105*25cf1a30Sjl 106*25cf1a30Sjl extern void pcmu_debug(uint64_t, dev_info_t *, char *, 107*25cf1a30Sjl uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); 108*25cf1a30Sjl #else /* DEBUG */ 109*25cf1a30Sjl 110*25cf1a30Sjl #define PCMU_DBG0(flag, dip, fmt) 111*25cf1a30Sjl #define PCMU_DBG1(flag, dip, fmt, a1) 112*25cf1a30Sjl #define PCMU_DBG2(flag, dip, fmt, a1, a2) 113*25cf1a30Sjl #define PCMU_DBG3(flag, dip, fmt, a1, a2, a3) 114*25cf1a30Sjl #define PCMU_DBG4(flag, dip, fmt, a1, a2, a3, a4) 115*25cf1a30Sjl #define PCMU_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) 116*25cf1a30Sjl 117*25cf1a30Sjl #endif /* DEBUG */ 118*25cf1a30Sjl 119*25cf1a30Sjl #ifdef __cplusplus 120*25cf1a30Sjl } 121*25cf1a30Sjl #endif 122*25cf1a30Sjl 123*25cf1a30Sjl #endif /* _SYS_PCMU_UTIL_H */ 124