PciDevice.py revision 10359
1# Copyright (c) 2013 ARM Limited 2# All rights reserved 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Copyright (c) 2005-2007 The Regents of The University of Michigan 14# All rights reserved. 15# 16# Redistribution and use in source and binary forms, with or without 17# modification, are permitted provided that the following conditions are 18# met: redistributions of source code must retain the above copyright 19# notice, this list of conditions and the following disclaimer; 20# redistributions in binary form must reproduce the above copyright 21# notice, this list of conditions and the following disclaimer in the 22# documentation and/or other materials provided with the distribution; 23# neither the name of the copyright holders nor the names of its 24# contributors may be used to endorse or promote products derived from 25# this software without specific prior written permission. 26# 27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39# Authors: Nathan Binkert 40 41from m5.SimObject import SimObject 42from m5.params import * 43from m5.proxy import * 44from Device import BasicPioDevice, DmaDevice, PioDevice 45 46class PciConfigAll(BasicPioDevice): 47 type = 'PciConfigAll' 48 cxx_header = "dev/pciconfigall.hh" 49 platform = Param.Platform(Parent.any, "Platform this device is part of.") 50 bus = Param.UInt8(0x00, "PCI bus to act as config space for") 51 size = Param.MemorySize32('16MB', "Size of config space") 52 53 pio_latency = '30ns' 54 pio_addr = 0 # will be overridden by platform-based calculation 55 56 57class PciDevice(DmaDevice): 58 type = 'PciDevice' 59 cxx_class = 'PciDevice' 60 cxx_header = "dev/pcidev.hh" 61 abstract = True 62 platform = Param.Platform(Parent.any, "Platform this device is part of.") 63 config = SlavePort("PCI configuration space port") 64 pci_bus = Param.Int("PCI bus") 65 pci_dev = Param.Int("PCI device number") 66 pci_func = Param.Int("PCI function code") 67 pio_latency = Param.Latency('30ns', "Programmed IO latency") 68 config_latency = Param.Latency('20ns', "Config read or write latency") 69 70 VendorID = Param.UInt16("Vendor ID") 71 DeviceID = Param.UInt16("Device ID") 72 Command = Param.UInt16(0, "Command") 73 Status = Param.UInt16(0, "Status") 74 Revision = Param.UInt8(0, "Device") 75 ProgIF = Param.UInt8(0, "Programming Interface") 76 SubClassCode = Param.UInt8(0, "Sub-Class Code") 77 ClassCode = Param.UInt8(0, "Class Code") 78 CacheLineSize = Param.UInt8(0, "System Cacheline Size") 79 LatencyTimer = Param.UInt8(0, "PCI Latency Timer") 80 HeaderType = Param.UInt8(0, "PCI Header Type") 81 BIST = Param.UInt8(0, "Built In Self Test") 82 83 BAR0 = Param.UInt32(0x00, "Base Address Register 0") 84 BAR1 = Param.UInt32(0x00, "Base Address Register 1") 85 BAR2 = Param.UInt32(0x00, "Base Address Register 2") 86 BAR3 = Param.UInt32(0x00, "Base Address Register 3") 87 BAR4 = Param.UInt32(0x00, "Base Address Register 4") 88 BAR5 = Param.UInt32(0x00, "Base Address Register 5") 89 BAR0Size = Param.MemorySize32('0B', "Base Address Register 0 Size") 90 BAR1Size = Param.MemorySize32('0B', "Base Address Register 1 Size") 91 BAR2Size = Param.MemorySize32('0B', "Base Address Register 2 Size") 92 BAR3Size = Param.MemorySize32('0B', "Base Address Register 3 Size") 93 BAR4Size = Param.MemorySize32('0B', "Base Address Register 4 Size") 94 BAR5Size = Param.MemorySize32('0B', "Base Address Register 5 Size") 95 BAR0LegacyIO = Param.Bool(False, "Whether BAR0 is hardwired legacy IO") 96 BAR1LegacyIO = Param.Bool(False, "Whether BAR1 is hardwired legacy IO") 97 BAR2LegacyIO = Param.Bool(False, "Whether BAR2 is hardwired legacy IO") 98 BAR3LegacyIO = Param.Bool(False, "Whether BAR3 is hardwired legacy IO") 99 BAR4LegacyIO = Param.Bool(False, "Whether BAR4 is hardwired legacy IO") 100 BAR5LegacyIO = Param.Bool(False, "Whether BAR5 is hardwired legacy IO") 101 LegacyIOBase = Param.Addr(0x0, "Base Address for Legacy IO") 102 103 CardbusCIS = Param.UInt32(0x00, "Cardbus Card Information Structure") 104 SubsystemID = Param.UInt16(0x00, "Subsystem ID") 105 SubsystemVendorID = Param.UInt16(0x00, "Subsystem Vendor ID") 106 ExpansionROM = Param.UInt32(0x00, "Expansion ROM Base Address") 107 CapabilityPtr = Param.UInt8(0x00, "Capability List Pointer offset") 108 InterruptLine = Param.UInt8(0x00, "Interrupt Line") 109 InterruptPin = Param.UInt8(0x00, "Interrupt Pin") 110 MaximumLatency = Param.UInt8(0x00, "Maximum Latency") 111 MinimumGrant = Param.UInt8(0x00, "Minimum Grant") 112 113 # Capabilities List structures for PCIe devices 114 # PMCAP - PCI Power Management Capability 115 PMCAPBaseOffset = \ 116 Param.UInt8(0x00, "Base offset of PMCAP in PCI Config space") 117 PMCAPNextCapability = \ 118 Param.UInt8(0x00, "Pointer to next capability block") 119 PMCAPCapId = \ 120 Param.UInt8(0x00, "Specifies this is the Power Management capability") 121 PMCAPCapabilities = \ 122 Param.UInt16(0x0000, "PCI Power Management Capabilities Register") 123 PMCAPCtrlStatus = \ 124 Param.UInt16(0x0000, "PCI Power Management Control and Status") 125 126 # MSICAP - Message Signaled Interrupt Capability 127 MSICAPBaseOffset = \ 128 Param.UInt8(0x00, "Base offset of MSICAP in PCI Config space") 129 MSICAPNextCapability = \ 130 Param.UInt8(0x00, "Pointer to next capability block") 131 MSICAPCapId = Param.UInt8(0x00, "Specifies this is the MSI Capability") 132 MSICAPMsgCtrl = Param.UInt16(0x0000, "MSI Message Control") 133 MSICAPMsgAddr = Param.UInt32(0x00000000, "MSI Message Address") 134 MSICAPMsgUpperAddr = Param.UInt32(0x00000000, "MSI Message Upper Address") 135 MSICAPMsgData = Param.UInt16(0x0000, "MSI Message Data") 136 MSICAPMaskBits = Param.UInt32(0x00000000, "MSI Interrupt Mask Bits") 137 MSICAPPendingBits = Param.UInt32(0x00000000, "MSI Pending Bits") 138 139 # MSIXCAP - MSI-X Capability 140 MSIXCAPBaseOffset = \ 141 Param.UInt8(0x00, "Base offset of MSIXCAP in PCI Config space") 142 MSIXCAPNextCapability = \ 143 Param.UInt8(0x00, "Pointer to next capability block") 144 MSIXCAPCapId = Param.UInt8(0x00, "Specifices this the MSI-X Capability") 145 MSIXMsgCtrl = Param.UInt16(0x0000, "MSI-X Message Control") 146 MSIXTableOffset = \ 147 Param.UInt32(0x00000000, "MSI-X Table Offset and Table BIR") 148 MSIXPbaOffset = Param.UInt32(0x00000000, "MSI-X PBA Offset and PBA BIR") 149 150 # PXCAP - PCI Express Capability 151 PXCAPBaseOffset = \ 152 Param.UInt8(0x00, "Base offset of PXCAP in PCI Config space") 153 PXCAPNextCapability = Param.UInt8(0x00, "Pointer to next capability block") 154 PXCAPCapId = Param.UInt8(0x00, "Specifies this is the PCIe Capability") 155 PXCAPCapabilities = Param.UInt16(0x0000, "PCIe Capabilities") 156 PXCAPDevCapabilities = Param.UInt32(0x00000000, "PCIe Device Capabilities") 157 PXCAPDevCtrl = Param.UInt16(0x0000, "PCIe Device Control") 158 PXCAPDevStatus = Param.UInt16(0x0000, "PCIe Device Status") 159 PXCAPLinkCap = Param.UInt32(0x00000000, "PCIe Link Capabilities") 160 PXCAPLinkCtrl = Param.UInt16(0x0000, "PCIe Link Control") 161 PXCAPLinkStatus = Param.UInt16(0x0000, "PCIe Link Status") 162 PXCAPDevCap2 = Param.UInt32(0x00000000, "PCIe Device Capabilities 2") 163 PXCAPDevCtrl2 = Param.UInt32(0x00000000, "PCIe Device Control 2") 164