amba_fake.cc revision 8245
112863Sgabeblack@google.com/* 212863Sgabeblack@google.com * Copyright (c) 2010 ARM Limited 312863Sgabeblack@google.com * All rights reserved 412863Sgabeblack@google.com * 512863Sgabeblack@google.com * The license below extends only to copyright in the software and shall 612863Sgabeblack@google.com * not be construed as granting a license to any other intellectual 712863Sgabeblack@google.com * property including but not limited to intellectual property relating 812863Sgabeblack@google.com * to a hardware implementation of the functionality of the software 912863Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1012863Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1112863Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1212863Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1312863Sgabeblack@google.com * 1412863Sgabeblack@google.com * Copyright (c) 2005 The Regents of The University of Michigan 1512863Sgabeblack@google.com * All rights reserved. 1612863Sgabeblack@google.com * 1712863Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1812863Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1912863Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 2012863Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 2112863Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 2212863Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2312863Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2412863Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2512863Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2612863Sgabeblack@google.com * this software without specific prior written permission. 2712863Sgabeblack@google.com * 2812863Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2912863Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3012863Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3112863Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3212950Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3312863Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3412863Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3512863Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3612863Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3712950Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3812863Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3912863Sgabeblack@google.com * 4012863Sgabeblack@google.com * Authors: Ali Saidi 4112863Sgabeblack@google.com */ 4212863Sgabeblack@google.com 4312863Sgabeblack@google.com#include "base/trace.hh" 4412950Sgabeblack@google.com#include "debug/AMBA.hh" 4512863Sgabeblack@google.com#include "dev/arm/amba_fake.hh" 4613045Sgabeblack@google.com#include "mem/packet.hh" 4713045Sgabeblack@google.com#include "mem/packet_access.hh" 4812863Sgabeblack@google.com 4912863Sgabeblack@google.comusing namespace AmbaDev; 5012950Sgabeblack@google.com 5112950Sgabeblack@google.comAmbaFake::AmbaFake(const Params *p) 5212950Sgabeblack@google.com : AmbaDevice(p) 5312950Sgabeblack@google.com{ 5412950Sgabeblack@google.com pioSize = 0xfff; 5512950Sgabeblack@google.com} 5612982Sgabeblack@google.com 5712982Sgabeblack@google.comTick 5812863Sgabeblack@google.comAmbaFake::read(PacketPtr pkt) 5912950Sgabeblack@google.com{ 6012863Sgabeblack@google.com assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 6112950Sgabeblack@google.com 6212950Sgabeblack@google.com Addr daddr = pkt->getAddr() - pioAddr; 6312863Sgabeblack@google.com pkt->allocate(); 6412950Sgabeblack@google.com 6512982Sgabeblack@google.com DPRINTF(AMBA, " read register %#x\n", daddr); 6612982Sgabeblack@google.com 6712982Sgabeblack@google.com pkt->set<uint32_t>(0); 6812982Sgabeblack@google.com if (!readId(pkt, ambaId, pioAddr) && !params()->ignore_access) 6912863Sgabeblack@google.com panic("Tried to read AmbaFake at offset %#x that doesn't exist\n", daddr); 7012863Sgabeblack@google.com 7112863Sgabeblack@google.com pkt->makeAtomicResponse(); 7212863Sgabeblack@google.com return pioDelay; 7312863Sgabeblack@google.com} 7412950Sgabeblack@google.com 7512863Sgabeblack@google.comTick 7612863Sgabeblack@google.comAmbaFake::write(PacketPtr pkt) 7712950Sgabeblack@google.com{ 7812950Sgabeblack@google.com 7912863Sgabeblack@google.com Addr daddr = pkt->getAddr() - pioAddr; 8012863Sgabeblack@google.com pkt->allocate(); 8112863Sgabeblack@google.com 8212950Sgabeblack@google.com if (!params()->ignore_access) 8312863Sgabeblack@google.com panic("Tried to write AmbaFake at offset %#x that doesn't exist\n", daddr); 8412950Sgabeblack@google.com 8512950Sgabeblack@google.com pkt->makeAtomicResponse(); 8612950Sgabeblack@google.com return pioDelay; 8712863Sgabeblack@google.com} 8812863Sgabeblack@google.com 8912950Sgabeblack@google.com 9012950Sgabeblack@google.comAmbaFake * 9112950Sgabeblack@google.comAmbaFakeParams::create() 9212950Sgabeblack@google.com{ 9312950Sgabeblack@google.com return new AmbaFake(this); 9412950Sgabeblack@google.com} 9513045Sgabeblack@google.com