110749Smatt.evans@arm.com/*
210749Smatt.evans@arm.com * Copyright (c) 2013 ARM Limited
310749Smatt.evans@arm.com * All rights reserved
410749Smatt.evans@arm.com *
510749Smatt.evans@arm.com * The license below extends only to copyright in the software and shall
610749Smatt.evans@arm.com * not be construed as granting a license to any other intellectual
710749Smatt.evans@arm.com * property including but not limited to intellectual property relating
810749Smatt.evans@arm.com * to a hardware implementation of the functionality of the software
910749Smatt.evans@arm.com * licensed hereunder.  You may use the software subject to the license
1010749Smatt.evans@arm.com * terms below provided that you ensure that this notice is replicated
1110749Smatt.evans@arm.com * unmodified and in its entirety in all distributions of the software,
1210749Smatt.evans@arm.com * modified or unmodified, in source code or in binary form.
1310749Smatt.evans@arm.com *
1410749Smatt.evans@arm.com * Redistribution and use in source and binary forms, with or without
1510749Smatt.evans@arm.com * modification, are permitted provided that the following conditions are
1610749Smatt.evans@arm.com * met: redistributions of source code must retain the above copyright
1710749Smatt.evans@arm.com * notice, this list of conditions and the following disclaimer;
1810749Smatt.evans@arm.com * redistributions in binary form must reproduce the above copyright
1910749Smatt.evans@arm.com * notice, this list of conditions and the following disclaimer in the
2010749Smatt.evans@arm.com * documentation and/or other materials provided with the distribution;
2110749Smatt.evans@arm.com * neither the name of the copyright holders nor the names of its
2210749Smatt.evans@arm.com * contributors may be used to endorse or promote products derived from
2310749Smatt.evans@arm.com * this software without specific prior written permission.
2410749Smatt.evans@arm.com *
2510749Smatt.evans@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2610749Smatt.evans@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2710749Smatt.evans@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2810749Smatt.evans@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2910749Smatt.evans@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3010749Smatt.evans@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3110749Smatt.evans@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3210749Smatt.evans@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3310749Smatt.evans@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3410749Smatt.evans@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3510749Smatt.evans@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3610749Smatt.evans@arm.com *
3710749Smatt.evans@arm.com * Authors: Matt Evans
3810749Smatt.evans@arm.com */
3910749Smatt.evans@arm.com
4010749Smatt.evans@arm.com/** @file
4110749Smatt.evans@arm.com * Implementiation of a GICv2m MSI shim.
4210749Smatt.evans@arm.com *
4310749Smatt.evans@arm.com * See gic_v2m.cc for an instantiation example.
4410749Smatt.evans@arm.com */
4510749Smatt.evans@arm.com
4610749Smatt.evans@arm.com#ifndef __DEV_ARM_GIC_V2M_H__
4710749Smatt.evans@arm.com#define __DEV_ARM_GIC_V2M_H__
4810749Smatt.evans@arm.com
4910749Smatt.evans@arm.com#include "base/bitunion.hh"
5010749Smatt.evans@arm.com#include "cpu/intr_control.hh"
5110749Smatt.evans@arm.com#include "dev/arm/base_gic.hh"
5210749Smatt.evans@arm.com#include "dev/io_device.hh"
5310749Smatt.evans@arm.com#include "dev/platform.hh"
5410749Smatt.evans@arm.com#include "params/Gicv2m.hh"
5510749Smatt.evans@arm.com#include "params/Gicv2mFrame.hh"
5610749Smatt.evans@arm.com
5710749Smatt.evans@arm.com/**
5810749Smatt.evans@arm.com * Ultimately this class should be embedded in the Gicv2m class, but
5910749Smatt.evans@arm.com * this confuses Python as 'Gicv2m::Frame' gets interpreted as 'Frame'
6010749Smatt.evans@arm.com * in namespace Gicv2m.
6110749Smatt.evans@arm.com */
6210749Smatt.evans@arm.comclass Gicv2mFrame : public SimObject
6310749Smatt.evans@arm.com{
6410749Smatt.evans@arm.com  public:
6510749Smatt.evans@arm.com    const Addr          addr;
6610749Smatt.evans@arm.com    const unsigned int  spi_base;
6710749Smatt.evans@arm.com    const unsigned int  spi_len;
6810749Smatt.evans@arm.com
6910749Smatt.evans@arm.com    typedef Gicv2mFrameParams Params;
7010749Smatt.evans@arm.com    Gicv2mFrame(const Params *p) :
7110749Smatt.evans@arm.com        SimObject(p), addr(p->addr), spi_base(p->spi_base), spi_len(p->spi_len)
7210749Smatt.evans@arm.com    {}
7310749Smatt.evans@arm.com};
7410749Smatt.evans@arm.com
7510749Smatt.evans@arm.comclass Gicv2m : public PioDevice
7610749Smatt.evans@arm.com{
7710749Smatt.evans@arm.com  private:
7810749Smatt.evans@arm.com    static const int FRAME_SIZE         = 0x10000;
7910749Smatt.evans@arm.com
8010749Smatt.evans@arm.com    static const int MSI_TYPER          = 0x0008;
8110749Smatt.evans@arm.com    static const int MSI_SETSPI_NSR     = 0x0040;
8210749Smatt.evans@arm.com    static const int PER_ID4            = 0x0fd0;
8310749Smatt.evans@arm.com
8410749Smatt.evans@arm.com    /** Latency for an MMIO operation */
8510749Smatt.evans@arm.com    const Tick pioDelay;
8610749Smatt.evans@arm.com
8710749Smatt.evans@arm.com    /** A set of configured hardware frames */
8810749Smatt.evans@arm.com    std::vector<Gicv2mFrame *> frames;
8910749Smatt.evans@arm.com
9010749Smatt.evans@arm.com    /** Gic to which we fire interrupts */
9110749Smatt.evans@arm.com    BaseGic *gic;
9210749Smatt.evans@arm.com
9310749Smatt.evans@arm.com    /** Count of number of configured frames, as log2(frames) */
9410749Smatt.evans@arm.com    unsigned int log2framenum;
9510749Smatt.evans@arm.com
9610749Smatt.evans@arm.com  public:
9710749Smatt.evans@arm.com    typedef Gicv2mParams Params;
9810749Smatt.evans@arm.com    Gicv2m(const Params *p);
9910749Smatt.evans@arm.com
10010749Smatt.evans@arm.com    /** @{ */
10110749Smatt.evans@arm.com    /** Return the address ranges used by the Gicv2m
10210749Smatt.evans@arm.com     * This is the set of frame addresses
10310749Smatt.evans@arm.com     */
10410749Smatt.evans@arm.com    virtual AddrRangeList getAddrRanges() const;
10510749Smatt.evans@arm.com
10610749Smatt.evans@arm.com    /** A PIO read to the device
10710749Smatt.evans@arm.com     */
10810749Smatt.evans@arm.com    virtual Tick read(PacketPtr pkt);
10910749Smatt.evans@arm.com
11010749Smatt.evans@arm.com    /** A PIO read to the device
11110749Smatt.evans@arm.com     */
11210749Smatt.evans@arm.com    virtual Tick write(PacketPtr pkt);
11310749Smatt.evans@arm.com    /** @} */
11410749Smatt.evans@arm.com
11510749Smatt.evans@arm.com  private:
11610749Smatt.evans@arm.com    /** Determine which frame a PIO access lands in
11710749Smatt.evans@arm.com     */
11810749Smatt.evans@arm.com    int frameFromAddr(Addr a) const;
11910749Smatt.evans@arm.com};
12010749Smatt.evans@arm.com
12110749Smatt.evans@arm.com#endif //__DEV_ARM_GIC_V2M_H__
122