xref: /titanic_52/usr/src/uts/i86pc/io/pci/pci_common.h (revision 269473047d747f7815af570197e4ef7322d3632c)
170025d76Sjohnny /*
270025d76Sjohnny  * CDDL HEADER START
370025d76Sjohnny  *
470025d76Sjohnny  * The contents of this file are subject to the terms of the
500d0963fSdilpreet  * Common Development and Distribution License (the "License").
600d0963fSdilpreet  * You may not use this file except in compliance with the License.
770025d76Sjohnny  *
870025d76Sjohnny  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
970025d76Sjohnny  * or http://www.opensolaris.org/os/licensing.
1070025d76Sjohnny  * See the License for the specific language governing permissions
1170025d76Sjohnny  * and limitations under the License.
1270025d76Sjohnny  *
1370025d76Sjohnny  * When distributing Covered Code, include this CDDL HEADER in each
1470025d76Sjohnny  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1570025d76Sjohnny  * If applicable, add the following below this CDDL HEADER, with the
1670025d76Sjohnny  * fields enclosed by brackets "[]" replaced with your own identifying
1770025d76Sjohnny  * information: Portions Copyright [yyyy] [name of copyright owner]
1870025d76Sjohnny  *
1970025d76Sjohnny  * CDDL HEADER END
2070025d76Sjohnny  */
2170025d76Sjohnny 
2270025d76Sjohnny /*
23*26947304SEvan Yan  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2470025d76Sjohnny  * Use is subject to license terms.
2570025d76Sjohnny  */
2670025d76Sjohnny 
2770025d76Sjohnny #ifndef	_PCI_PCI_COMMON_H
2870025d76Sjohnny #define	_PCI_PCI_COMMON_H
2970025d76Sjohnny 
3070025d76Sjohnny #ifdef	__cplusplus
3170025d76Sjohnny extern "C" {
3270025d76Sjohnny #endif
3370025d76Sjohnny 
34649d4cceSanish /*
35649d4cceSanish  *	Common header file with definitions shared between
36649d4cceSanish  *	pci(7d) and npe(7d)
37649d4cceSanish  */
38649d4cceSanish 
397a364d25Sschwartz /* State structure. */
407a364d25Sschwartz typedef struct pci_state {
417a364d25Sschwartz 	dev_info_t *pci_dip;
4200d0963fSdilpreet 	int pci_fmcap;
43*26947304SEvan Yan 	uint_t pci_soft_state;
4400d0963fSdilpreet 	ddi_iblock_cookie_t pci_fm_ibc;
45*26947304SEvan Yan 	kmutex_t pci_mutex;
4600d0963fSdilpreet 	kmutex_t pci_peek_poke_mutex;
4700d0963fSdilpreet 	kmutex_t pci_err_mutex;
487a364d25Sschwartz } pci_state_t;
4970025d76Sjohnny 
50649d4cceSanish /*
51649d4cceSanish  * These are the access routines.
52649d4cceSanish  * The pci_bus_map sets the handle to point to these in pci(7d).
53649d4cceSanish  * The npe_bus_map sets the handle to point to these in npe(7d).
54649d4cceSanish  */
55649d4cceSanish uint8_t		pci_config_rd8(ddi_acc_impl_t *hdlp, uint8_t *addr);
56649d4cceSanish uint16_t	pci_config_rd16(ddi_acc_impl_t *hdlp, uint16_t *addr);
57649d4cceSanish uint32_t	pci_config_rd32(ddi_acc_impl_t *hdlp, uint32_t *addr);
58649d4cceSanish uint64_t	pci_config_rd64(ddi_acc_impl_t *hdlp, uint64_t *addr);
59649d4cceSanish 
60649d4cceSanish void		pci_config_wr8(ddi_acc_impl_t *hdlp, uint8_t *addr,
61649d4cceSanish 		    uint8_t value);
62649d4cceSanish void		pci_config_wr16(ddi_acc_impl_t *hdlp, uint16_t *addr,
63649d4cceSanish 		    uint16_t value);
64649d4cceSanish void		pci_config_wr32(ddi_acc_impl_t *hdlp, uint32_t *addr,
65649d4cceSanish 		    uint32_t value);
66649d4cceSanish void		pci_config_wr64(ddi_acc_impl_t *hdlp, uint64_t *addr,
67649d4cceSanish 		    uint64_t value);
68649d4cceSanish 
69649d4cceSanish void		pci_config_rep_rd8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
70649d4cceSanish 		    uint8_t *dev_addr, size_t repcount, uint_t flags);
71649d4cceSanish void		pci_config_rep_rd16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
72649d4cceSanish 		    uint16_t *dev_addr, size_t repcount, uint_t flags);
73649d4cceSanish void		pci_config_rep_rd32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
74649d4cceSanish 		    uint32_t *dev_addr, size_t repcount, uint_t flags);
75649d4cceSanish void		pci_config_rep_rd64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
76649d4cceSanish 		    uint64_t *dev_addr, size_t repcount, uint_t flags);
77649d4cceSanish 
78649d4cceSanish void		pci_config_rep_wr8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
79649d4cceSanish 		    uint8_t *dev_addr, size_t repcount, uint_t flags);
80649d4cceSanish void		pci_config_rep_wr16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
81649d4cceSanish 		    uint16_t *dev_addr, size_t repcount, uint_t flags);
82649d4cceSanish void		pci_config_rep_wr32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
83649d4cceSanish 		    uint32_t *dev_addr, size_t repcount, uint_t flags);
84649d4cceSanish void		pci_config_rep_wr64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
85649d4cceSanish 		    uint64_t *dev_addr, size_t repcount, uint_t flags);
8670025d76Sjohnny 
8770025d76Sjohnny /*
8870025d76Sjohnny  * PCI tool related declarations
8970025d76Sjohnny  */
9070025d76Sjohnny int	pci_common_ioctl(dev_info_t *dip, dev_t dev, int cmd,
9170025d76Sjohnny 	    intptr_t arg, int mode, cred_t *credp, int *rvalp);
9270025d76Sjohnny 
9370025d76Sjohnny /*
9470025d76Sjohnny  * Interrupt related declaration
9570025d76Sjohnny  */
9670025d76Sjohnny int	pci_common_intr_ops(dev_info_t *, dev_info_t *, ddi_intr_op_t,
9770025d76Sjohnny 	    ddi_intr_handle_impl_t *, void *);
9870025d76Sjohnny void	pci_common_set_parent_private_data(dev_info_t *);
9970025d76Sjohnny 
10070025d76Sjohnny /*
10170025d76Sjohnny  * Miscellaneous library functions
10270025d76Sjohnny  */
10370025d76Sjohnny int	pci_common_get_reg_prop(dev_info_t *dip, pci_regspec_t *pci_rp);
10470025d76Sjohnny int	pci_common_name_child(dev_info_t *child, char *name, int namelen);
10500d0963fSdilpreet int	pci_common_peekpoke(dev_info_t *dip, dev_info_t *rdip,
10600d0963fSdilpreet 	ddi_ctl_enum_t ctlop, void *arg, void *result);
10700d0963fSdilpreet int	pci_fm_acc_setup(ddi_acc_hdl_t *hp, off_t offset, off_t len);
10870025d76Sjohnny 
10970025d76Sjohnny #ifdef	__cplusplus
11070025d76Sjohnny }
11170025d76Sjohnny #endif
11270025d76Sjohnny 
11370025d76Sjohnny #endif	/* _PCI_PCI_COMMON_H */
114