amba_fake.cc revision 9806:3f262c18ad5d
113207Sgabeblack@google.com/*
213207Sgabeblack@google.com * Copyright (c) 2010 ARM Limited
313207Sgabeblack@google.com * All rights reserved
413207Sgabeblack@google.com *
513207Sgabeblack@google.com * The license below extends only to copyright in the software and shall
613207Sgabeblack@google.com * not be construed as granting a license to any other intellectual
713207Sgabeblack@google.com * property including but not limited to intellectual property relating
813207Sgabeblack@google.com * to a hardware implementation of the functionality of the software
913207Sgabeblack@google.com * licensed hereunder.  You may use the software subject to the license
1013207Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated
1113207Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software,
1213207Sgabeblack@google.com * modified or unmodified, in source code or in binary form.
1313207Sgabeblack@google.com *
1413207Sgabeblack@google.com * Copyright (c) 2005 The Regents of The University of Michigan
1513207Sgabeblack@google.com * All rights reserved.
1613207Sgabeblack@google.com *
1713207Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
1813207Sgabeblack@google.com * modification, are permitted provided that the following conditions are
1913207Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
2013207Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
2113207Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
2213207Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
2313207Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
2413207Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
2513207Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
2613207Sgabeblack@google.com * this software without specific prior written permission.
2713207Sgabeblack@google.com *
2813207Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2913207Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3013207Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3113207Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3213207Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3313207Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3413273Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3513207Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3613207Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3713239Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3813207Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3913207Sgabeblack@google.com *
4013207Sgabeblack@google.com * Authors: Ali Saidi
4113207Sgabeblack@google.com */
4213207Sgabeblack@google.com
4313207Sgabeblack@google.com#include "base/trace.hh"
4413207Sgabeblack@google.com#include "debug/AMBA.hh"
4513207Sgabeblack@google.com#include "dev/arm/amba_fake.hh"
4613260Sgabeblack@google.com#include "mem/packet.hh"
4713207Sgabeblack@google.com#include "mem/packet_access.hh"
4813207Sgabeblack@google.com
4913207Sgabeblack@google.comAmbaFake::AmbaFake(const Params *p)
5013207Sgabeblack@google.com    : AmbaPioDevice(p)
5113207Sgabeblack@google.com{
5213207Sgabeblack@google.com    pioSize = 0xfff;
5313207Sgabeblack@google.com}
5413207Sgabeblack@google.com
5513207Sgabeblack@google.comTick
5613207Sgabeblack@google.comAmbaFake::read(PacketPtr pkt)
5713207Sgabeblack@google.com{
5813207Sgabeblack@google.com    assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
5913207Sgabeblack@google.com
6013207Sgabeblack@google.com    Addr daddr = pkt->getAddr() - pioAddr;
6113273Sgabeblack@google.com    pkt->allocate();
6213273Sgabeblack@google.com
6313207Sgabeblack@google.com    DPRINTF(AMBA, " read register %#x\n", daddr);
6413207Sgabeblack@google.com
6513260Sgabeblack@google.com    pkt->set<uint32_t>(0);
6613207Sgabeblack@google.com    if (!readId(pkt, ambaId, pioAddr) && !params()->ignore_access)
6713207Sgabeblack@google.com        panic("Tried to read AmbaFake at offset %#x that doesn't exist\n", daddr);
6813239Sgabeblack@google.com
6913207Sgabeblack@google.com    pkt->makeAtomicResponse();
7013239Sgabeblack@google.com    return pioDelay;
7113239Sgabeblack@google.com}
7213239Sgabeblack@google.com
7313239Sgabeblack@google.comTick
7413239Sgabeblack@google.comAmbaFake::write(PacketPtr pkt)
7513239Sgabeblack@google.com{
7613239Sgabeblack@google.com
7713239Sgabeblack@google.com    Addr daddr = pkt->getAddr() - pioAddr;
7813239Sgabeblack@google.com    pkt->allocate();
7913207Sgabeblack@google.com
8013239Sgabeblack@google.com    if (!params()->ignore_access)
8113207Sgabeblack@google.com        panic("Tried to write AmbaFake at offset %#x that doesn't exist\n", daddr);
8213207Sgabeblack@google.com
8313207Sgabeblack@google.com    pkt->makeAtomicResponse();
8413207Sgabeblack@google.com    return pioDelay;
8513207Sgabeblack@google.com}
8613273Sgabeblack@google.com
8713273Sgabeblack@google.com
8813207Sgabeblack@google.comAmbaFake *
8913207Sgabeblack@google.comAmbaFakeParams::create()
9013207Sgabeblack@google.com{
9113207Sgabeblack@google.com    return new AmbaFake(this);
9213207Sgabeblack@google.com}
9313207Sgabeblack@google.com