1/* 2 * Copyright 1998 by Concurrent Computer Corporation 3 * 4 * Permission to use, copy, modify, distribute, and sell this software 5 * and its documentation for any purpose is hereby granted without fee, 6 * provided that the above copyright notice appear in all copies and that 7 * both that copyright notice and this permission notice appear in 8 * supporting documentation, and that the name of Concurrent Computer 9 * Corporation not be used in advertising or publicity pertaining to 10 * distribution of the software without specific, written prior 11 * permission. Concurrent Computer Corporation makes no representations 12 * about the suitability of this software for any purpose. It is 13 * provided "as is" without express or implied warranty. 14 * 15 * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD 16 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 17 * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE 18 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 19 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 20 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 21 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 22 * SOFTWARE. 23 * 24 * Copyright 1998 by Metro Link Incorporated 25 * 26 * Permission to use, copy, modify, distribute, and sell this software 27 * and its documentation for any purpose is hereby granted without fee, 28 * provided that the above copyright notice appear in all copies and that 29 * both that copyright notice and this permission notice appear in 30 * supporting documentation, and that the name of Metro Link 31 * Incorporated not be used in advertising or publicity pertaining to 32 * distribution of the software without specific, written prior 33 * permission. Metro Link Incorporated makes no representations 34 * about the suitability of this software for any purpose. It is 35 * provided "as is" without express or implied warranty. 36 * 37 * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD 38 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 39 * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE 40 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 41 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 42 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 43 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 44 * SOFTWARE. 45 * 46 * This file is derived in part from the original xf86_PCI.h that included 47 * following copyright message: 48 * 49 * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> 50 * 51 * Permission to use, copy, modify, distribute, and sell this software and its 52 * documentation for any purpose is hereby granted without fee, provided that 53 * the above copyright notice appear in all copies and that both that 54 * copyright notice and this permission notice appear in supporting 55 * documentation, and that the names of the above listed copyright holder(s) 56 * not be used in advertising or publicity pertaining to distribution of 57 * the software without specific, written prior permission. The above listed 58 * copyright holder(s) make(s) no representations about the suitability of this 59 * software for any purpose. It is provided "as is" without express or 60 * implied warranty. 61 * 62 * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD 63 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 64 * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE 65 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 66 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 67 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 68 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 69 * 70 */ 71/* 72 * Copyright (c) 1999-2003 by The XFree86 Project, Inc. 73 * 74 * Permission is hereby granted, free of charge, to any person obtaining a 75 * copy of this software and associated documentation files (the "Software"), 76 * to deal in the Software without restriction, including without limitation 77 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 78 * and/or sell copies of the Software, and to permit persons to whom the 79 * Software is furnished to do so, subject to the following conditions: 80 * 81 * The above copyright notice and this permission notice shall be included in 82 * all copies or substantial portions of the Software. 83 * 84 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 85 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 86 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 87 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 88 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 89 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 90 * OTHER DEALINGS IN THE SOFTWARE. 91 * 92 * Except as contained in this notice, the name of the copyright holder(s) 93 * and author(s) shall not be used in advertising or otherwise to promote 94 * the sale, use or other dealings in this Software without prior written 95 * authorization from the copyright holder(s) and author(s). 96 */ 97 98 99/* 100 * This file contains just the public interface to the PCI code. 101 * Drivers should use this file rather than Pci.h. 102 */ 103 104#ifndef _XF86PCI_H 105#define _XF86PCI_H 1 106#include <X11/Xarch.h> 107#include <X11/Xfuncproto.h> 108#include "misc.h" 109#include <pciaccess.h> 110 111/* 112 * PCI cfg space definitions (e.g. stuff right out of the PCI spec) 113 */ 114 115/* Device identification register */ 116#define PCI_ID_REG 0x00 117 118/* Command and status register */ 119#define PCI_CMD_STAT_REG 0x04 120#define PCI_CMD_BASE_REG 0x10 121#define PCI_CMD_BIOS_REG 0x30 122#define PCI_CMD_MASK 0xffff 123#define PCI_CMD_IO_ENABLE 0x01 124#define PCI_CMD_MEM_ENABLE 0x02 125#define PCI_CMD_MASTER_ENABLE 0x04 126#define PCI_CMD_SPECIAL_ENABLE 0x08 127#define PCI_CMD_INVALIDATE_ENABLE 0x10 128#define PCI_CMD_PALETTE_ENABLE 0x20 129#define PCI_CMD_PARITY_ENABLE 0x40 130#define PCI_CMD_STEPPING_ENABLE 0x80 131#define PCI_CMD_SERR_ENABLE 0x100 132#define PCI_CMD_BACKTOBACK_ENABLE 0x200 133#define PCI_CMD_BIOS_ENABLE 0x01 134 135/* base class */ 136#define PCI_CLASS_REG 0x08 137#define PCI_CLASS_MASK 0xff000000 138#define PCI_CLASS_SHIFT 24 139#define PCI_CLASS_EXTRACT(x) \ 140 (((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT) 141 142/* base class values */ 143#define PCI_CLASS_PREHISTORIC 0x00 144#define PCI_CLASS_MASS_STORAGE 0x01 145#define PCI_CLASS_NETWORK 0x02 146#define PCI_CLASS_DISPLAY 0x03 147#define PCI_CLASS_MULTIMEDIA 0x04 148#define PCI_CLASS_MEMORY 0x05 149#define PCI_CLASS_BRIDGE 0x06 150#define PCI_CLASS_COMMUNICATIONS 0x07 151#define PCI_CLASS_SYSPERIPH 0x08 152#define PCI_CLASS_INPUT 0x09 153#define PCI_CLASS_DOCKING 0x0a 154#define PCI_CLASS_PROCESSOR 0x0b 155#define PCI_CLASS_SERIALBUS 0x0c 156#define PCI_CLASS_WIRELESS 0x0d 157#define PCI_CLASS_I2O 0x0e 158#define PCI_CLASS_SATELLITE 0x0f 159#define PCI_CLASS_CRYPT 0x10 160#define PCI_CLASS_DATA_ACQUISTION 0x11 161#define PCI_CLASS_UNDEFINED 0xff 162 163/* sub class */ 164#define PCI_SUBCLASS_MASK 0x00ff0000 165#define PCI_SUBCLASS_SHIFT 16 166#define PCI_SUBCLASS_EXTRACT(x) \ 167 (((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT) 168 169/* Sub class values */ 170/* 0x00 prehistoric subclasses */ 171#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00 172#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 173 174/* 0x03 display subclasses */ 175#define PCI_SUBCLASS_DISPLAY_VGA 0x00 176#define PCI_SUBCLASS_DISPLAY_XGA 0x01 177#define PCI_SUBCLASS_DISPLAY_MISC 0x80 178 179/* 0x04 multimedia subclasses */ 180#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00 181#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01 182#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80 183 184/* 0x06 bridge subclasses */ 185#define PCI_SUBCLASS_BRIDGE_HOST 0x00 186#define PCI_SUBCLASS_BRIDGE_ISA 0x01 187#define PCI_SUBCLASS_BRIDGE_EISA 0x02 188#define PCI_SUBCLASS_BRIDGE_MC 0x03 189#define PCI_SUBCLASS_BRIDGE_PCI 0x04 190#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05 191#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06 192#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 193#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 194#define PCI_SUBCLASS_BRIDGE_MISC 0x80 195#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01 196 197/* 0x0b processor subclasses */ 198#define PCI_SUBCLASS_PROCESSOR_386 0x00 199#define PCI_SUBCLASS_PROCESSOR_486 0x01 200#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02 201#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10 202#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20 203#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30 204#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40 205 206/* PCI-PCI bridge mapping registers */ 207#define PCI_PCI_BRIDGE_BUS_REG 0x18 208#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000 209#define PCI_SECONDARY_BUS_MASK 0x0000ff00 210#define PCI_PRIMARY_BUS_MASK 0x000000ff 211 212#define PCI_PCI_BRIDGE_IO_REG 0x1c 213#define PCI_PCI_BRIDGE_MEM_REG 0x20 214#define PCI_PCI_BRIDGE_PMEM_REG 0x24 215 216#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E 217#define PCI_PCI_BRIDGE_PARITY_EN 0x01 218#define PCI_PCI_BRIDGE_SERR_EN 0x02 219#define PCI_PCI_BRIDGE_ISA_EN 0x04 220#define PCI_PCI_BRIDGE_VGA_EN 0x08 221#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20 222#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40 223#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80 224 225/* Subsystem identification register */ 226#define PCI_SUBSYSTEM_ID_REG 0x2c 227 228/* User defined cfg space regs */ 229#define PCI_REG_USERCONFIG 0x40 230#define PCI_OPTION_REG 0x40 231 232/* 233 * Typedefs, etc... 234 */ 235 236/* Primitive Types */ 237typedef unsigned long ADDRESS; /* Memory/PCI address */ 238typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */ 239typedef unsigned long PCITAG; 240 241typedef enum { 242 PCI_MEM, 243 PCI_MEM_SIZE, 244 PCI_MEM_SPARSE_BASE, 245 PCI_MEM_SPARSE_MASK, 246 PCI_IO, 247 PCI_IO_SIZE, 248 PCI_IO_SPARSE_BASE, 249 PCI_IO_SPARSE_MASK 250} PciAddrType; 251 252 253/* Public PCI access functions */ 254extern _X_EXPORT PCITAG pciTag(int busnum, int devnum, int funcnum); 255extern _X_EXPORT Bool xf86scanpci(void); 256 257/* Domain access functions. Some of these probably shouldn't be public */ 258extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, 259 ADDRESS Base, unsigned long Size); 260extern _X_EXPORT IOADDRESS xf86MapLegacyIO(struct pci_device *dev); 261 262#endif /* _XF86PCI_H */ 263