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 5*2536Sarutz * Common Development and Distribution License (the "License"). 6*2536Sarutz * 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*2536Sarutz * Copyright 2006 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_SBBCVAR_H 270Sstevel@tonic-gate #define _SYS_SBBCVAR_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate typedef struct sbbc_intr_map { 360Sstevel@tonic-gate uint32_t sbbc_phys_hi; 370Sstevel@tonic-gate uint32_t sbbc_phys_mid; 380Sstevel@tonic-gate uint32_t sbbc_phys_low; 390Sstevel@tonic-gate uint32_t sbbc_intr; 400Sstevel@tonic-gate uint32_t intr_ctlr_nodeid; 410Sstevel@tonic-gate uint32_t ino; 420Sstevel@tonic-gate }sbbc_intr_map_t; 430Sstevel@tonic-gate 440Sstevel@tonic-gate struct sbbc_intr_map_mask { 450Sstevel@tonic-gate uint32_t sbbc_phys_hi; 460Sstevel@tonic-gate uint32_t sbbc_phys_mid; 470Sstevel@tonic-gate uint32_t sbbc_phys_low; 480Sstevel@tonic-gate uint32_t sbbc_intr; 490Sstevel@tonic-gate }; 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* sbbc intrspec for initializing its children. */ 520Sstevel@tonic-gate struct sbbc_intrspec { 530Sstevel@tonic-gate struct intrspec intr_spec; 540Sstevel@tonic-gate dev_info_t *dip; /* Interrupt parent dip */ 550Sstevel@tonic-gate uint32_t intr; /* for lookup */ 560Sstevel@tonic-gate }; 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* 590Sstevel@tonic-gate * definition of sbbc child reg spec entry: 600Sstevel@tonic-gate */ 610Sstevel@tonic-gate typedef struct { 620Sstevel@tonic-gate uint32_t addr_hi; 630Sstevel@tonic-gate uint32_t addr_low; 640Sstevel@tonic-gate uint32_t size; 650Sstevel@tonic-gate } sbbc_child_regspec_t; 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* SBBC range entry */ 680Sstevel@tonic-gate typedef struct sbbc_pci_rangespec { 690Sstevel@tonic-gate uint32_t sbbc_phys_hi; /* Child hi range address */ 700Sstevel@tonic-gate uint32_t sbbc_phys_low; /* Child low range address */ 710Sstevel@tonic-gate uint32_t pci_phys_hi; /* Parent hi rng addr */ 720Sstevel@tonic-gate uint32_t pci_phys_mid; /* Parent mid rng addr */ 730Sstevel@tonic-gate uint32_t pci_phys_low; /* Parent low rng addr */ 740Sstevel@tonic-gate uint32_t rng_size; /* Range size */ 750Sstevel@tonic-gate } sbbc_pci_rangespec_t; 760Sstevel@tonic-gate 770Sstevel@tonic-gate typedef int procid_t; 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* Max. SBBC devices/children */ 800Sstevel@tonic-gate #define MAX_SBBC_DEVICES 3 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* Only used for fixed or legacy interrupts */ 830Sstevel@tonic-gate #define SBBC_INTR_STATE_DISABLE 0 /* disabled */ 840Sstevel@tonic-gate #define SBBC_INTR_STATE_ENABLE 1 /* enabled */ 850Sstevel@tonic-gate 860Sstevel@tonic-gate typedef struct sbbc_child_intr { 870Sstevel@tonic-gate char *name; 880Sstevel@tonic-gate uint_t inum; 890Sstevel@tonic-gate uint_t status; 900Sstevel@tonic-gate uint_t (*intr_handler)(); 910Sstevel@tonic-gate caddr_t arg1; 920Sstevel@tonic-gate caddr_t arg2; 930Sstevel@tonic-gate } sbbc_child_intr_t; 940Sstevel@tonic-gate 950Sstevel@tonic-gate typedef struct sbbcsoft { 960Sstevel@tonic-gate int instance; 970Sstevel@tonic-gate int oflag; 980Sstevel@tonic-gate uint_t myinumber; 990Sstevel@tonic-gate dev_info_t *dip; /* device information */ 1000Sstevel@tonic-gate pci_regspec_t *reg; 1010Sstevel@tonic-gate int nreg; 1020Sstevel@tonic-gate sbbc_pci_rangespec_t *rangep; 1030Sstevel@tonic-gate int range_cnt; 1040Sstevel@tonic-gate int range_len; 105*2536Sarutz struct sbbc_regs_map *pci_sbbc_map; /* SBBC Internal Registers */ 1060Sstevel@tonic-gate ddi_acc_handle_t pci_sbbc_map_handle; 1070Sstevel@tonic-gate ddi_iblock_cookie_t sbbc_iblock_cookie; /* interrupt block cookie */ 1080Sstevel@tonic-gate kmutex_t sbbc_intr_mutex; /* lock for interrupts */ 1090Sstevel@tonic-gate sbbc_child_intr_t *child_intr[MAX_SBBC_DEVICES]; /* intr per device */ 1100Sstevel@tonic-gate boolean_t suspended; /* TRUE if driver suspended */ 1110Sstevel@tonic-gate kmutex_t umutex; /* lock for this structure */ 1120Sstevel@tonic-gate } sbbcsoft_t; 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define TRUE 1 1150Sstevel@tonic-gate #define FALSE 0 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate #if defined(DEBUG) 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate #define SBBC_DBG_ATTACH 0x1 1210Sstevel@tonic-gate #define SBBC_DBG_DETACH 0x2 1220Sstevel@tonic-gate #define SBBC_DBG_CTLOPS 0x4 1230Sstevel@tonic-gate #define SBBC_DBG_INITCHILD 0x8 1240Sstevel@tonic-gate #define SBBC_DBG_UNINITCHILD 0x10 1250Sstevel@tonic-gate #define SBBC_DBG_BUSMAP 0x20 1260Sstevel@tonic-gate #define SBBC_DBG_INTR 0x40 1270Sstevel@tonic-gate #define SBBC_DBG_PCICONF 0x80 1280Sstevel@tonic-gate #define SBBC_DBG_MAPRANGES 0x100 1290Sstevel@tonic-gate #define SBBC_DBG_PROPERTIES 0x200 1300Sstevel@tonic-gate #define SBBC_DBG_OPEN 0x400 1310Sstevel@tonic-gate #define SBBC_DBG_CLOSE 0x800 1320Sstevel@tonic-gate #define SBBC_DBG_IOCTL 0x1000 1330Sstevel@tonic-gate #define SBBC_DBG_INTROPS 0x2000 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate #define SBBC_DBG0(flag, dip, fmt) \ 1370Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, 0, 0, 0, 0, 0); 1380Sstevel@tonic-gate #define SBBC_DBG1(flag, dip, fmt, a1) \ 1390Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0); 1400Sstevel@tonic-gate #define SBBC_DBG2(flag, dip, fmt, a1, a2) \ 1410Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0); 1420Sstevel@tonic-gate #define SBBC_DBG3(flag, dip, fmt, a1, a2, a3) \ 1430Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1440Sstevel@tonic-gate (uintptr_t)(a3), 0, 0); 1450Sstevel@tonic-gate #define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) \ 1460Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1470Sstevel@tonic-gate (uintptr_t)(a3), (uintptr_t)(a4), 0); 1480Sstevel@tonic-gate #define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) \ 1490Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1500Sstevel@tonic-gate (uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5)); 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate #else /* DEBUG */ 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate #define SBBC_DBG0(flag, dip, fmt) 1550Sstevel@tonic-gate #define SBBC_DBG1(flag, dip, fmt, a1) 1560Sstevel@tonic-gate #define SBBC_DBG2(flag, dip, fmt, a1, a2) 1570Sstevel@tonic-gate #define SBBC_DBG3(flag, dip, fmt, a1, a2, a3) 1580Sstevel@tonic-gate #define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) 1590Sstevel@tonic-gate #define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate #endif /* DEBUG */ 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* debugging flags */ 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * To enable tracing, uncomment this line: 1660Sstevel@tonic-gate * #define SBBC_TRACE 1 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate #if defined(SBBC_TRACE) 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate #ifndef NSBBCTRACE 1720Sstevel@tonic-gate #define NSBBCTRACE 1024 1730Sstevel@tonic-gate #endif 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate struct sbbctrace { 1760Sstevel@tonic-gate int count; 1770Sstevel@tonic-gate int function; /* address of function */ 1780Sstevel@tonic-gate int trace_action; /* descriptive 4 characters */ 1790Sstevel@tonic-gate int object; /* object operated on */ 1800Sstevel@tonic-gate }; 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate /* 1830Sstevel@tonic-gate * For debugging, allocate space for the trace buffer 1840Sstevel@tonic-gate */ 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate extern struct sbbctrace sbbctrace_buffer[]; 1870Sstevel@tonic-gate extern struct sbbctrace *sbbctrace_ptr; 1880Sstevel@tonic-gate extern int sbbctrace_count; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate #define SBBCTRACEINIT() { \ 1910Sstevel@tonic-gate if (sbbctrace_ptr == NULL) \ 1920Sstevel@tonic-gate sbbctrace_ptr = sbbctrace_buffer; \ 1930Sstevel@tonic-gate } 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate #define LOCK_TRACE() (uint_t)ddi_enter_critical() 1960Sstevel@tonic-gate #define UNLOCK_TRACE(x) ddi_exit_critical((uint_t)x) 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate #define SBBCTRACE(func, act, obj) { \ 1990Sstevel@tonic-gate int __s = LOCK_TRACE(); \ 2000Sstevel@tonic-gate int *_p = &sbbctrace_ptr->count; \ 2010Sstevel@tonic-gate *_p++ = ++sbbctrace_count; \ 2020Sstevel@tonic-gate *_p++ = (int)(func); \ 2030Sstevel@tonic-gate *_p++ = (int)(act); \ 2040Sstevel@tonic-gate *_p++ = (int)(obj); \ 2050Sstevel@tonic-gate if ((struct sbbctrace *)(void *)_p >= &sbbctrace_buffer[NSBBCTRACE])\ 2060Sstevel@tonic-gate sbbctrace_ptr = sbbctrace_buffer; \ 2070Sstevel@tonic-gate else \ 2080Sstevel@tonic-gate sbbctrace_ptr = (struct sbbctrace *)(void *)_p; \ 2090Sstevel@tonic-gate UNLOCK_TRACE(__s); \ 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate #else /* !SBBC_TRACE */ 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate /* If no tracing, define no-ops */ 2150Sstevel@tonic-gate #define SBBCTRACEINIT() 2160Sstevel@tonic-gate #define SBBCTRACE(a, b, c) 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate #endif /* !SBBC_TRACE */ 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate #ifdef __cplusplus 2210Sstevel@tonic-gate } 2220Sstevel@tonic-gate #endif 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate #endif /* _SYS_SBBCVAR_H */ 225