port_proxy.cc revision 10653
18853Sandreas.hansson@arm.com/* 28853Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited 38853Sandreas.hansson@arm.com * All rights reserved 48853Sandreas.hansson@arm.com * 58853Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68853Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78853Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88853Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98853Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108853Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118853Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128853Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138853Sandreas.hansson@arm.com * 148853Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 158853Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 168853Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 178853Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 188853Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 198853Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 208853Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 218853Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 228853Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 238853Sandreas.hansson@arm.com * this software without specific prior written permission. 248853Sandreas.hansson@arm.com * 258853Sandreas.hansson@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 268853Sandreas.hansson@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 278853Sandreas.hansson@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 288853Sandreas.hansson@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 298853Sandreas.hansson@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 308853Sandreas.hansson@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 318853Sandreas.hansson@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 328853Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 338853Sandreas.hansson@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 348853Sandreas.hansson@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 358853Sandreas.hansson@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 368853Sandreas.hansson@arm.com * 378853Sandreas.hansson@arm.com * Authors: Andreas Hansson 388853Sandreas.hansson@arm.com */ 398853Sandreas.hansson@arm.com 408853Sandreas.hansson@arm.com#include "base/chunk_generator.hh" 418853Sandreas.hansson@arm.com#include "mem/port_proxy.hh" 428853Sandreas.hansson@arm.com 438853Sandreas.hansson@arm.comvoid 4410564Sandreas.hansson@arm.comPortProxy::readBlob(Addr addr, uint8_t *p, int size) const 458853Sandreas.hansson@arm.com{ 4610564Sandreas.hansson@arm.com for (ChunkGenerator gen(addr, size, _cacheLineSize); !gen.done(); 4710564Sandreas.hansson@arm.com gen.next()) { 4810653Sandreas.hansson@arm.com Request req(gen.addr(), gen.size(), 0, Request::funcMasterId); 4910564Sandreas.hansson@arm.com Packet pkt(&req, MemCmd::ReadReq); 508853Sandreas.hansson@arm.com pkt.dataStatic(p); 518853Sandreas.hansson@arm.com _port.sendFunctional(&pkt); 528853Sandreas.hansson@arm.com p += gen.size(); 538853Sandreas.hansson@arm.com } 548853Sandreas.hansson@arm.com} 558853Sandreas.hansson@arm.com 568853Sandreas.hansson@arm.comvoid 5710564Sandreas.hansson@arm.comPortProxy::writeBlob(Addr addr, const uint8_t *p, int size) const 5810564Sandreas.hansson@arm.com{ 5910564Sandreas.hansson@arm.com for (ChunkGenerator gen(addr, size, _cacheLineSize); !gen.done(); 6010564Sandreas.hansson@arm.com gen.next()) { 6110653Sandreas.hansson@arm.com Request req(gen.addr(), gen.size(), 0, Request::funcMasterId); 6210564Sandreas.hansson@arm.com Packet pkt(&req, MemCmd::WriteReq); 6310564Sandreas.hansson@arm.com pkt.dataStaticConst(p); 6410564Sandreas.hansson@arm.com _port.sendFunctional(&pkt); 6510564Sandreas.hansson@arm.com p += gen.size(); 6610564Sandreas.hansson@arm.com } 6710564Sandreas.hansson@arm.com} 6810564Sandreas.hansson@arm.com 6910564Sandreas.hansson@arm.comvoid 708861Sandreas.hansson@arm.comPortProxy::memsetBlob(Addr addr, uint8_t v, int size) const 718853Sandreas.hansson@arm.com{ 728853Sandreas.hansson@arm.com // quick and dirty... 738853Sandreas.hansson@arm.com uint8_t *buf = new uint8_t[size]; 748853Sandreas.hansson@arm.com 758853Sandreas.hansson@arm.com std::memset(buf, v, size); 7610564Sandreas.hansson@arm.com PortProxy::writeBlob(addr, buf, size); 778853Sandreas.hansson@arm.com 788853Sandreas.hansson@arm.com delete [] buf; 798853Sandreas.hansson@arm.com} 80