a9scu.cc revision 8282
112904Sgabeblack@google.com/* 212904Sgabeblack@google.com * Copyright (c) 2010 ARM Limited 312904Sgabeblack@google.com * All rights reserved 412904Sgabeblack@google.com * 512904Sgabeblack@google.com * The license below extends only to copyright in the software and shall 612904Sgabeblack@google.com * not be construed as granting a license to any other intellectual 712904Sgabeblack@google.com * property including but not limited to intellectual property relating 812904Sgabeblack@google.com * to a hardware implementation of the functionality of the software 912904Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1012904Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1112935Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1212935Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1312935Sgabeblack@google.com * 1412935Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1512935Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1612904Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 1712904Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1813526Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1913526Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2013526Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2113526Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2212904Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2312904Sgabeblack@google.com * this software without specific prior written permission. 2412904Sgabeblack@google.com * 2512904Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2612906Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2712910Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2812906Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2912906Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3012906Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3112906Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3212936Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3312936Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3412936Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3512936Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3613050Sgabeblack@google.com * 3713050Sgabeblack@google.com * Authors: Ali Saidi 3813050Sgabeblack@google.com */ 3913050Sgabeblack@google.com 4012936Sgabeblack@google.com#include "base/intmath.hh" 4112936Sgabeblack@google.com#include "base/trace.hh" 4212936Sgabeblack@google.com#include "dev/arm/a9scu.hh" 4312936Sgabeblack@google.com#include "mem/packet.hh" 4412936Sgabeblack@google.com#include "mem/packet_access.hh" 4512936Sgabeblack@google.com#include "sim/system.hh" 4612947Sgabeblack@google.com 4712947Sgabeblack@google.comA9SCU::A9SCU(Params *p) 4812947Sgabeblack@google.com : BasicPioDevice(p) 4912947Sgabeblack@google.com{ 5012947Sgabeblack@google.com pioSize = 0x60; 5112947Sgabeblack@google.com} 5213266Sgabeblack@google.com 5313266Sgabeblack@google.comTick 5413266Sgabeblack@google.comA9SCU::read(PacketPtr pkt) 5513266Sgabeblack@google.com{ 5613266Sgabeblack@google.com assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 5713266Sgabeblack@google.com assert(pkt->getSize() == 4); 5813326Sgabeblack@google.com Addr daddr = pkt->getAddr() - pioAddr; 5913326Sgabeblack@google.com pkt->allocate(); 6013326Sgabeblack@google.com 6113326Sgabeblack@google.com switch(daddr) { 6213326Sgabeblack@google.com case Control: 6312904Sgabeblack@google.com pkt->set(1); // SCU already enabled 6412904Sgabeblack@google.com break; 6512904Sgabeblack@google.com case Config: 66 assert(sys->numContexts() <= 4); 67 int smp_bits, core_cnt; 68 smp_bits = power(2,sys->numContexts()) - 1; 69 core_cnt = sys->numContexts() - 1; 70 pkt->set(smp_bits << 4 | core_cnt); 71 break; 72 default: 73 // Only configuration register is implemented 74 panic("Tried to read SCU at offset %#x\n", daddr); 75 break; 76 } 77 pkt->makeAtomicResponse(); 78 return pioDelay; 79 80} 81 82Tick 83A9SCU::write(PacketPtr pkt) 84{ 85 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 86 87 Addr daddr = pkt->getAddr() - pioAddr; 88 switch (daddr) { 89 default: 90 // Nothing implemented at this point 91 panic("Tried to write SCU at offset %#x\n", daddr); 92 break; 93 } 94 pkt->makeAtomicResponse(); 95 return pioDelay; 96} 97 98A9SCU * 99A9SCUParams::create() 100{ 101 return new A9SCU(this); 102} 103