17584SAli.Saidi@arm.com/*
27584SAli.Saidi@arm.com * Copyright (c) 2010 ARM Limited
37584SAli.Saidi@arm.com * All rights reserved
47584SAli.Saidi@arm.com *
57584SAli.Saidi@arm.com * The license below extends only to copyright in the software and shall
67584SAli.Saidi@arm.com * not be construed as granting a license to any other intellectual
77584SAli.Saidi@arm.com * property including but not limited to intellectual property relating
87584SAli.Saidi@arm.com * to a hardware implementation of the functionality of the software
97584SAli.Saidi@arm.com * licensed hereunder.  You may use the software subject to the license
107584SAli.Saidi@arm.com * terms below provided that you ensure that this notice is replicated
117584SAli.Saidi@arm.com * unmodified and in its entirety in all distributions of the software,
127584SAli.Saidi@arm.com * modified or unmodified, in source code or in binary form.
137584SAli.Saidi@arm.com *
147584SAli.Saidi@arm.com * Copyright (c) 2005 The Regents of The University of Michigan
157584SAli.Saidi@arm.com * All rights reserved.
167584SAli.Saidi@arm.com *
177584SAli.Saidi@arm.com * Redistribution and use in source and binary forms, with or without
187584SAli.Saidi@arm.com * modification, are permitted provided that the following conditions are
197584SAli.Saidi@arm.com * met: redistributions of source code must retain the above copyright
207584SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer;
217584SAli.Saidi@arm.com * redistributions in binary form must reproduce the above copyright
227584SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer in the
237584SAli.Saidi@arm.com * documentation and/or other materials provided with the distribution;
247584SAli.Saidi@arm.com * neither the name of the copyright holders nor the names of its
257584SAli.Saidi@arm.com * contributors may be used to endorse or promote products derived from
267584SAli.Saidi@arm.com * this software without specific prior written permission.
277584SAli.Saidi@arm.com *
287584SAli.Saidi@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
297584SAli.Saidi@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
307584SAli.Saidi@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
317584SAli.Saidi@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
327584SAli.Saidi@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
337584SAli.Saidi@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
347584SAli.Saidi@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
357584SAli.Saidi@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
367584SAli.Saidi@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
377584SAli.Saidi@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
387584SAli.Saidi@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
397584SAli.Saidi@arm.com *
407584SAli.Saidi@arm.com * Authors: Ali Saidi
417584SAli.Saidi@arm.com */
427584SAli.Saidi@arm.com
4311793Sbrandon.potter@amd.com#include "dev/arm/amba_fake.hh"
4411793Sbrandon.potter@amd.com
457584SAli.Saidi@arm.com#include "base/trace.hh"
468245Snate@binkert.org#include "debug/AMBA.hh"
477584SAli.Saidi@arm.com#include "mem/packet.hh"
487584SAli.Saidi@arm.com#include "mem/packet_access.hh"
497584SAli.Saidi@arm.com
507584SAli.Saidi@arm.comAmbaFake::AmbaFake(const Params *p)
5112772Snikos.nikoleris@arm.com    : AmbaPioDevice(p, 0x1000)
527584SAli.Saidi@arm.com{
537584SAli.Saidi@arm.com}
547584SAli.Saidi@arm.com
557584SAli.Saidi@arm.comTick
567584SAli.Saidi@arm.comAmbaFake::read(PacketPtr pkt)
577584SAli.Saidi@arm.com{
587584SAli.Saidi@arm.com    assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
597584SAli.Saidi@arm.com
607584SAli.Saidi@arm.com    Addr daddr = pkt->getAddr() - pioAddr;
617584SAli.Saidi@arm.com
627584SAli.Saidi@arm.com    DPRINTF(AMBA, " read register %#x\n", daddr);
637584SAli.Saidi@arm.com
6413230Sgabeblack@google.com    pkt->setLE<uint32_t>(0);
657587SAli.Saidi@arm.com    if (!readId(pkt, ambaId, pioAddr) && !params()->ignore_access)
667584SAli.Saidi@arm.com        panic("Tried to read AmbaFake at offset %#x that doesn't exist\n", daddr);
677584SAli.Saidi@arm.com
687584SAli.Saidi@arm.com    pkt->makeAtomicResponse();
697584SAli.Saidi@arm.com    return pioDelay;
707584SAli.Saidi@arm.com}
717584SAli.Saidi@arm.com
727584SAli.Saidi@arm.comTick
737584SAli.Saidi@arm.comAmbaFake::write(PacketPtr pkt)
747584SAli.Saidi@arm.com{
757584SAli.Saidi@arm.com
767584SAli.Saidi@arm.com    Addr daddr = pkt->getAddr() - pioAddr;
777584SAli.Saidi@arm.com
787584SAli.Saidi@arm.com    if (!params()->ignore_access)
797584SAli.Saidi@arm.com        panic("Tried to write AmbaFake at offset %#x that doesn't exist\n", daddr);
807584SAli.Saidi@arm.com
817584SAli.Saidi@arm.com    pkt->makeAtomicResponse();
827584SAli.Saidi@arm.com    return pioDelay;
837584SAli.Saidi@arm.com}
847584SAli.Saidi@arm.com
857584SAli.Saidi@arm.com
867584SAli.Saidi@arm.comAmbaFake *
877584SAli.Saidi@arm.comAmbaFakeParams::create()
887584SAli.Saidi@arm.com{
897584SAli.Saidi@arm.com    return new AmbaFake(this);
907584SAli.Saidi@arm.com}
91