pci_cap.h revision 27255037bba8df933008f7bd2112201bef2e2429
27255037bba8df933008f7bd2112201bef2e2429pjha * CDDL HEADER START
27255037bba8df933008f7bd2112201bef2e2429pjha * The contents of this file are subject to the terms of the
27255037bba8df933008f7bd2112201bef2e2429pjha * Common Development and Distribution License (the "License").
27255037bba8df933008f7bd2112201bef2e2429pjha * You may not use this file except in compliance with the License.
27255037bba8df933008f7bd2112201bef2e2429pjha * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
27255037bba8df933008f7bd2112201bef2e2429pjha * See the License for the specific language governing permissions
27255037bba8df933008f7bd2112201bef2e2429pjha * and limitations under the License.
27255037bba8df933008f7bd2112201bef2e2429pjha * When distributing Covered Code, include this CDDL HEADER in each
27255037bba8df933008f7bd2112201bef2e2429pjha * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
27255037bba8df933008f7bd2112201bef2e2429pjha * If applicable, add the following below this CDDL HEADER, with the
27255037bba8df933008f7bd2112201bef2e2429pjha * fields enclosed by brackets "[]" replaced with your own identifying
27255037bba8df933008f7bd2112201bef2e2429pjha * information: Portions Copyright [yyyy] [name of copyright owner]
27255037bba8df933008f7bd2112201bef2e2429pjha * CDDL HEADER END
27255037bba8df933008f7bd2112201bef2e2429pjha * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27255037bba8df933008f7bd2112201bef2e2429pjha * Use is subject to license terms.
27255037bba8df933008f7bd2112201bef2e2429pjha#pragma ident "%Z%%M% %I% %E% SMI"
27255037bba8df933008f7bd2112201bef2e2429pjhaextern "C" {
27255037bba8df933008f7bd2112201bef2e2429pjha#define PCI_CAP_XCFG_FLAG (1u << PCI_CAP_XCFG_FLAG_SHIFT)
27255037bba8df933008f7bd2112201bef2e2429pjha/* Function Prototypes */
27255037bba8df933008f7bd2112201bef2e2429pjhaint pci_xcap_locate(ddi_acc_handle_t h, uint16_t id, uint16_t *base_p);
27255037bba8df933008f7bd2112201bef2e2429pjhaint pci_lcap_locate(ddi_acc_handle_t h, uint8_t id, uint16_t *base_p);
27255037bba8df933008f7bd2112201bef2e2429pjha/* Extract the lower 16 bits Extended CFG SPACE */
27255037bba8df933008f7bd2112201bef2e2429pjha/* Extract the lower 8 bits Extended CFG SPACE */
27255037bba8df933008f7bd2112201bef2e2429pjha#define PCI_CAP_XCFG_SPC(i) ((i) ? (i) | PCI_CAP_XCFG_FLAG : 0)
27255037bba8df933008f7bd2112201bef2e2429pjha#define PCI_CAP_DBG _NOTE(CONSTANTCONDITION) if (0) printf
27255037bba8df933008f7bd2112201bef2e2429pjha#endif /* DEBUG */
27255037bba8df933008f7bd2112201bef2e2429pjha * Supported Config Size Reads/Writes
27255037bba8df933008f7bd2112201bef2e2429pjhatypedef enum {
27255037bba8df933008f7bd2112201bef2e2429pjha/* Define Macros */
27255037bba8df933008f7bd2112201bef2e2429pjha#define PCI_CAP_LOCATE(h, id, base_p) ((id) & PCI_CAP_XCFG_FLAG ? \
27255037bba8df933008f7bd2112201bef2e2429pjha pci_xcap_locate(h, (uint16_t)((id) & PCI_CAP_XID_MASK), base_p) : \
27255037bba8df933008f7bd2112201bef2e2429pjha pci_lcap_locate(h, (uint8_t)((id) & PCI_CAP_ID_MASK), base_p))
27255037bba8df933008f7bd2112201bef2e2429pjha pci_cap_get(h, PCI_CAP_CFGSZ_8, PCI_CAP_XCFG_SPC(i), b, o))
27255037bba8df933008f7bd2112201bef2e2429pjha pci_cap_get(h, PCI_CAP_CFGSZ_16, PCI_CAP_XCFG_SPC(i), b, o))
27255037bba8df933008f7bd2112201bef2e2429pjha pci_cap_get(h, PCI_CAP_CFGSZ_32, PCI_CAP_XCFG_SPC(i), b, o))
27255037bba8df933008f7bd2112201bef2e2429pjha pci_cap_put(h, PCI_CAP_CFGSZ_8, PCI_CAP_XCFG_SPC(i), b, o, d))
27255037bba8df933008f7bd2112201bef2e2429pjha pci_cap_put(h, PCI_CAP_CFGSZ_16, PCI_CAP_XCFG_SPC(i), b, o, d))
27255037bba8df933008f7bd2112201bef2e2429pjha pci_cap_put(h, PCI_CAP_CFGSZ_32, PCI_CAP_XCFG_SPC(i), b, o, d))
27255037bba8df933008f7bd2112201bef2e2429pjhaextern int pci_cap_probe(ddi_acc_handle_t h, uint16_t index,
27255037bba8df933008f7bd2112201bef2e2429pjhaextern uint32_t pci_cap_get(ddi_acc_handle_t h, pci_config_size_t size,
27255037bba8df933008f7bd2112201bef2e2429pjhaextern int pci_cap_put(ddi_acc_handle_t h, pci_config_size_t size,
27255037bba8df933008f7bd2112201bef2e2429pjha uint32_t id, uint16_t base, uint16_t offset, uint32_t data);
27255037bba8df933008f7bd2112201bef2e2429pjhaextern int pci_cap_read(ddi_acc_handle_t h, uint32_t id, uint16_t base,
27255037bba8df933008f7bd2112201bef2e2429pjhaextern void pci_cap_dump(uint32_t *buf_p, uint32_t nwords);
27255037bba8df933008f7bd2112201bef2e2429pjha#endif /* _SYS_PCI_CAP_H */