pci_private.h revision 252315
1/*- 2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org> 3 * Copyright (c) 2000, Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000, BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * $FreeBSD: head/sys/dev/pci/pci_private.h 252315 2013-06-27 20:21:54Z jhb $ 29 * 30 */ 31 32#ifndef _PCI_PRIVATE_H_ 33#define _PCI_PRIVATE_H_ 34 35/* 36 * Export definitions of the pci bus so that we can more easily share 37 * it with "subclass" busses. 38 */ 39DECLARE_CLASS(pci_driver); 40 41struct pci_softc { 42 bus_dma_tag_t sc_dma_tag; 43}; 44 45extern int pci_do_power_resume; 46extern int pci_do_power_suspend; 47 48void pci_add_children(device_t dev, int domain, int busno, 49 size_t dinfo_size); 50void pci_add_child(device_t bus, struct pci_devinfo *dinfo); 51void pci_add_resources(device_t bus, device_t dev, int force, 52 uint32_t prefetchmask); 53int pci_attach_common(device_t dev); 54void pci_delete_child(device_t dev, device_t child); 55void pci_driver_added(device_t dev, driver_t *driver); 56int pci_print_child(device_t dev, device_t child); 57void pci_probe_nomatch(device_t dev, device_t child); 58int pci_read_ivar(device_t dev, device_t child, int which, 59 uintptr_t *result); 60int pci_write_ivar(device_t dev, device_t child, int which, 61 uintptr_t value); 62int pci_setup_intr(device_t dev, device_t child, 63 struct resource *irq, int flags, driver_filter_t *filter, 64 driver_intr_t *intr, void *arg, void **cookiep); 65int pci_teardown_intr(device_t dev, device_t child, 66 struct resource *irq, void *cookie); 67int pci_get_vpd_ident_method(device_t dev, device_t child, 68 const char **identptr); 69int pci_get_vpd_readonly_method(device_t dev, device_t child, 70 const char *kw, const char **vptr); 71int pci_set_powerstate_method(device_t dev, device_t child, 72 int state); 73int pci_get_powerstate_method(device_t dev, device_t child); 74uint32_t pci_read_config_method(device_t dev, device_t child, 75 int reg, int width); 76void pci_write_config_method(device_t dev, device_t child, 77 int reg, uint32_t val, int width); 78int pci_enable_busmaster_method(device_t dev, device_t child); 79int pci_disable_busmaster_method(device_t dev, device_t child); 80int pci_enable_io_method(device_t dev, device_t child, int space); 81int pci_disable_io_method(device_t dev, device_t child, int space); 82int pci_find_cap_method(device_t dev, device_t child, 83 int capability, int *capreg); 84int pci_find_extcap_method(device_t dev, device_t child, 85 int capability, int *capreg); 86int pci_find_htcap_method(device_t dev, device_t child, 87 int capability, int *capreg); 88int pci_alloc_msi_method(device_t dev, device_t child, int *count); 89int pci_alloc_msix_method(device_t dev, device_t child, int *count); 90int pci_remap_msix_method(device_t dev, device_t child, 91 int count, const u_int *vectors); 92int pci_release_msi_method(device_t dev, device_t child); 93int pci_msi_count_method(device_t dev, device_t child); 94int pci_msix_count_method(device_t dev, device_t child); 95struct resource *pci_alloc_resource(device_t dev, device_t child, 96 int type, int *rid, u_long start, u_long end, u_long count, 97 u_int flags); 98int pci_activate_resource(device_t dev, device_t child, int type, 99 int rid, struct resource *r); 100int pci_deactivate_resource(device_t dev, device_t child, int type, 101 int rid, struct resource *r); 102void pci_delete_resource(device_t dev, device_t child, 103 int type, int rid); 104struct resource_list *pci_get_resource_list (device_t dev, device_t child); 105struct pci_devinfo *pci_read_device(device_t pcib, int d, int b, int s, int f, 106 size_t size); 107void pci_print_verbose(struct pci_devinfo *dinfo); 108int pci_freecfg(struct pci_devinfo *dinfo); 109void pci_child_detached(device_t dev, device_t child); 110int pci_child_location_str_method(device_t cbdev, device_t child, 111 char *buf, size_t buflen); 112int pci_child_pnpinfo_str_method(device_t cbdev, device_t child, 113 char *buf, size_t buflen); 114int pci_assign_interrupt_method(device_t dev, device_t child); 115int pci_resume(device_t dev); 116int pci_suspend(device_t dev); 117 118/** Restore the config register state. The state must be previously 119 * saved with pci_cfg_save. However, the pci bus driver takes care of 120 * that. This function will also return the device to PCI_POWERSTATE_D0 121 * if it is currently in a lower power mode. 122 */ 123void pci_cfg_restore(device_t, struct pci_devinfo *); 124 125/** Save the config register state. Optionally set the power state to D3 126 * if the third argument is non-zero. 127 */ 128void pci_cfg_save(device_t, struct pci_devinfo *, int); 129 130#endif /* _PCI_PRIVATE_H_ */ 131