70025d765b044c6d8594bb965a2247a61e991a99johnny/*
70025d765b044c6d8594bb965a2247a61e991a99johnny * CDDL HEADER START
70025d765b044c6d8594bb965a2247a61e991a99johnny *
70025d765b044c6d8594bb965a2247a61e991a99johnny * The contents of this file are subject to the terms of the
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet * Common Development and Distribution License (the "License").
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet * You may not use this file except in compliance with the License.
70025d765b044c6d8594bb965a2247a61e991a99johnny *
70025d765b044c6d8594bb965a2247a61e991a99johnny * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
70025d765b044c6d8594bb965a2247a61e991a99johnny * or http://www.opensolaris.org/os/licensing.
70025d765b044c6d8594bb965a2247a61e991a99johnny * See the License for the specific language governing permissions
70025d765b044c6d8594bb965a2247a61e991a99johnny * and limitations under the License.
70025d765b044c6d8594bb965a2247a61e991a99johnny *
70025d765b044c6d8594bb965a2247a61e991a99johnny * When distributing Covered Code, include this CDDL HEADER in each
70025d765b044c6d8594bb965a2247a61e991a99johnny * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
70025d765b044c6d8594bb965a2247a61e991a99johnny * If applicable, add the following below this CDDL HEADER, with the
70025d765b044c6d8594bb965a2247a61e991a99johnny * fields enclosed by brackets "[]" replaced with your own identifying
70025d765b044c6d8594bb965a2247a61e991a99johnny * information: Portions Copyright [yyyy] [name of copyright owner]
70025d765b044c6d8594bb965a2247a61e991a99johnny *
70025d765b044c6d8594bb965a2247a61e991a99johnny * CDDL HEADER END
70025d765b044c6d8594bb965a2247a61e991a99johnny */
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny/*
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
70025d765b044c6d8594bb965a2247a61e991a99johnny * Use is subject to license terms.
70025d765b044c6d8594bb965a2247a61e991a99johnny */
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny#ifndef _PCI_PCI_COMMON_H
70025d765b044c6d8594bb965a2247a61e991a99johnny#define _PCI_PCI_COMMON_H
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny#ifdef __cplusplus
70025d765b044c6d8594bb965a2247a61e991a99johnnyextern "C" {
70025d765b044c6d8594bb965a2247a61e991a99johnny#endif
70025d765b044c6d8594bb965a2247a61e991a99johnny
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish/*
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish * Common header file with definitions shared between
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish * pci(7d) and npe(7d)
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish */
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish
7a364d25fde47aa82704b12b5251bf7fac37f02eschwartz/* State structure. */
7a364d25fde47aa82704b12b5251bf7fac37f02eschwartztypedef struct pci_state {
7a364d25fde47aa82704b12b5251bf7fac37f02eschwartz dev_info_t *pci_dip;
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet int pci_fmcap;
269473047d747f7815af570197e4ef7322d3632cEvan Yan uint_t pci_soft_state;
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet ddi_iblock_cookie_t pci_fm_ibc;
269473047d747f7815af570197e4ef7322d3632cEvan Yan kmutex_t pci_mutex;
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet kmutex_t pci_peek_poke_mutex;
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet kmutex_t pci_err_mutex;
7a364d25fde47aa82704b12b5251bf7fac37f02eschwartz} pci_state_t;
70025d765b044c6d8594bb965a2247a61e991a99johnny
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish/*
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish * These are the access routines.
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish * The pci_bus_map sets the handle to point to these in pci(7d).
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish * The npe_bus_map sets the handle to point to these in npe(7d).
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish */
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishuint8_t pci_config_rd8(ddi_acc_impl_t *hdlp, uint8_t *addr);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishuint16_t pci_config_rd16(ddi_acc_impl_t *hdlp, uint16_t *addr);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishuint32_t pci_config_rd32(ddi_acc_impl_t *hdlp, uint32_t *addr);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishuint64_t pci_config_rd64(ddi_acc_impl_t *hdlp, uint64_t *addr);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_wr8(ddi_acc_impl_t *hdlp, uint8_t *addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint8_t value);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_wr16(ddi_acc_impl_t *hdlp, uint16_t *addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint16_t value);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_wr32(ddi_acc_impl_t *hdlp, uint32_t *addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint32_t value);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_wr64(ddi_acc_impl_t *hdlp, uint64_t *addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint64_t value);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_rd8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint8_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_rd16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint16_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_rd32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint32_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_rd64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint64_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_wr8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint8_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_wr16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint16_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_wr32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint32_t *dev_addr, size_t repcount, uint_t flags);
649d4cce0c8ba57f2c399df82be95a0395cfeef2anishvoid pci_config_rep_wr64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
649d4cce0c8ba57f2c399df82be95a0395cfeef2anish uint64_t *dev_addr, size_t repcount, uint_t flags);
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny/*
70025d765b044c6d8594bb965a2247a61e991a99johnny * PCI tool related declarations
70025d765b044c6d8594bb965a2247a61e991a99johnny */
70025d765b044c6d8594bb965a2247a61e991a99johnnyint pci_common_ioctl(dev_info_t *dip, dev_t dev, int cmd,
70025d765b044c6d8594bb965a2247a61e991a99johnny intptr_t arg, int mode, cred_t *credp, int *rvalp);
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny/*
70025d765b044c6d8594bb965a2247a61e991a99johnny * Interrupt related declaration
70025d765b044c6d8594bb965a2247a61e991a99johnny */
70025d765b044c6d8594bb965a2247a61e991a99johnnyint pci_common_intr_ops(dev_info_t *, dev_info_t *, ddi_intr_op_t,
70025d765b044c6d8594bb965a2247a61e991a99johnny ddi_intr_handle_impl_t *, void *);
70025d765b044c6d8594bb965a2247a61e991a99johnnyvoid pci_common_set_parent_private_data(dev_info_t *);
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny/*
70025d765b044c6d8594bb965a2247a61e991a99johnny * Miscellaneous library functions
70025d765b044c6d8594bb965a2247a61e991a99johnny */
70025d765b044c6d8594bb965a2247a61e991a99johnnyint pci_common_get_reg_prop(dev_info_t *dip, pci_regspec_t *pci_rp);
70025d765b044c6d8594bb965a2247a61e991a99johnnyint pci_common_name_child(dev_info_t *child, char *name, int namelen);
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreetint pci_common_peekpoke(dev_info_t *dip, dev_info_t *rdip,
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreet ddi_ctl_enum_t ctlop, void *arg, void *result);
00d0963faf2e861a4aef6b1bf28f99a5b2b20755dilpreetint pci_fm_acc_setup(ddi_acc_hdl_t *hp, off_t offset, off_t len);
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny#ifdef __cplusplus
70025d765b044c6d8594bb965a2247a61e991a99johnny}
70025d765b044c6d8594bb965a2247a61e991a99johnny#endif
70025d765b044c6d8594bb965a2247a61e991a99johnny
70025d765b044c6d8594bb965a2247a61e991a99johnny#endif /* _PCI_PCI_COMMON_H */