gic_v2m.hh revision 10749:ac3611ba911c
12810SN/A/* 29725Sandreas.hansson@arm.com * Copyright (c) 2013 ARM Limited 39663Suri.wiener@arm.com * All rights reserved 49663Suri.wiener@arm.com * 59663Suri.wiener@arm.com * The license below extends only to copyright in the software and shall 69663Suri.wiener@arm.com * not be construed as granting a license to any other intellectual 79663Suri.wiener@arm.com * property including but not limited to intellectual property relating 89663Suri.wiener@arm.com * to a hardware implementation of the functionality of the software 99663Suri.wiener@arm.com * licensed hereunder. You may use the software subject to the license 109663Suri.wiener@arm.com * terms below provided that you ensure that this notice is replicated 119663Suri.wiener@arm.com * unmodified and in its entirety in all distributions of the software, 129663Suri.wiener@arm.com * modified or unmodified, in source code or in binary form. 139663Suri.wiener@arm.com * 142810SN/A * Redistribution and use in source and binary forms, with or without 152810SN/A * modification, are permitted provided that the following conditions are 162810SN/A * met: redistributions of source code must retain the above copyright 172810SN/A * notice, this list of conditions and the following disclaimer; 182810SN/A * redistributions in binary form must reproduce the above copyright 192810SN/A * notice, this list of conditions and the following disclaimer in the 202810SN/A * documentation and/or other materials provided with the distribution; 212810SN/A * neither the name of the copyright holders nor the names of its 222810SN/A * contributors may be used to endorse or promote products derived from 232810SN/A * this software without specific prior written permission. 242810SN/A * 252810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 262810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 272810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 282810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 292810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 302810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 312810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 322810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 332810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 342810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 352810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 362810SN/A * 372810SN/A * Authors: Matt Evans 382810SN/A */ 392810SN/A 402810SN/A/** @file 412810SN/A * Implementiation of a GICv2m MSI shim. 422810SN/A * 432810SN/A * See gic_v2m.cc for an instantiation example. 442810SN/A */ 452810SN/A 462810SN/A#ifndef __DEV_ARM_GIC_V2M_H__ 472810SN/A#define __DEV_ARM_GIC_V2M_H__ 482810SN/A 492810SN/A#include "base/bitunion.hh" 502810SN/A#include "cpu/intr_control.hh" 514626SN/A#include "dev/arm/base_gic.hh" 524626SN/A#include "dev/io_device.hh" 535314SN/A#include "dev/platform.hh" 542810SN/A#include "params/Gicv2m.hh" 552810SN/A#include "params/Gicv2mFrame.hh" 564626SN/A 574626SN/A/** 582810SN/A * Ultimately this class should be embedded in the Gicv2m class, but 592810SN/A * this confuses Python as 'Gicv2m::Frame' gets interpreted as 'Frame' 602810SN/A * in namespace Gicv2m. 613374SN/A */ 629264Sdjordje.kovacevic@arm.comclass Gicv2mFrame : public SimObject 632810SN/A{ 645314SN/A public: 654626SN/A const Addr addr; 664626SN/A const unsigned int spi_base; 679725Sandreas.hansson@arm.com const unsigned int spi_len; 689725Sandreas.hansson@arm.com 699725Sandreas.hansson@arm.com typedef Gicv2mFrameParams Params; 709725Sandreas.hansson@arm.com Gicv2mFrame(const Params *p) : 719725Sandreas.hansson@arm.com SimObject(p), addr(p->addr), spi_base(p->spi_base), spi_len(p->spi_len) 729725Sandreas.hansson@arm.com {} 739725Sandreas.hansson@arm.com}; 749725Sandreas.hansson@arm.com 759725Sandreas.hansson@arm.comclass Gicv2m : public PioDevice 769725Sandreas.hansson@arm.com{ 779725Sandreas.hansson@arm.com private: 789725Sandreas.hansson@arm.com static const int FRAME_SIZE = 0x10000; 799725Sandreas.hansson@arm.com 809725Sandreas.hansson@arm.com static const int MSI_TYPER = 0x0008; 819725Sandreas.hansson@arm.com static const int MSI_SETSPI_NSR = 0x0040; 829725Sandreas.hansson@arm.com static const int PER_ID4 = 0x0fd0; 839725Sandreas.hansson@arm.com 849725Sandreas.hansson@arm.com /** Latency for an MMIO operation */ 859725Sandreas.hansson@arm.com const Tick pioDelay; 869725Sandreas.hansson@arm.com 879725Sandreas.hansson@arm.com /** A set of configured hardware frames */ 889725Sandreas.hansson@arm.com std::vector<Gicv2mFrame *> frames; 899725Sandreas.hansson@arm.com 909725Sandreas.hansson@arm.com /** Gic to which we fire interrupts */ 919725Sandreas.hansson@arm.com BaseGic *gic; 922810SN/A 934626SN/A /** Count of number of configured frames, as log2(frames) */ 944626SN/A unsigned int log2framenum; 954626SN/A 965875Ssteve.reinhardt@amd.com public: 975875Ssteve.reinhardt@amd.com typedef Gicv2mParams Params; 985875Ssteve.reinhardt@amd.com Gicv2m(const Params *p); 995875Ssteve.reinhardt@amd.com 1005875Ssteve.reinhardt@amd.com /** @{ */ 1015875Ssteve.reinhardt@amd.com /** Return the address ranges used by the Gicv2m 1025875Ssteve.reinhardt@amd.com * This is the set of frame addresses 1034871SN/A */ 1044871SN/A virtual AddrRangeList getAddrRanges() const; 1054666SN/A 1064626SN/A /** A PIO read to the device 1075875Ssteve.reinhardt@amd.com */ 1085318SN/A virtual Tick read(PacketPtr pkt); 1095318SN/A 1104626SN/A /** A PIO read to the device 1115318SN/A */ 1125875Ssteve.reinhardt@amd.com virtual Tick write(PacketPtr pkt); 1137823Ssteve.reinhardt@amd.com /** @} */ 1145875Ssteve.reinhardt@amd.com 1154626SN/A private: 1164626SN/A /** Determine which frame a PIO access lands in 1174626SN/A */ 1184903SN/A int frameFromAddr(Addr a) const; 1194903SN/A}; 1204903SN/A 1215314SN/A#endif //__DEV_ARM_GIC_V2M_H__ 1224903SN/A