i740_pcirename.h revision 0cc67336
11.2Skiyohara/* 21.1Such * Copyright 2007 George Sapountzis 31.1Such * 41.1Such * Permission is hereby granted, free of charge, to any person obtaining a 51.1Such * copy of this software and associated documentation files (the "Software"), 61.1Such * to deal in the Software without restriction, including without limitation 71.1Such * the rights to use, copy, modify, merge, publish, distribute, sublicense, 81.1Such * and/or sell copies of the Software, and to permit persons to whom the 91.1Such * Software is furnished to do so, subject to the following conditions: 101.1Such * 111.1Such * The above copyright notice and this permission notice (including the next 121.1Such * paragraph) shall be included in all copies or substantial portions of the 131.1Such * Software. 141.1Such * 151.1Such * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161.1Such * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171.1Such * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181.1Such * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191.1Such * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 201.1Such * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 211.1Such * SOFTWARE. 221.1Such */ 231.1Such 241.1Such/** 251.1Such * Macros for porting drivers from legacy xfree86 PCI code to the pciaccess 261.1Such * library. The main purpose being to facilitate source code compatibility. 271.1Such */ 281.1Such 291.1Such#ifndef I740PCIRENAME_H 301.1Such#define I740PCIRENAME_H 311.1Such 321.1Suchenum region_type { 331.1Such REGION_MEM, 341.1Such REGION_IO 351.1Such}; 361.1Such 371.1Such#ifndef XSERVER_LIBPCIACCESS 381.1Such 391.1Such/* pciVideoPtr */ 401.1Such#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor) 411.1Such#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->chipType) 421.1Such#define PCI_DEV_REVISION(_pcidev) ((_pcidev)->chipRev) 431.1Such 441.1Such#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subsysVendor) 451.1Such#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subsysCard) 461.1Such 471.1Such#define PCI_DEV_TAG(_pcidev) pciTag((_pcidev)->bus, \ 481.1Such (_pcidev)->device, \ 491.1Such (_pcidev)->func) 501.1Such#define PCI_DEV_BUS(_pcidev) ((_pcidev)->bus) 511.1Such#define PCI_DEV_DEV(_pcidev) ((_pcidev)->device) 521.1Such#define PCI_DEV_FUNC(_pcidev) ((_pcidev)->func) 531.1Such 541.2Skiyohara/* pciConfigPtr */ 551.1Such#define PCI_CFG_TAG(_pcidev) (((pciConfigPtr)(_pcidev)->thisCard)->tag) 561.1Such#define PCI_CFG_BUS(_pcidev) (((pciConfigPtr)(_pcidev)->thisCard)->busnum) 571.1Such#define PCI_CFG_DEV(_pcidev) (((pciConfigPtr)(_pcidev)->thisCard)->devnum) 581.1Such#define PCI_CFG_FUNC(_pcidev) (((pciConfigPtr)(_pcidev)->thisCard)->funcnum) 591.1Such 601.1Such/* region addr: xfree86 uses different fields for memory regions and I/O ports */ 611.1Such#define PCI_REGION_BASE(_pcidev, _b, _type) \ 621.1Such (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] \ 631.1Such : (_pcidev)->ioBase[(_b)]) 641.1Such 651.1Such/* region size: xfree86 uses the log2 of the region size, 661.1Such * but with zero meaning no region, not size of one XXX */ 671.1Such#define PCI_REGION_SIZE(_pcidev, _b) \ 681.1Such (((_pcidev)->size[(_b)] > 0) ? (1 << (_pcidev)->size[(_b)]) : 0) 691.1Such 701.1Such/* read/write PCI configuration space */ 711.1Such#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \ 721.1Such *(_value_ptr) = pciReadByte(PCI_CFG_TAG(_pcidev), (_offset)) 731.1Such 741.1Such#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \ 751.1Such *(_value_ptr) = pciReadLong(PCI_CFG_TAG(_pcidev), (_offset)) 761.1Such 771.2Skiyohara#define PCI_WRITE_LONG(_pcidev, _value, _offset) \ 781.2Skiyohara pciWriteLong(PCI_CFG_TAG(_pcidev), (_offset), (_value)) 791.1Such 801.2Skiyohara#else /* XSERVER_LIBPCIACCESS */ 811.1Such 821.1Suchtypedef struct pci_device *pciVideoPtr; 831.1Such 841.1Such#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor_id) 851.1Such#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->device_id) 861.1Such#define PCI_DEV_REVISION(_pcidev) ((_pcidev)->revision) 871.1Such 881.1Such#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subvendor_id) 891.1Such#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subdevice_id) 901.1Such 911.1Such/* pci-rework functions take a 'pci_device' parameter instead of a tag */ 921.1Such#define PCI_DEV_TAG(_pcidev) (_pcidev) 931.1Such 941.1Such/* PCI_DEV macros, typically used in printf's, add domain ? XXX */ 951.1Such#define PCI_DEV_BUS(_pcidev) ((_pcidev)->bus) 961.1Such#define PCI_DEV_DEV(_pcidev) ((_pcidev)->dev) 971.1Such#define PCI_DEV_FUNC(_pcidev) ((_pcidev)->func) 981.1Such 991.1Such/* pci-rework functions take a 'pci_device' parameter instead of a tag */ 1001.1Such#define PCI_CFG_TAG(_pcidev) (_pcidev) 1011.1Such 1021.1Such/* PCI_CFG macros, typically used in DRI init, contain the domain */ 1031.1Such#define PCI_CFG_BUS(_pcidev) (((_pcidev)->domain << 8) | \ 1041.1Such (_pcidev)->bus) 1051.1Such#define PCI_CFG_DEV(_pcidev) ((_pcidev)->dev) 1061.1Such#define PCI_CFG_FUNC(_pcidev) ((_pcidev)->func) 1071.2Skiyohara 1081.1Such#define PCI_REGION_BASE(_pcidev, _b, _type) ((_pcidev)->regions[(_b)].base_addr) 1091.1Such#define PCI_REGION_SIZE(_pcidev, _b) ((_pcidev)->regions[(_b)].size) 1101.1Such 1111.2Skiyohara#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \ 1121.2Skiyohara pci_device_cfg_read_u8((_pcidev), (_value_ptr), (_offset)) 1131.2Skiyohara 1141.2Skiyohara#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \ 1151.2Skiyohara pci_device_cfg_read_u32((_pcidev), (_value_ptr), (_offset)) 1161.1Such 1171.1Such#define PCI_WRITE_LONG(_pcidev, _value, _offset) \ 1181.1Such pci_device_cfg_write_u32((_pcidev), (_value), (_offset)) 1191.2Skiyohara 1201.1Such#endif /* XSERVER_LIBPCIACCESS */ 1211.1Such 1221.1Such#endif /* i740PCIRENAME_H */ 1231.1Such