PciDevice.py revision 11260:bedcc64f6145
112855Sgabeblack@google.com# Copyright (c) 2013 ARM Limited
212855Sgabeblack@google.com#  All rights reserved
312855Sgabeblack@google.com#
412855Sgabeblack@google.com# The license below extends only to copyright in the software and shall
512855Sgabeblack@google.com# not be construed as granting a license to any other intellectual
612855Sgabeblack@google.com# property including but not limited to intellectual property relating
712855Sgabeblack@google.com# to a hardware implementation of the functionality of the software
812855Sgabeblack@google.com# licensed hereunder.  You may use the software subject to the license
912855Sgabeblack@google.com# terms below provided that you ensure that this notice is replicated
1012855Sgabeblack@google.com# unmodified and in its entirety in all distributions of the software,
1112855Sgabeblack@google.com# modified or unmodified, in source code or in binary form.
1212855Sgabeblack@google.com#
1312855Sgabeblack@google.com# Copyright (c) 2005-2007 The Regents of The University of Michigan
1412855Sgabeblack@google.com# All rights reserved.
1512855Sgabeblack@google.com#
1612855Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
1712855Sgabeblack@google.com# modification, are permitted provided that the following conditions are
1812855Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
1912855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
2012855Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
2112855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
2212855Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
2312855Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
2412855Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
2512855Sgabeblack@google.com# this software without specific prior written permission.
2612855Sgabeblack@google.com#
2712855Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2812855Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2912855Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3012855Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3112855Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3212855Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3312855Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3412855Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3512855Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3612855Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3712855Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3812855Sgabeblack@google.com#
3912855Sgabeblack@google.com# Authors: Nathan Binkert
4012855Sgabeblack@google.com
4112855Sgabeblack@google.comfrom m5.SimObject import SimObject
4212855Sgabeblack@google.comfrom m5.params import *
4312855Sgabeblack@google.comfrom m5.proxy import *
4412855Sgabeblack@google.comfrom Device import DmaDevice
4512855Sgabeblack@google.comfrom PciHost import PciHost
4612855Sgabeblack@google.com
4712855Sgabeblack@google.comclass PciDevice(DmaDevice):
4812855Sgabeblack@google.com    type = 'PciDevice'
4912855Sgabeblack@google.com    cxx_class = 'PciDevice'
5012855Sgabeblack@google.com    cxx_header = "dev/pci/device.hh"
5112855Sgabeblack@google.com    abstract = True
52
53    host = Param.PciHost(Parent.any, "PCI host")
54    pci_bus = Param.Int("PCI bus")
55    pci_dev = Param.Int("PCI device number")
56    pci_func = Param.Int("PCI function code")
57
58    pio_latency = Param.Latency('30ns', "Programmed IO latency")
59    config_latency = Param.Latency('20ns', "Config read or write latency")
60
61    VendorID = Param.UInt16("Vendor ID")
62    DeviceID = Param.UInt16("Device ID")
63    Command = Param.UInt16(0, "Command")
64    Status = Param.UInt16(0, "Status")
65    Revision = Param.UInt8(0, "Device")
66    ProgIF = Param.UInt8(0, "Programming Interface")
67    SubClassCode = Param.UInt8(0, "Sub-Class Code")
68    ClassCode = Param.UInt8(0, "Class Code")
69    CacheLineSize = Param.UInt8(0, "System Cacheline Size")
70    LatencyTimer = Param.UInt8(0, "PCI Latency Timer")
71    HeaderType = Param.UInt8(0, "PCI Header Type")
72    BIST = Param.UInt8(0, "Built In Self Test")
73
74    BAR0 = Param.UInt32(0x00, "Base Address Register 0")
75    BAR1 = Param.UInt32(0x00, "Base Address Register 1")
76    BAR2 = Param.UInt32(0x00, "Base Address Register 2")
77    BAR3 = Param.UInt32(0x00, "Base Address Register 3")
78    BAR4 = Param.UInt32(0x00, "Base Address Register 4")
79    BAR5 = Param.UInt32(0x00, "Base Address Register 5")
80    BAR0Size = Param.MemorySize32('0B', "Base Address Register 0 Size")
81    BAR1Size = Param.MemorySize32('0B', "Base Address Register 1 Size")
82    BAR2Size = Param.MemorySize32('0B', "Base Address Register 2 Size")
83    BAR3Size = Param.MemorySize32('0B', "Base Address Register 3 Size")
84    BAR4Size = Param.MemorySize32('0B', "Base Address Register 4 Size")
85    BAR5Size = Param.MemorySize32('0B', "Base Address Register 5 Size")
86    BAR0LegacyIO = Param.Bool(False, "Whether BAR0 is hardwired legacy IO")
87    BAR1LegacyIO = Param.Bool(False, "Whether BAR1 is hardwired legacy IO")
88    BAR2LegacyIO = Param.Bool(False, "Whether BAR2 is hardwired legacy IO")
89    BAR3LegacyIO = Param.Bool(False, "Whether BAR3 is hardwired legacy IO")
90    BAR4LegacyIO = Param.Bool(False, "Whether BAR4 is hardwired legacy IO")
91    BAR5LegacyIO = Param.Bool(False, "Whether BAR5 is hardwired legacy IO")
92    LegacyIOBase = Param.Addr(0x0, "Base Address for Legacy IO")
93
94    CardbusCIS = Param.UInt32(0x00, "Cardbus Card Information Structure")
95    SubsystemID = Param.UInt16(0x00, "Subsystem ID")
96    SubsystemVendorID = Param.UInt16(0x00, "Subsystem Vendor ID")
97    ExpansionROM = Param.UInt32(0x00, "Expansion ROM Base Address")
98    CapabilityPtr = Param.UInt8(0x00, "Capability List Pointer offset")
99    InterruptLine = Param.UInt8(0x00, "Interrupt Line")
100    InterruptPin = Param.UInt8(0x00, "Interrupt Pin")
101    MaximumLatency = Param.UInt8(0x00, "Maximum Latency")
102    MinimumGrant = Param.UInt8(0x00, "Minimum Grant")
103
104    # Capabilities List structures for PCIe devices
105    # PMCAP - PCI Power Management Capability
106    PMCAPBaseOffset = \
107        Param.UInt8(0x00, "Base offset of PMCAP in PCI Config space")
108    PMCAPNextCapability = \
109        Param.UInt8(0x00, "Pointer to next capability block")
110    PMCAPCapId = \
111        Param.UInt8(0x00, "Specifies this is the Power Management capability")
112    PMCAPCapabilities = \
113        Param.UInt16(0x0000, "PCI Power Management Capabilities Register")
114    PMCAPCtrlStatus = \
115        Param.UInt16(0x0000, "PCI Power Management Control and Status")
116
117    # MSICAP - Message Signaled Interrupt Capability
118    MSICAPBaseOffset = \
119        Param.UInt8(0x00, "Base offset of MSICAP in PCI Config space")
120    MSICAPNextCapability = \
121        Param.UInt8(0x00, "Pointer to next capability block")
122    MSICAPCapId = Param.UInt8(0x00, "Specifies this is the MSI Capability")
123    MSICAPMsgCtrl = Param.UInt16(0x0000, "MSI Message Control")
124    MSICAPMsgAddr = Param.UInt32(0x00000000, "MSI Message Address")
125    MSICAPMsgUpperAddr = Param.UInt32(0x00000000, "MSI Message Upper Address")
126    MSICAPMsgData = Param.UInt16(0x0000, "MSI Message Data")
127    MSICAPMaskBits = Param.UInt32(0x00000000, "MSI Interrupt Mask Bits")
128    MSICAPPendingBits = Param.UInt32(0x00000000, "MSI Pending Bits")
129
130    # MSIXCAP - MSI-X Capability
131    MSIXCAPBaseOffset = \
132        Param.UInt8(0x00, "Base offset of MSIXCAP in PCI Config space")
133    MSIXCAPNextCapability = \
134        Param.UInt8(0x00, "Pointer to next capability block")
135    MSIXCAPCapId = Param.UInt8(0x00, "Specifices this the MSI-X Capability")
136    MSIXMsgCtrl = Param.UInt16(0x0000, "MSI-X Message Control")
137    MSIXTableOffset = \
138        Param.UInt32(0x00000000, "MSI-X Table Offset and Table BIR")
139    MSIXPbaOffset = Param.UInt32(0x00000000, "MSI-X PBA Offset and PBA BIR")
140
141    # PXCAP - PCI Express Capability
142    PXCAPBaseOffset = \
143        Param.UInt8(0x00, "Base offset of PXCAP in PCI Config space")
144    PXCAPNextCapability = Param.UInt8(0x00, "Pointer to next capability block")
145    PXCAPCapId = Param.UInt8(0x00, "Specifies this is the PCIe Capability")
146    PXCAPCapabilities = Param.UInt16(0x0000, "PCIe Capabilities")
147    PXCAPDevCapabilities = Param.UInt32(0x00000000, "PCIe Device Capabilities")
148    PXCAPDevCtrl = Param.UInt16(0x0000, "PCIe Device Control")
149    PXCAPDevStatus = Param.UInt16(0x0000, "PCIe Device Status")
150    PXCAPLinkCap = Param.UInt32(0x00000000, "PCIe Link Capabilities")
151    PXCAPLinkCtrl = Param.UInt16(0x0000, "PCIe Link Control")
152    PXCAPLinkStatus = Param.UInt16(0x0000, "PCIe Link Status")
153    PXCAPDevCap2 = Param.UInt32(0x00000000, "PCIe Device Capabilities 2")
154    PXCAPDevCtrl2 = Param.UInt32(0x00000000, "PCIe Device Control 2")
155