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.
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.
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]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _PCI_PCI_COMMON_H
28 #define _PCI_PCI_COMMON_H
35 * Common header file with definitions shared between
39 /* State structure. */
40 typedef struct pci_state
{
43 uint_t pci_soft_state
;
44 ddi_iblock_cookie_t pci_fm_ibc
;
46 kmutex_t pci_peek_poke_mutex
;
47 kmutex_t pci_err_mutex
;
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).
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
);
60 void pci_config_wr8(ddi_acc_impl_t
*hdlp
, uint8_t *addr
,
62 void pci_config_wr16(ddi_acc_impl_t
*hdlp
, uint16_t *addr
,
64 void pci_config_wr32(ddi_acc_impl_t
*hdlp
, uint32_t *addr
,
66 void pci_config_wr64(ddi_acc_impl_t
*hdlp
, uint64_t *addr
,
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
);
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
);
88 * PCI tool related declarations
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
);
94 * Interrupt related declaration
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
*);
101 * Miscellaneous library functions
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
);
113 #endif /* _PCI_PCI_COMMON_H */