1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _PCI_PCI_COMMON_H 28 #define _PCI_PCI_COMMON_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * Common header file with definitions shared between 36 * pci(7d) and npe(7d) 37 */ 38 39 /* State structure. */ 40 typedef struct pci_state { 41 dev_info_t *pci_dip; 42 int pci_fmcap; 43 uint_t pci_soft_state; 44 ddi_iblock_cookie_t pci_fm_ibc; 45 kmutex_t pci_mutex; 46 kmutex_t pci_peek_poke_mutex; 47 kmutex_t pci_err_mutex; 48 } pci_state_t; 49 50 /* 51 * These are the access routines. 52 * The pci_bus_map sets the handle to point to these in pci(7d). 53 * The npe_bus_map sets the handle to point to these in npe(7d). 54 */ 55 uint8_t pci_config_rd8(ddi_acc_impl_t *hdlp, uint8_t *addr); 56 uint16_t pci_config_rd16(ddi_acc_impl_t *hdlp, uint16_t *addr); 57 uint32_t pci_config_rd32(ddi_acc_impl_t *hdlp, uint32_t *addr); 58 uint64_t pci_config_rd64(ddi_acc_impl_t *hdlp, uint64_t *addr); 59 60 void pci_config_wr8(ddi_acc_impl_t *hdlp, uint8_t *addr, 61 uint8_t value); 62 void pci_config_wr16(ddi_acc_impl_t *hdlp, uint16_t *addr, 63 uint16_t value); 64 void pci_config_wr32(ddi_acc_impl_t *hdlp, uint32_t *addr, 65 uint32_t value); 66 void pci_config_wr64(ddi_acc_impl_t *hdlp, uint64_t *addr, 67 uint64_t value); 68 69 void pci_config_rep_rd8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, 70 uint8_t *dev_addr, size_t repcount, uint_t flags); 71 void pci_config_rep_rd16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, 72 uint16_t *dev_addr, size_t repcount, uint_t flags); 73 void pci_config_rep_rd32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, 74 uint32_t *dev_addr, size_t repcount, uint_t flags); 75 void pci_config_rep_rd64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, 76 uint64_t *dev_addr, size_t repcount, uint_t flags); 77 78 void pci_config_rep_wr8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, 79 uint8_t *dev_addr, size_t repcount, uint_t flags); 80 void pci_config_rep_wr16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, 81 uint16_t *dev_addr, size_t repcount, uint_t flags); 82 void pci_config_rep_wr32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, 83 uint32_t *dev_addr, size_t repcount, uint_t flags); 84 void pci_config_rep_wr64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, 85 uint64_t *dev_addr, size_t repcount, uint_t flags); 86 87 /* 88 * PCI tool related declarations 89 */ 90 int pci_common_ioctl(dev_info_t *dip, dev_t dev, int cmd, 91 intptr_t arg, int mode, cred_t *credp, int *rvalp); 92 93 /* 94 * Interrupt related declaration 95 */ 96 int pci_common_intr_ops(dev_info_t *, dev_info_t *, ddi_intr_op_t, 97 ddi_intr_handle_impl_t *, void *); 98 void pci_common_set_parent_private_data(dev_info_t *); 99 100 /* 101 * Miscellaneous library functions 102 */ 103 int pci_common_get_reg_prop(dev_info_t *dip, pci_regspec_t *pci_rp); 104 int pci_common_name_child(dev_info_t *child, char *name, int namelen); 105 int pci_common_peekpoke(dev_info_t *dip, dev_info_t *rdip, 106 ddi_ctl_enum_t ctlop, void *arg, void *result); 107 int pci_fm_acc_setup(ddi_acc_hdl_t *hp, off_t offset, off_t len); 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #endif /* _PCI_PCI_COMMON_H */ 114