port.cc revision 2641
12405SN/A/* 22405SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 32405SN/A * All rights reserved. 42405SN/A * 52405SN/A * Redistribution and use in source and binary forms, with or without 62405SN/A * modification, are permitted provided that the following conditions are 72405SN/A * met: redistributions of source code must retain the above copyright 82405SN/A * notice, this list of conditions and the following disclaimer; 92405SN/A * redistributions in binary form must reproduce the above copyright 102405SN/A * notice, this list of conditions and the following disclaimer in the 112405SN/A * documentation and/or other materials provided with the distribution; 122405SN/A * neither the name of the copyright holders nor the names of its 132405SN/A * contributors may be used to endorse or promote products derived from 142405SN/A * this software without specific prior written permission. 152405SN/A * 162405SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172405SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182405SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192405SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202405SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212405SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222405SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232405SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242405SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252405SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262405SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272405SN/A */ 282405SN/A 292405SN/A/** 302405SN/A * @file Port object definitions. 312405SN/A */ 322405SN/A 332405SN/A#include "base/chunk_generator.hh" 342623SN/A#include "mem/packet_impl.hh" 352405SN/A#include "mem/port.hh" 362405SN/A 372405SN/Avoid 382641Sstever@eecs.umich.eduPort::blobHelper(Addr addr, uint8_t *p, int size, Packet::Command cmd) 392405SN/A{ 402532SN/A Request req(false); 412641Sstever@eecs.umich.edu Packet pkt(&req, cmd, Packet::Broadcast); 422405SN/A 432406SN/A for (ChunkGenerator gen(addr, size, peerBlockSize()); 442406SN/A !gen.done(); gen.next()) { 452641Sstever@eecs.umich.edu req.setPaddr(gen.addr()); 462641Sstever@eecs.umich.edu req.setSize(gen.size()); 472641Sstever@eecs.umich.edu pkt.reinitFromRequest(); 482566SN/A pkt.dataStatic(p); 492630SN/A sendFunctional(&pkt); 502405SN/A p += gen.size(); 512405SN/A } 522405SN/A} 532405SN/A 542405SN/Avoid 552461SN/APort::writeBlob(Addr addr, uint8_t *p, int size) 562405SN/A{ 572641Sstever@eecs.umich.edu blobHelper(addr, p, size, Packet::WriteReq); 582405SN/A} 592405SN/A 602405SN/Avoid 612461SN/APort::readBlob(Addr addr, uint8_t *p, int size) 622405SN/A{ 632641Sstever@eecs.umich.edu blobHelper(addr, p, size, Packet::ReadReq); 642405SN/A} 652405SN/A 662420SN/Avoid 672461SN/APort::memsetBlob(Addr addr, uint8_t val, int size) 682420SN/A{ 692420SN/A // quick and dirty... 702420SN/A uint8_t *buf = new uint8_t[size]; 712420SN/A 722420SN/A memset(buf, val, size); 732641Sstever@eecs.umich.edu blobHelper(addr, buf, size, Packet::WriteReq); 742421SN/A 752548SN/A delete [] buf; 762420SN/A} 77