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 5*b8dc8477Sarutz * Common Development and Distribution License (the "License"). 6*b8dc8477Sarutz * 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*b8dc8477Sarutz * Copyright 2006 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_SBBCVAR_H 277c478bd9Sstevel@tonic-gate #define _SYS_SBBCVAR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate typedef struct sbbc_intr_map { 367c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_hi; 377c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_mid; 387c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_low; 397c478bd9Sstevel@tonic-gate uint32_t sbbc_intr; 407c478bd9Sstevel@tonic-gate uint32_t intr_ctlr_nodeid; 417c478bd9Sstevel@tonic-gate uint32_t ino; 427c478bd9Sstevel@tonic-gate }sbbc_intr_map_t; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate struct sbbc_intr_map_mask { 457c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_hi; 467c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_mid; 477c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_low; 487c478bd9Sstevel@tonic-gate uint32_t sbbc_intr; 497c478bd9Sstevel@tonic-gate }; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* sbbc intrspec for initializing its children. */ 527c478bd9Sstevel@tonic-gate struct sbbc_intrspec { 537c478bd9Sstevel@tonic-gate struct intrspec intr_spec; 547c478bd9Sstevel@tonic-gate dev_info_t *dip; /* Interrupt parent dip */ 557c478bd9Sstevel@tonic-gate uint32_t intr; /* for lookup */ 567c478bd9Sstevel@tonic-gate }; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * definition of sbbc child reg spec entry: 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate typedef struct { 627c478bd9Sstevel@tonic-gate uint32_t addr_hi; 637c478bd9Sstevel@tonic-gate uint32_t addr_low; 647c478bd9Sstevel@tonic-gate uint32_t size; 657c478bd9Sstevel@tonic-gate } sbbc_child_regspec_t; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* SBBC range entry */ 687c478bd9Sstevel@tonic-gate typedef struct sbbc_pci_rangespec { 697c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_hi; /* Child hi range address */ 707c478bd9Sstevel@tonic-gate uint32_t sbbc_phys_low; /* Child low range address */ 717c478bd9Sstevel@tonic-gate uint32_t pci_phys_hi; /* Parent hi rng addr */ 727c478bd9Sstevel@tonic-gate uint32_t pci_phys_mid; /* Parent mid rng addr */ 737c478bd9Sstevel@tonic-gate uint32_t pci_phys_low; /* Parent low rng addr */ 747c478bd9Sstevel@tonic-gate uint32_t rng_size; /* Range size */ 757c478bd9Sstevel@tonic-gate } sbbc_pci_rangespec_t; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate typedef int procid_t; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* Max. SBBC devices/children */ 807c478bd9Sstevel@tonic-gate #define MAX_SBBC_DEVICES 3 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* Only used for fixed or legacy interrupts */ 837c478bd9Sstevel@tonic-gate #define SBBC_INTR_STATE_DISABLE 0 /* disabled */ 847c478bd9Sstevel@tonic-gate #define SBBC_INTR_STATE_ENABLE 1 /* enabled */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate typedef struct sbbc_child_intr { 877c478bd9Sstevel@tonic-gate char *name; 887c478bd9Sstevel@tonic-gate uint_t inum; 897c478bd9Sstevel@tonic-gate uint_t status; 907c478bd9Sstevel@tonic-gate uint_t (*intr_handler)(); 917c478bd9Sstevel@tonic-gate caddr_t arg1; 927c478bd9Sstevel@tonic-gate caddr_t arg2; 937c478bd9Sstevel@tonic-gate } sbbc_child_intr_t; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate typedef struct sbbcsoft { 967c478bd9Sstevel@tonic-gate int instance; 977c478bd9Sstevel@tonic-gate int oflag; 987c478bd9Sstevel@tonic-gate uint_t myinumber; 997c478bd9Sstevel@tonic-gate dev_info_t *dip; /* device information */ 1007c478bd9Sstevel@tonic-gate pci_regspec_t *reg; 1017c478bd9Sstevel@tonic-gate int nreg; 1027c478bd9Sstevel@tonic-gate sbbc_pci_rangespec_t *rangep; 1037c478bd9Sstevel@tonic-gate int range_cnt; 1047c478bd9Sstevel@tonic-gate int range_len; 105*b8dc8477Sarutz struct sbbc_regs_map *pci_sbbc_map; /* SBBC Internal Registers */ 1067c478bd9Sstevel@tonic-gate ddi_acc_handle_t pci_sbbc_map_handle; 1077c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t sbbc_iblock_cookie; /* interrupt block cookie */ 1087c478bd9Sstevel@tonic-gate kmutex_t sbbc_intr_mutex; /* lock for interrupts */ 1097c478bd9Sstevel@tonic-gate sbbc_child_intr_t *child_intr[MAX_SBBC_DEVICES]; /* intr per device */ 1107c478bd9Sstevel@tonic-gate boolean_t suspended; /* TRUE if driver suspended */ 1117c478bd9Sstevel@tonic-gate kmutex_t umutex; /* lock for this structure */ 1127c478bd9Sstevel@tonic-gate } sbbcsoft_t; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #define TRUE 1 1157c478bd9Sstevel@tonic-gate #define FALSE 0 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #if defined(DEBUG) 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #define SBBC_DBG_ATTACH 0x1 1217c478bd9Sstevel@tonic-gate #define SBBC_DBG_DETACH 0x2 1227c478bd9Sstevel@tonic-gate #define SBBC_DBG_CTLOPS 0x4 1237c478bd9Sstevel@tonic-gate #define SBBC_DBG_INITCHILD 0x8 1247c478bd9Sstevel@tonic-gate #define SBBC_DBG_UNINITCHILD 0x10 1257c478bd9Sstevel@tonic-gate #define SBBC_DBG_BUSMAP 0x20 1267c478bd9Sstevel@tonic-gate #define SBBC_DBG_INTR 0x40 1277c478bd9Sstevel@tonic-gate #define SBBC_DBG_PCICONF 0x80 1287c478bd9Sstevel@tonic-gate #define SBBC_DBG_MAPRANGES 0x100 1297c478bd9Sstevel@tonic-gate #define SBBC_DBG_PROPERTIES 0x200 1307c478bd9Sstevel@tonic-gate #define SBBC_DBG_OPEN 0x400 1317c478bd9Sstevel@tonic-gate #define SBBC_DBG_CLOSE 0x800 1327c478bd9Sstevel@tonic-gate #define SBBC_DBG_IOCTL 0x1000 1337c478bd9Sstevel@tonic-gate #define SBBC_DBG_INTROPS 0x2000 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #define SBBC_DBG0(flag, dip, fmt) \ 1377c478bd9Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, 0, 0, 0, 0, 0); 1387c478bd9Sstevel@tonic-gate #define SBBC_DBG1(flag, dip, fmt, a1) \ 1397c478bd9Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0); 1407c478bd9Sstevel@tonic-gate #define SBBC_DBG2(flag, dip, fmt, a1, a2) \ 1417c478bd9Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0); 1427c478bd9Sstevel@tonic-gate #define SBBC_DBG3(flag, dip, fmt, a1, a2, a3) \ 1437c478bd9Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1447c478bd9Sstevel@tonic-gate (uintptr_t)(a3), 0, 0); 1457c478bd9Sstevel@tonic-gate #define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) \ 1467c478bd9Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1477c478bd9Sstevel@tonic-gate (uintptr_t)(a3), (uintptr_t)(a4), 0); 1487c478bd9Sstevel@tonic-gate #define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) \ 1497c478bd9Sstevel@tonic-gate sbbc_dbg(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1507c478bd9Sstevel@tonic-gate (uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5)); 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #else /* DEBUG */ 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #define SBBC_DBG0(flag, dip, fmt) 1557c478bd9Sstevel@tonic-gate #define SBBC_DBG1(flag, dip, fmt, a1) 1567c478bd9Sstevel@tonic-gate #define SBBC_DBG2(flag, dip, fmt, a1, a2) 1577c478bd9Sstevel@tonic-gate #define SBBC_DBG3(flag, dip, fmt, a1, a2, a3) 1587c478bd9Sstevel@tonic-gate #define SBBC_DBG4(flag, dip, fmt, a1, a2, a3, a4) 1597c478bd9Sstevel@tonic-gate #define SBBC_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5) 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* debugging flags */ 1647c478bd9Sstevel@tonic-gate /* 1657c478bd9Sstevel@tonic-gate * To enable tracing, uncomment this line: 1667c478bd9Sstevel@tonic-gate * #define SBBC_TRACE 1 1677c478bd9Sstevel@tonic-gate */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #if defined(SBBC_TRACE) 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate #ifndef NSBBCTRACE 1727c478bd9Sstevel@tonic-gate #define NSBBCTRACE 1024 1737c478bd9Sstevel@tonic-gate #endif 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate struct sbbctrace { 1767c478bd9Sstevel@tonic-gate int count; 1777c478bd9Sstevel@tonic-gate int function; /* address of function */ 1787c478bd9Sstevel@tonic-gate int trace_action; /* descriptive 4 characters */ 1797c478bd9Sstevel@tonic-gate int object; /* object operated on */ 1807c478bd9Sstevel@tonic-gate }; 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * For debugging, allocate space for the trace buffer 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate extern struct sbbctrace sbbctrace_buffer[]; 1877c478bd9Sstevel@tonic-gate extern struct sbbctrace *sbbctrace_ptr; 1887c478bd9Sstevel@tonic-gate extern int sbbctrace_count; 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate #define SBBCTRACEINIT() { \ 1917c478bd9Sstevel@tonic-gate if (sbbctrace_ptr == NULL) \ 1927c478bd9Sstevel@tonic-gate sbbctrace_ptr = sbbctrace_buffer; \ 1937c478bd9Sstevel@tonic-gate } 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate #define LOCK_TRACE() (uint_t)ddi_enter_critical() 1967c478bd9Sstevel@tonic-gate #define UNLOCK_TRACE(x) ddi_exit_critical((uint_t)x) 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate #define SBBCTRACE(func, act, obj) { \ 1997c478bd9Sstevel@tonic-gate int __s = LOCK_TRACE(); \ 2007c478bd9Sstevel@tonic-gate int *_p = &sbbctrace_ptr->count; \ 2017c478bd9Sstevel@tonic-gate *_p++ = ++sbbctrace_count; \ 2027c478bd9Sstevel@tonic-gate *_p++ = (int)(func); \ 2037c478bd9Sstevel@tonic-gate *_p++ = (int)(act); \ 2047c478bd9Sstevel@tonic-gate *_p++ = (int)(obj); \ 2057c478bd9Sstevel@tonic-gate if ((struct sbbctrace *)(void *)_p >= &sbbctrace_buffer[NSBBCTRACE])\ 2067c478bd9Sstevel@tonic-gate sbbctrace_ptr = sbbctrace_buffer; \ 2077c478bd9Sstevel@tonic-gate else \ 2087c478bd9Sstevel@tonic-gate sbbctrace_ptr = (struct sbbctrace *)(void *)_p; \ 2097c478bd9Sstevel@tonic-gate UNLOCK_TRACE(__s); \ 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #else /* !SBBC_TRACE */ 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate /* If no tracing, define no-ops */ 2157c478bd9Sstevel@tonic-gate #define SBBCTRACEINIT() 2167c478bd9Sstevel@tonic-gate #define SBBCTRACE(a, b, c) 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate #endif /* !SBBC_TRACE */ 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2217c478bd9Sstevel@tonic-gate } 2227c478bd9Sstevel@tonic-gate #endif 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate #endif /* _SYS_SBBCVAR_H */ 225