amba_fake.cc revision 8245
113511Sgabeblack@google.com/* 213511Sgabeblack@google.com * Copyright (c) 2010 ARM Limited 313511Sgabeblack@google.com * All rights reserved 413511Sgabeblack@google.com * 513511Sgabeblack@google.com * The license below extends only to copyright in the software and shall 613511Sgabeblack@google.com * not be construed as granting a license to any other intellectual 713511Sgabeblack@google.com * property including but not limited to intellectual property relating 813511Sgabeblack@google.com * to a hardware implementation of the functionality of the software 913511Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1013511Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1113511Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1213511Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1313511Sgabeblack@google.com * 1413511Sgabeblack@google.com * Copyright (c) 2005 The Regents of The University of Michigan 1513511Sgabeblack@google.com * All rights reserved. 1613511Sgabeblack@google.com * 1713511Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1813511Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1913511Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 2013511Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 2113511Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 2213511Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2313511Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2413511Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2513511Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2613511Sgabeblack@google.com * this software without specific prior written permission. 2713511Sgabeblack@google.com * 2813511Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2913511Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3013511Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3113511Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3213511Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3313511Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3413511Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3513511Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3613511Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3713511Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3813511Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3913511Sgabeblack@google.com * 4013511Sgabeblack@google.com * Authors: Ali Saidi 4113511Sgabeblack@google.com */ 4213511Sgabeblack@google.com 4313511Sgabeblack@google.com#include "base/trace.hh" 4413511Sgabeblack@google.com#include "debug/AMBA.hh" 4513511Sgabeblack@google.com#include "dev/arm/amba_fake.hh" 4613511Sgabeblack@google.com#include "mem/packet.hh" 4713511Sgabeblack@google.com#include "mem/packet_access.hh" 4813511Sgabeblack@google.com 4913511Sgabeblack@google.comusing namespace AmbaDev; 5013511Sgabeblack@google.com 5113511Sgabeblack@google.comAmbaFake::AmbaFake(const Params *p) 5213511Sgabeblack@google.com : AmbaDevice(p) 5313511Sgabeblack@google.com{ 5413511Sgabeblack@google.com pioSize = 0xfff; 5513511Sgabeblack@google.com} 5613511Sgabeblack@google.com 5713511Sgabeblack@google.comTick 5813511Sgabeblack@google.comAmbaFake::read(PacketPtr pkt) 5913511Sgabeblack@google.com{ 6013511Sgabeblack@google.com assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 6113511Sgabeblack@google.com 6213511Sgabeblack@google.com Addr daddr = pkt->getAddr() - pioAddr; 6313511Sgabeblack@google.com pkt->allocate(); 6413511Sgabeblack@google.com 6513511Sgabeblack@google.com DPRINTF(AMBA, " read register %#x\n", daddr); 6613511Sgabeblack@google.com 6713511Sgabeblack@google.com pkt->set<uint32_t>(0); 6813511Sgabeblack@google.com if (!readId(pkt, ambaId, pioAddr) && !params()->ignore_access) 6913511Sgabeblack@google.com panic("Tried to read AmbaFake at offset %#x that doesn't exist\n", daddr); 7013511Sgabeblack@google.com 7113511Sgabeblack@google.com pkt->makeAtomicResponse(); 7213511Sgabeblack@google.com return pioDelay; 7313511Sgabeblack@google.com} 7413511Sgabeblack@google.com 7513511Sgabeblack@google.comTick 7613511Sgabeblack@google.comAmbaFake::write(PacketPtr pkt) 7713511Sgabeblack@google.com{ 7813511Sgabeblack@google.com 7913511Sgabeblack@google.com Addr daddr = pkt->getAddr() - pioAddr; 8013511Sgabeblack@google.com pkt->allocate(); 8113511Sgabeblack@google.com 8213511Sgabeblack@google.com if (!params()->ignore_access) 8313511Sgabeblack@google.com panic("Tried to write AmbaFake at offset %#x that doesn't exist\n", daddr); 8413511Sgabeblack@google.com 8513511Sgabeblack@google.com pkt->makeAtomicResponse(); 8613511Sgabeblack@google.com return pioDelay; 8713511Sgabeblack@google.com} 8813511Sgabeblack@google.com 8913511Sgabeblack@google.com 9013511Sgabeblack@google.comAmbaFake * 9113511Sgabeblack@google.comAmbaFakeParams::create() 9213511Sgabeblack@google.com{ 9313511Sgabeblack@google.com return new AmbaFake(this); 9413511Sgabeblack@google.com} 9513511Sgabeblack@google.com