pci_private.h revision 201279
11553Srgrimes/*-
21553Srgrimes * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
31553Srgrimes * Copyright (c) 2000, Michael Smith <msmith@freebsd.org>
41553Srgrimes * Copyright (c) 2000, BSDi
51553Srgrimes * All rights reserved.
61553Srgrimes *
71553Srgrimes * Redistribution and use in source and binary forms, with or without
81553Srgrimes * modification, are permitted provided that the following conditions
91553Srgrimes * are met:
101553Srgrimes * 1. Redistributions of source code must retain the above copyright
111553Srgrimes *    notice unmodified, this list of conditions, and the following
121553Srgrimes *    disclaimer.
131553Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141553Srgrimes *    notice, this list of conditions and the following disclaimer in the
151553Srgrimes *    documentation and/or other materials provided with the distribution.
161553Srgrimes *
171553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181553Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191553Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201553Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211553Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221553Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231553Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241553Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251553Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
261553Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271553Srgrimes *
281553Srgrimes * $FreeBSD: head/sys/dev/pci/pci_private.h 201279 2009-12-30 20:47:14Z jhb $
291553Srgrimes *
301553Srgrimes */
3184693Sgad
321553Srgrimes#ifndef _PCI_PRIVATE_H_
331553Srgrimes#define	_PCI_PRIVATE_H_
341553Srgrimes
351553Srgrimes/*
36117609Sgad * Export definitions of the pci bus so that we can more easily share
371553Srgrimes * it with "subclass" busses.
38117609Sgad */
391553SrgrimesDECLARE_CLASS(pci_driver);
40117609Sgad
411553Srgrimesvoid		pci_add_children(device_t dev, int domain, int busno,
42117609Sgad		    size_t dinfo_size);
43117609Sgadvoid		pci_add_child(device_t bus, struct pci_devinfo *dinfo);
44117609Sgadvoid		pci_add_resources(device_t bus, device_t dev, int force,
451553Srgrimes		    uint32_t prefetchmask);
461553Srgrimesvoid		pci_driver_added(device_t dev, driver_t *driver);
471553Srgrimesint		pci_print_child(device_t dev, device_t child);
481553Srgrimesvoid		pci_probe_nomatch(device_t dev, device_t child);
491553Srgrimesint		pci_read_ivar(device_t dev, device_t child, int which,
501553Srgrimes		    uintptr_t *result);
511553Srgrimesint		pci_write_ivar(device_t dev, device_t child, int which,
521553Srgrimes		    uintptr_t value);
531553Srgrimesint		pci_setup_intr(device_t dev, device_t child,
541553Srgrimes		    struct resource *irq, int flags, driver_filter_t *filter,
551553Srgrimes		    driver_intr_t *intr, void *arg, void **cookiep);
561553Srgrimesint		pci_teardown_intr(device_t dev, device_t child,
571553Srgrimes		    struct resource *irq, void *cookie);
58228663Sdimint		pci_get_vpd_ident_method(device_t dev, device_t child,
591553Srgrimes		    const char **identptr);
601553Srgrimesint		pci_get_vpd_readonly_method(device_t dev, device_t child,
611553Srgrimes		    const char *kw, const char **vptr);
621553Srgrimesint		pci_set_powerstate_method(device_t dev, device_t child,
63242091Sed		    int state);
64242091Sedint		pci_get_powerstate_method(device_t dev, device_t child);
65242091Seduint32_t	pci_read_config_method(device_t dev, device_t child,
66242091Sed		    int reg, int width);
67242091Sedvoid		pci_write_config_method(device_t dev, device_t child,
68242091Sed		    int reg, uint32_t val, int width);
69242091Sedint		pci_enable_busmaster_method(device_t dev, device_t child);
70242091Sedint		pci_disable_busmaster_method(device_t dev, device_t child);
71242091Sedint		pci_enable_io_method(device_t dev, device_t child, int space);
72242091Sedint		pci_disable_io_method(device_t dev, device_t child, int space);
73242091Sedint		pci_find_extcap_method(device_t dev, device_t child,
741553Srgrimes		    int capability, int *capreg);
751553Srgrimesint		pci_alloc_msi_method(device_t dev, device_t child, int *count);
7678146Sgadint		pci_alloc_msix_method(device_t dev, device_t child, int *count);
771553Srgrimesint		pci_remap_msix_method(device_t dev, device_t child,
781553Srgrimes		    int count, const u_int *vectors);
791553Srgrimesint		pci_release_msi_method(device_t dev, device_t child);
801553Srgrimesint		pci_msi_count_method(device_t dev, device_t child);
811553Srgrimesint		pci_msix_count_method(device_t dev, device_t child);
8217202Sjoergstruct resource	*pci_alloc_resource(device_t dev, device_t child,
8317202Sjoerg		    int type, int *rid, u_long start, u_long end, u_long count,
841553Srgrimes		    u_int flags);
851553Srgrimesint		pci_activate_resource(device_t dev, device_t child, int type,
861553Srgrimes		    int rid, struct resource *r);
871553Srgrimesint		pci_deactivate_resource(device_t dev, device_t child, int type,
881553Srgrimes		    int rid, struct resource *r);
891553Srgrimesvoid		pci_delete_resource(device_t dev, device_t child,
901553Srgrimes		    int type, int rid);
911553Srgrimesstruct resource_list *pci_get_resource_list (device_t dev, device_t child);
921553Srgrimesstruct pci_devinfo *pci_read_device(device_t pcib, int d, int b, int s, int f,
931553Srgrimes		    size_t size);
941553Srgrimesvoid		pci_print_verbose(struct pci_devinfo *dinfo);
951553Srgrimesint		pci_freecfg(struct pci_devinfo *dinfo);
961553Srgrimesint		pci_child_location_str_method(device_t cbdev, device_t child,
971553Srgrimes		    char *buf, size_t buflen);
981553Srgrimesint		pci_child_pnpinfo_str_method(device_t cbdev, device_t child,
991553Srgrimes		    char *buf, size_t buflen);
1001553Srgrimesint		pci_assign_interrupt_method(device_t dev, device_t child);
1011553Srgrimesint		pci_resume(device_t dev);
1021553Srgrimesint		pci_suspend(device_t dev);
1031553Srgrimes
1041553Srgrimes/** Restore the config register state.  The state must be previously
1051553Srgrimes * saved with pci_cfg_save.  However, the pci bus driver takes care of
1061553Srgrimes * that.  This function will also return the device to PCI_POWERSTATE_D0
1071553Srgrimes * if it is currently in a lower power mode.
1081553Srgrimes */
1091553Srgrimesvoid		pci_cfg_restore(device_t, struct pci_devinfo *);
1101553Srgrimes
1111553Srgrimes/** Save the config register state.  Optionally set the power state to D3
1121553Srgrimes * if the third argument is non-zero.
1131553Srgrimes */
1141553Srgrimesvoid		pci_cfg_save(device_t, struct pci_devinfo *, int);
1151553Srgrimes
1161553Srgrimes#endif /* _PCI_PRIVATE_H_ */
1171553Srgrimes