rv_ctrl.cc revision 7733:08d6a773d1b6
16019Shines@cs.fsu.edu/* 211495Sandreas.sandberg@arm.com * Copyright (c) 2010 ARM Limited 37093Sgblack@eecs.umich.edu * All rights reserved 47093Sgblack@eecs.umich.edu * 57093Sgblack@eecs.umich.edu * The license below extends only to copyright in the software and shall 67093Sgblack@eecs.umich.edu * not be construed as granting a license to any other intellectual 77093Sgblack@eecs.umich.edu * property including but not limited to intellectual property relating 87093Sgblack@eecs.umich.edu * to a hardware implementation of the functionality of the software 97093Sgblack@eecs.umich.edu * licensed hereunder. You may use the software subject to the license 107093Sgblack@eecs.umich.edu * terms below provided that you ensure that this notice is replicated 117093Sgblack@eecs.umich.edu * unmodified and in its entirety in all distributions of the software, 127093Sgblack@eecs.umich.edu * modified or unmodified, in source code or in binary form. 137093Sgblack@eecs.umich.edu * 146019Shines@cs.fsu.edu * Redistribution and use in source and binary forms, with or without 156019Shines@cs.fsu.edu * modification, are permitted provided that the following conditions are 166019Shines@cs.fsu.edu * met: redistributions of source code must retain the above copyright 176019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer; 186019Shines@cs.fsu.edu * redistributions in binary form must reproduce the above copyright 196019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer in the 206019Shines@cs.fsu.edu * documentation and/or other materials provided with the distribution; 216019Shines@cs.fsu.edu * neither the name of the copyright holders nor the names of its 226019Shines@cs.fsu.edu * contributors may be used to endorse or promote products derived from 236019Shines@cs.fsu.edu * this software without specific prior written permission. 246019Shines@cs.fsu.edu * 256019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 266019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 276019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 286019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 296019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 306019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 316019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 326019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 336019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 346019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 356019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 366019Shines@cs.fsu.edu * 376019Shines@cs.fsu.edu * Authors: Ali Saidi 386019Shines@cs.fsu.edu */ 396019Shines@cs.fsu.edu 407399SAli.Saidi@ARM.com#include "base/trace.hh" 417399SAli.Saidi@ARM.com#include "dev/arm/rv_ctrl.hh" 426019Shines@cs.fsu.edu#include "mem/packet.hh" 436019Shines@cs.fsu.edu#include "mem/packet_access.hh" 446019Shines@cs.fsu.edu 4510873Sandreas.sandberg@arm.comRealViewCtrl::RealViewCtrl(Params *p) 4610873Sandreas.sandberg@arm.com : BasicPioDevice(p) 4710474Sandreas.hansson@arm.com{ 486019Shines@cs.fsu.edu pioSize = 0xD4; 496019Shines@cs.fsu.edu} 506019Shines@cs.fsu.edu 516116Snate@binkert.orgTick 526019Shines@cs.fsu.eduRealViewCtrl::read(PacketPtr pkt) 538782Sgblack@eecs.umich.edu{ 548756Sgblack@eecs.umich.edu assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 5510037SARM gem5 Developers assert(pkt->getSize() == 4); 5610037SARM gem5 Developers Addr daddr = pkt->getAddr() - pioAddr; 576019Shines@cs.fsu.edu pkt->allocate(); 586019Shines@cs.fsu.edu 596019Shines@cs.fsu.edu switch(daddr) { 606019Shines@cs.fsu.edu case ProcId: 6110024Sdam.sunwoo@arm.com pkt->set(params()->proc_id); 626019Shines@cs.fsu.edu break; 638232Snate@binkert.org case Clock24: 648232Snate@binkert.org Tick clk; 658232Snate@binkert.org clk = (Tick)(curTick / (24 * SimClock::Float::MHz)); 666116Snate@binkert.org pkt->set((uint32_t)(clk)); 676116Snate@binkert.org break; 688756Sgblack@eecs.umich.edu case Flash: 696019Shines@cs.fsu.edu pkt->set<uint32_t>(0); 706019Shines@cs.fsu.edu break; 716019Shines@cs.fsu.edu default: 726019Shines@cs.fsu.edu panic("Tried to read RealView I/O at offset %#x that doesn't exist\n", daddr); 736019Shines@cs.fsu.edu break; 7410037SARM gem5 Developers } 7510037SARM gem5 Developers pkt->makeAtomicResponse(); 7610418Sandreas.hansson@arm.com return pioDelay; 7710418Sandreas.hansson@arm.com 7811395Sandreas.sandberg@arm.com} 7910537Sandreas.hansson@arm.com 8010537Sandreas.hansson@arm.comTick 8111152Smitch.hayenga@arm.comRealViewCtrl::write(PacketPtr pkt) 826019Shines@cs.fsu.edu{ 8310037SARM gem5 Developers assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 847399SAli.Saidi@ARM.com 8510037SARM gem5 Developers Addr daddr = pkt->getAddr() - pioAddr; 8610037SARM gem5 Developers switch (daddr) { 8710037SARM gem5 Developers case Flash: 8810037SARM gem5 Developers break; 896019Shines@cs.fsu.edu default: 906019Shines@cs.fsu.edu panic("Tried to write RVIO at offset %#x that doesn't exist\n", daddr); 916019Shines@cs.fsu.edu break; 926019Shines@cs.fsu.edu } 9310037SARM gem5 Developers pkt->makeAtomicResponse(); 9410037SARM gem5 Developers return pioDelay; 9510037SARM gem5 Developers} 9610037SARM gem5 Developers 9710037SARM gem5 Developersvoid 9810037SARM gem5 DevelopersRealViewCtrl::serialize(std::ostream &os) 9910037SARM gem5 Developers{ 10010037SARM gem5 Developers} 10110037SARM gem5 Developers 10210037SARM gem5 Developersvoid 10310037SARM gem5 DevelopersRealViewCtrl::unserialize(Checkpoint *cp, const std::string §ion) 10410717Sandreas.hansson@arm.com{ 10510037SARM gem5 Developers} 10610037SARM gem5 Developers 10710717Sandreas.hansson@arm.comRealViewCtrl * 1086019Shines@cs.fsu.eduRealViewCtrlParams::create() 1096019Shines@cs.fsu.edu{ 1107694SAli.Saidi@ARM.com return new RealViewCtrl(this); 1117694SAli.Saidi@ARM.com} 1127694SAli.Saidi@ARM.com