xref: /illumos-gate/usr/src/uts/i86pc/io/pci/pci_common.h (revision 0f1702c5201310f0529cd5abb77652e5e9b241b6)
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 2008 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 	ddi_iblock_cookie_t pci_fm_ibc;
44 	kmutex_t pci_peek_poke_mutex;
45 	kmutex_t pci_err_mutex;
46 } pci_state_t;
47 
48 /*
49  * These are the access routines.
50  * The pci_bus_map sets the handle to point to these in pci(7d).
51  * The npe_bus_map sets the handle to point to these in npe(7d).
52  */
53 uint8_t		pci_config_rd8(ddi_acc_impl_t *hdlp, uint8_t *addr);
54 uint16_t	pci_config_rd16(ddi_acc_impl_t *hdlp, uint16_t *addr);
55 uint32_t	pci_config_rd32(ddi_acc_impl_t *hdlp, uint32_t *addr);
56 uint64_t	pci_config_rd64(ddi_acc_impl_t *hdlp, uint64_t *addr);
57 
58 void		pci_config_wr8(ddi_acc_impl_t *hdlp, uint8_t *addr,
59 		    uint8_t value);
60 void		pci_config_wr16(ddi_acc_impl_t *hdlp, uint16_t *addr,
61 		    uint16_t value);
62 void		pci_config_wr32(ddi_acc_impl_t *hdlp, uint32_t *addr,
63 		    uint32_t value);
64 void		pci_config_wr64(ddi_acc_impl_t *hdlp, uint64_t *addr,
65 		    uint64_t value);
66 
67 void		pci_config_rep_rd8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
68 		    uint8_t *dev_addr, size_t repcount, uint_t flags);
69 void		pci_config_rep_rd16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
70 		    uint16_t *dev_addr, size_t repcount, uint_t flags);
71 void		pci_config_rep_rd32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
72 		    uint32_t *dev_addr, size_t repcount, uint_t flags);
73 void		pci_config_rep_rd64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
74 		    uint64_t *dev_addr, size_t repcount, uint_t flags);
75 
76 void		pci_config_rep_wr8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
77 		    uint8_t *dev_addr, size_t repcount, uint_t flags);
78 void		pci_config_rep_wr16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
79 		    uint16_t *dev_addr, size_t repcount, uint_t flags);
80 void		pci_config_rep_wr32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
81 		    uint32_t *dev_addr, size_t repcount, uint_t flags);
82 void		pci_config_rep_wr64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
83 		    uint64_t *dev_addr, size_t repcount, uint_t flags);
84 
85 /*
86  * PCI tool related declarations
87  */
88 int	pci_common_ioctl(dev_info_t *dip, dev_t dev, int cmd,
89 	    intptr_t arg, int mode, cred_t *credp, int *rvalp);
90 
91 /*
92  * Interrupt related declaration
93  */
94 int	pci_common_intr_ops(dev_info_t *, dev_info_t *, ddi_intr_op_t,
95 	    ddi_intr_handle_impl_t *, void *);
96 void	pci_common_set_parent_private_data(dev_info_t *);
97 
98 /*
99  * Miscellaneous library functions
100  */
101 int	pci_common_get_reg_prop(dev_info_t *dip, pci_regspec_t *pci_rp);
102 int	pci_common_name_child(dev_info_t *child, char *name, int namelen);
103 int	pci_common_peekpoke(dev_info_t *dip, dev_info_t *rdip,
104 	ddi_ctl_enum_t ctlop, void *arg, void *result);
105 int	pci_fm_acc_setup(ddi_acc_hdl_t *hp, off_t offset, off_t len);
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif	/* _PCI_PCI_COMMON_H */
112