1881Sjohnny /* 2881Sjohnny * CDDL HEADER START 3881Sjohnny * 4881Sjohnny * The contents of this file are subject to the terms of the 51865Sdilpreet * Common Development and Distribution License (the "License"). 61865Sdilpreet * You may not use this file except in compliance with the License. 7881Sjohnny * 8881Sjohnny * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9881Sjohnny * or http://www.opensolaris.org/os/licensing. 10881Sjohnny * See the License for the specific language governing permissions 11881Sjohnny * and limitations under the License. 12881Sjohnny * 13881Sjohnny * When distributing Covered Code, include this CDDL HEADER in each 14881Sjohnny * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15881Sjohnny * If applicable, add the following below this CDDL HEADER, with the 16881Sjohnny * fields enclosed by brackets "[]" replaced with your own identifying 17881Sjohnny * information: Portions Copyright [yyyy] [name of copyright owner] 18881Sjohnny * 19881Sjohnny * CDDL HEADER END 20881Sjohnny */ 21881Sjohnny 22881Sjohnny /* 23*10923SEvan.Yan@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24881Sjohnny * Use is subject to license terms. 25881Sjohnny */ 26881Sjohnny 27881Sjohnny #ifndef _PCI_PCI_COMMON_H 28881Sjohnny #define _PCI_PCI_COMMON_H 29881Sjohnny 30881Sjohnny #ifdef __cplusplus 31881Sjohnny extern "C" { 32881Sjohnny #endif 33881Sjohnny 341083Sanish /* 351083Sanish * Common header file with definitions shared between 361083Sanish * pci(7d) and npe(7d) 371083Sanish */ 381083Sanish 39916Sschwartz /* State structure. */ 40916Sschwartz typedef struct pci_state { 41916Sschwartz dev_info_t *pci_dip; 421865Sdilpreet int pci_fmcap; 43*10923SEvan.Yan@Sun.COM uint_t pci_soft_state; 441865Sdilpreet ddi_iblock_cookie_t pci_fm_ibc; 45*10923SEvan.Yan@Sun.COM kmutex_t pci_mutex; 461865Sdilpreet kmutex_t pci_peek_poke_mutex; 471865Sdilpreet kmutex_t pci_err_mutex; 48916Sschwartz } pci_state_t; 49881Sjohnny 501083Sanish /* 511083Sanish * These are the access routines. 521083Sanish * The pci_bus_map sets the handle to point to these in pci(7d). 531083Sanish * The npe_bus_map sets the handle to point to these in npe(7d). 54881Sjohnny */ 551083Sanish uint8_t pci_config_rd8(ddi_acc_impl_t *hdlp, uint8_t *addr); 561083Sanish uint16_t pci_config_rd16(ddi_acc_impl_t *hdlp, uint16_t *addr); 571083Sanish uint32_t pci_config_rd32(ddi_acc_impl_t *hdlp, uint32_t *addr); 581083Sanish uint64_t pci_config_rd64(ddi_acc_impl_t *hdlp, uint64_t *addr); 591083Sanish 601083Sanish void pci_config_wr8(ddi_acc_impl_t *hdlp, uint8_t *addr, 611083Sanish uint8_t value); 621083Sanish void pci_config_wr16(ddi_acc_impl_t *hdlp, uint16_t *addr, 631083Sanish uint16_t value); 641083Sanish void pci_config_wr32(ddi_acc_impl_t *hdlp, uint32_t *addr, 651083Sanish uint32_t value); 661083Sanish void pci_config_wr64(ddi_acc_impl_t *hdlp, uint64_t *addr, 671083Sanish uint64_t value); 681083Sanish 691083Sanish void pci_config_rep_rd8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, 701083Sanish uint8_t *dev_addr, size_t repcount, uint_t flags); 711083Sanish void pci_config_rep_rd16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, 721083Sanish uint16_t *dev_addr, size_t repcount, uint_t flags); 731083Sanish void pci_config_rep_rd32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, 741083Sanish uint32_t *dev_addr, size_t repcount, uint_t flags); 751083Sanish void pci_config_rep_rd64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, 761083Sanish uint64_t *dev_addr, size_t repcount, uint_t flags); 771083Sanish 781083Sanish void pci_config_rep_wr8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, 791083Sanish uint8_t *dev_addr, size_t repcount, uint_t flags); 801083Sanish void pci_config_rep_wr16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, 811083Sanish uint16_t *dev_addr, size_t repcount, uint_t flags); 821083Sanish void pci_config_rep_wr32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, 831083Sanish uint32_t *dev_addr, size_t repcount, uint_t flags); 841083Sanish void pci_config_rep_wr64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, 851083Sanish uint64_t *dev_addr, size_t repcount, uint_t flags); 86881Sjohnny 87881Sjohnny /* 88881Sjohnny * PCI tool related declarations 89881Sjohnny */ 90881Sjohnny int pci_common_ioctl(dev_info_t *dip, dev_t dev, int cmd, 91881Sjohnny intptr_t arg, int mode, cred_t *credp, int *rvalp); 92881Sjohnny 93881Sjohnny /* 94881Sjohnny * Interrupt related declaration 95881Sjohnny */ 96881Sjohnny int pci_common_intr_ops(dev_info_t *, dev_info_t *, ddi_intr_op_t, 97881Sjohnny ddi_intr_handle_impl_t *, void *); 98881Sjohnny void pci_common_set_parent_private_data(dev_info_t *); 99881Sjohnny 100881Sjohnny /* 101881Sjohnny * Miscellaneous library functions 102881Sjohnny */ 103881Sjohnny int pci_common_get_reg_prop(dev_info_t *dip, pci_regspec_t *pci_rp); 104881Sjohnny int pci_common_name_child(dev_info_t *child, char *name, int namelen); 1051865Sdilpreet int pci_common_peekpoke(dev_info_t *dip, dev_info_t *rdip, 1061865Sdilpreet ddi_ctl_enum_t ctlop, void *arg, void *result); 1071865Sdilpreet int pci_fm_acc_setup(ddi_acc_hdl_t *hp, off_t offset, off_t len); 108881Sjohnny 109881Sjohnny #ifdef __cplusplus 110881Sjohnny } 111881Sjohnny #endif 112881Sjohnny 113881Sjohnny #endif /* _PCI_PCI_COMMON_H */ 114