Pci.h revision 45e9809aff7304721fddb95654901b32195c9c7a
/*
* Copyright 1998 by Concurrent Computer Corporation
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Concurrent Computer
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Concurrent Computer Corporation makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Copyright 1998 by Metro Link Incorporated
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Metro Link
* Incorporated not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Metro Link Incorporated makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* This file is derived in part from the original xf86_PCI.h that included
* following copyright message:
*
* Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of the above listed copyright holder(s)
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The above listed
* copyright holder(s) make(s) no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* Copyright (c) 1999-2003 by The XFree86 Project, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the copyright holder(s)
* and author(s) shall not be used in advertising or otherwise to promote
* the sale, use or other dealings in this Software without prior written
* authorization from the copyright holder(s) and author(s).
*/
/*
* This file has the private Pci definitions. The public ones are imported
* from xf86Pci.h. Drivers should not use this file.
*/
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#ifndef _PCI_H
#define _PCI_H 1
#include <X11/Xfuncproto.h>
#include "xf86Pci.h"
#include "xf86PciInfo.h"
/*
* Global Definitions
*/
/* by xf86scanpci */
# define MAX_PCI_DOMAINS 512
# define PCI_DOM_MASK 0x01fful
#else
#endif
#ifndef PCI_DOM_MASK
# define PCI_DOM_MASK 0x0ffu
#endif
/*
* "b" contains an optional domain number.
*/
(((d) & 0x00001fu) << 11) | \
(((f) & 0x000007u) << 8))
/*
* Macros for bus numbers found in P2P headers.
*/
#define PCI_PRIMARY_BUS_EXTRACT(x, tag) \
#define PCI_SECONDARY_BUS_EXTRACT(x, tag) \
#define PCI_SUBORDINATE_BUS_EXTRACT(x, tag) \
#define PCI_PRIMARY_BUS_INSERT(x, y) \
(((x) & ~PCI_PRIMARY_BUS_MASK ) | (((y) & 0xffu) << 0))
#define PCI_SECONDARY_BUS_INSERT(x, y) \
#define PCI_SUBORDINATE_BUS_INSERT(x, y) \
/* Ditto for CardBus bridges */
#define PCI_CB_PRIMARY_BUS_EXTRACT(x, tag) \
#define PCI_CB_CARDBUS_BUS_EXTRACT(x, tag) \
#define PCI_CB_SUBORDINATE_BUS_EXTRACT(x, tag) \
#define PCI_CB_PRIMARY_BUS_INSERT(x, tag) \
#define PCI_CB_CARDBUS_BUS_INSERT(x, tag) \
#define PCI_CB_SUBORDINATE_BUS_INSERT(x, tag) \
#if X_BYTE_ORDER == X_BIG_ENDIAN
#else
#endif
/*
* Debug Macros/Definitions
*/
#if defined(DEBUGPCI)
if (lvl > xf86Verbose) { \
ErrorF printfargs; \
}
#else /* !defined(DEBUGPCI) */
#endif /* !defined(DEBUGPCI) */
/*
* PCI Config mechanism definitions
*/
#define PCI_EN 0x80000000
#define PCI_CFGMECH1_ADDRESS_REG 0xCF8
#define PCI_CFGMECH1_DATA_REG 0xCFC
#define PCI_CFGMECH1_MAXDEV 32
/*
* Select architecture specific PCI init function
*/
#if defined(__alpha__)
# if defined(linux)
# define ARCH_PCI_INIT axpPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# elif defined(__NetBSD__)
# define ARCH_PCI_INIT netbsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT ia64linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
# define ARCH_PCI_INIT ix86PciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# if defined(linux)
# define ARCH_PCI_OS_INIT linuxPciInit
# endif
#elif defined(__mc68000__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# elif defined(__NetBSD__)
# define ARCH_PCI_INIT netbsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# else
# define ARCH_PCI_INIT ppcPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define ARCH_PCI_INIT sparcPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# if !defined(__FreeBSD__) && !defined(linux)
# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
# endif
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# define ARCH_PCI_INIT freebsdPciInit
# else
# define ARCH_PCI_INIT ix86PciInit
# endif
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# if defined(linux)
# define ARCH_PCI_OS_INIT linuxPciInit
# endif
#endif
#ifndef ARCH_PCI_INIT
#endif
extern void ARCH_PCI_INIT(void);
#if defined(ARCH_PCI_OS_INIT)
extern void ARCH_PCI_OS_INIT(void);
#endif
#if defined(ARCH_PCI_PCI_BRIDGE)
#endif
#if defined(XF86SCANPCI_WRAPPER)
typedef enum {
#endif
/*
* Table of functions used to access a specific PCI bus domain
* (e.g. a primary PCI bus and all of its secondaries)
*/
typedef struct pci_bus_funcs {
/*
* The next three are optional. If NULL, the corresponding function is
* to be performed generically.
*/
void (*pciGetBridgeBuses)(int, int *, int *, int *);
/* Use pointer's to avoid #include recursion */
/* These are optional and will be implemented using read long
* if not present. */
/*
* pciBusInfo_t - One structure per defined PCI bus
*/
typedef struct pci_bus_info {
unsigned char configMech; /* PCI config type to use */
unsigned char numDevices; /* Range of valid devnums */
unsigned char secondary; /* Boolean: bus is a secondary */
int primary_bus; /* Parent bus */
void *pciBusPriv; /* Implementation private data */
} pciBusInfo_t;
/* configMech values */
#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
/* Generic PCI service functions and helpers */
PCITAG pciGenFindFirst(void);
PCITAG pciGenFindNext(void);
extern PCITAG (*pciFindFirstFP)(void);
extern PCITAG (*pciFindNextFP)(void);
extern CARD32 pciDevidMask;
extern int pciMaxBusNum;
extern int pciBusNum;
extern int pciDevNum;
extern int pciFuncNum;
extern PCITAG pciDeviceTag;
extern int xf86MaxPciDevs;
extern pciBusInfo_t *pciBusInfo[];
#endif /* _PCI_H */