Gic.py revision 13504
13931Ssaidi@eecs.umich.edu# Copyright (c) 2012-2013, 2017-2018 ARM Limited
22632Sstever@eecs.umich.edu# All rights reserved.
32632Sstever@eecs.umich.edu#
42632Sstever@eecs.umich.edu# The license below extends only to copyright in the software and shall
52632Sstever@eecs.umich.edu# not be construed as granting a license to any other intellectual
62632Sstever@eecs.umich.edu# property including but not limited to intellectual property relating
72632Sstever@eecs.umich.edu# to a hardware implementation of the functionality of the software
82632Sstever@eecs.umich.edu# licensed hereunder.  You may use the software subject to the license
92632Sstever@eecs.umich.edu# terms below provided that you ensure that this notice is replicated
102632Sstever@eecs.umich.edu# unmodified and in its entirety in all distributions of the software,
112632Sstever@eecs.umich.edu# modified or unmodified, in source code or in binary form.
122632Sstever@eecs.umich.edu#
132632Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
142632Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are
152632Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright
162632Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
172632Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
182632Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
192632Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution;
202632Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its
212632Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from
222632Sstever@eecs.umich.edu# this software without specific prior written permission.
232632Sstever@eecs.umich.edu#
242632Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
252632Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
262632Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
272632Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
282632Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
292632Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
302022SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
312022SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
322022SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3312275Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3412275Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3512275Sgabeblack@google.com#
3612275Sgabeblack@google.com# Authors: Andreas Sandberg
3712275Sgabeblack@google.com
3812275Sgabeblack@google.comfrom m5.params import *
3912275Sgabeblack@google.comfrom m5.proxy import *
4012275Sgabeblack@google.comfrom m5.SimObject import SimObject
4112275Sgabeblack@google.com
4212275Sgabeblack@google.comfrom Device import PioDevice
432022SN/Afrom Platform import Platform
442022SN/A
455091Sgblack@eecs.umich.educlass BaseGic(PioDevice):
468621Sgblack@eecs.umich.edu    type = 'BaseGic'
4712275Sgabeblack@google.com    abstract = True
4812275Sgabeblack@google.com    cxx_header = "dev/arm/base_gic.hh"
4912275Sgabeblack@google.com
5012275Sgabeblack@google.com    platform = Param.Platform(Parent.any, "Platform this device is part of.")
5112275Sgabeblack@google.com
5212275Sgabeblack@google.comclass ArmInterruptPin(SimObject):
5312275Sgabeblack@google.com    type = 'ArmInterruptPin'
5412275Sgabeblack@google.com    cxx_header = "dev/arm/base_gic.hh"
5512275Sgabeblack@google.com    cxx_class = "ArmInterruptPinGen"
5612275Sgabeblack@google.com    abstract = True
5712275Sgabeblack@google.com
588621Sgblack@eecs.umich.edu    platform = Param.Platform(Parent.any, "Platform with interrupt controller")
598621Sgblack@eecs.umich.edu    num = Param.UInt32("Interrupt number in GIC")
608621Sgblack@eecs.umich.edu
615091Sgblack@eecs.umich.educlass ArmSPI(ArmInterruptPin):
6212275Sgabeblack@google.com    type = 'ArmSPI'
6312275Sgabeblack@google.com    cxx_header = "dev/arm/base_gic.hh"
6412275Sgabeblack@google.com    cxx_class = "ArmSPIGen"
6512275Sgabeblack@google.com
6612275Sgabeblack@google.comclass ArmPPI(ArmInterruptPin):
6712275Sgabeblack@google.com    type = 'ArmPPI'
6812275Sgabeblack@google.com    cxx_header = "dev/arm/base_gic.hh"
6912275Sgabeblack@google.com    cxx_class = "ArmPPIGen"
7012275Sgabeblack@google.com
7112275Sgabeblack@google.comclass GicV2(BaseGic):
725091Sgblack@eecs.umich.edu    type = 'GicV2'
735091Sgblack@eecs.umich.edu    cxx_header = "dev/arm/gic_v2.hh"
742022SN/A
752022SN/A    dist_addr = Param.Addr("Address for distributor")
7612275Sgabeblack@google.com    cpu_addr = Param.Addr("Address for cpu")
7712275Sgabeblack@google.com    cpu_size = Param.Addr(0x2000, "Size of cpu register bank")
7812275Sgabeblack@google.com    dist_pio_delay = Param.Latency('10ns', "Delay for PIO r/w to distributor")
7912275Sgabeblack@google.com    cpu_pio_delay = Param.Latency('10ns', "Delay for PIO r/w to cpu interface")
8012275Sgabeblack@google.com    int_latency = Param.Latency('10ns', "Delay for interrupt to get to CPU")
812022SN/A    it_lines = Param.UInt32(128, "Number of interrupt lines supported (max = 1020)")
822022SN/A    gem5_extensions = Param.Bool(False, "Enable gem5 extensions")
835091Sgblack@eecs.umich.edu
845091Sgblack@eecs.umich.educlass Gicv2mFrame(SimObject):
8512275Sgabeblack@google.com    type = 'Gicv2mFrame'
8612275Sgabeblack@google.com    cxx_header = "dev/arm/gic_v2m.hh"
8712275Sgabeblack@google.com    spi_base = Param.UInt32(0x0, "Frame SPI base number");
8812275Sgabeblack@google.com    spi_len = Param.UInt32(0x0, "Frame SPI total number");
8912275Sgabeblack@google.com    addr = Param.Addr("Address for frame PIO")
905091Sgblack@eecs.umich.edu
915091Sgblack@eecs.umich.educlass Gicv2m(PioDevice):
922022SN/A    type = 'Gicv2m'
932022SN/A    cxx_header = "dev/arm/gic_v2m.hh"
9412275Sgabeblack@google.com
9512275Sgabeblack@google.com    pio_delay = Param.Latency('10ns', "Delay for PIO r/w")
9612275Sgabeblack@google.com    gic = Param.BaseGic(Parent.any, "Gic on which to trigger interrupts")
9712275Sgabeblack@google.com    frames = VectorParam.Gicv2mFrame([], "Power of two number of frames")
9812275Sgabeblack@google.com
992022SN/Aclass VGic(PioDevice):
10012275Sgabeblack@google.com    type = 'VGic'
10112275Sgabeblack@google.com    cxx_header = "dev/arm/vgic.hh"
10212275Sgabeblack@google.com    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
10312275Sgabeblack@google.com    platform = Param.Platform(Parent.any, "Platform this device is part of.")
1042022SN/A    vcpu_addr = Param.Addr(0, "Address for vcpu interfaces")
10512275Sgabeblack@google.com    hv_addr = Param.Addr(0, "Address for hv control")
10612275Sgabeblack@google.com    pio_delay = Param.Latency('10ns', "Delay for PIO r/w")
10712275Sgabeblack@google.com   # The number of list registers is not currently configurable at runtime.
10812275Sgabeblack@google.com    ppint = Param.UInt32("HV maintenance interrupt number")
10912275Sgabeblack@google.com
1102022SN/A    def generateDeviceTree(self, state):
1112022SN/A        gic = self.gic.unproxy(self)
1128621Sgblack@eecs.umich.edu
11312275Sgabeblack@google.com        node = FdtNode("interrupt-controller")
11412275Sgabeblack@google.com        node.appendCompatible(["gem5,gic", "arm,cortex-a15-gic",
11512275Sgabeblack@google.com                               "arm,cortex-a9-gic"])
11612275Sgabeblack@google.com        node.append(FdtPropertyWords("#interrupt-cells", [3]))
11712275Sgabeblack@google.com        node.append(FdtPropertyWords("#address-cells", [0]))
11812275Sgabeblack@google.com        node.append(FdtProperty("interrupt-controller"))
11912275Sgabeblack@google.com
12012275Sgabeblack@google.com        regs = (
12112275Sgabeblack@google.com            state.addrCells(gic.dist_addr) +
12212275Sgabeblack@google.com            state.sizeCells(0x1000) +
12312275Sgabeblack@google.com            state.addrCells(gic.cpu_addr) +
12412275Sgabeblack@google.com            state.sizeCells(0x1000) +
1258621Sgblack@eecs.umich.edu            state.addrCells(self.hv_addr) +
1268621Sgblack@eecs.umich.edu            state.sizeCells(0x2000) +
1272022SN/A            state.addrCells(self.vcpu_addr) +
1282022SN/A            state.sizeCells(0x2000) )
12912275Sgabeblack@google.com
1302022SN/A        node.append(FdtPropertyWords("reg", regs))
1312022SN/A        node.append(FdtPropertyWords("interrupts",
1323272Sgblack@eecs.umich.edu                                     [1, int(self.ppint)-16, 0xf04]))
1333272Sgblack@eecs.umich.edu
13412275Sgabeblack@google.com        node.appendPhandle(gic)
1353272Sgblack@eecs.umich.edu
1363272Sgblack@eecs.umich.edu        yield node
1372022SN/A