port.cc revision 2642:c162e0359b49
12023SN/A/* 25268Sksewell@umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan 35254Sksewell@umich.edu * All rights reserved. 45254Sksewell@umich.edu * 52023SN/A * Redistribution and use in source and binary forms, with or without 65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 145254Sksewell@umich.edu * this software without specific prior written permission. 155254Sksewell@umich.edu * 162023SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275254Sksewell@umich.edu */ 282665Ssaidi@eecs.umich.edu 295254Sksewell@umich.edu/** 305254Sksewell@umich.edu * @file Port object definitions. 315222Sksewell@umich.edu */ 322023SN/A 332023SN/A#include "base/chunk_generator.hh" 342028SN/A#include "base/trace.hh" 352028SN/A#include "mem/packet_impl.hh" 362023SN/A#include "mem/port.hh" 378229Snate@binkert.org 382597SN/Avoid 396216Snate@binkert.orgPort::setPeer(Port *port) 405222Sksewell@umich.edu{ 418542Sgblack@eecs.umich.edu DPRINTF(Config, "setting peer to %s\n", port->name()); 422023SN/A peer = port; 437811Ssteve.reinhardt@amd.com} 442239SN/A 452131SN/Avoid 462023SN/APort::blobHelper(Addr addr, uint8_t *p, int size, Packet::Command cmd) 472525SN/A{ 486378Sgblack@eecs.umich.edu Request req(false); 492023SN/A Packet pkt(&req, cmd, Packet::Broadcast); 506378Sgblack@eecs.umich.edu 513093Sksewell@umich.edu for (ChunkGenerator gen(addr, size, peerBlockSize()); 526378Sgblack@eecs.umich.edu !gen.done(); gen.next()) { 536378Sgblack@eecs.umich.edu req.setPaddr(gen.addr()); 542239SN/A req.setSize(gen.size()); 556378Sgblack@eecs.umich.edu pkt.reinitFromRequest(); 566378Sgblack@eecs.umich.edu pkt.dataStatic(p); 576378Sgblack@eecs.umich.edu sendFunctional(&pkt); 586378Sgblack@eecs.umich.edu p += gen.size(); 595222Sksewell@umich.edu } 605222Sksewell@umich.edu} 616378Sgblack@eecs.umich.edu 626378Sgblack@eecs.umich.eduvoid 636378Sgblack@eecs.umich.eduPort::writeBlob(Addr addr, uint8_t *p, int size) 646378Sgblack@eecs.umich.edu{ 655222Sksewell@umich.edu blobHelper(addr, p, size, Packet::WriteReq); 666378Sgblack@eecs.umich.edu} 676378Sgblack@eecs.umich.edu 686378Sgblack@eecs.umich.eduvoid 696378Sgblack@eecs.umich.eduPort::readBlob(Addr addr, uint8_t *p, int size) 705222Sksewell@umich.edu{ 716378Sgblack@eecs.umich.edu blobHelper(addr, p, size, Packet::ReadReq); 726378Sgblack@eecs.umich.edu} 736378Sgblack@eecs.umich.edu 746378Sgblack@eecs.umich.eduvoid 756378Sgblack@eecs.umich.eduPort::memsetBlob(Addr addr, uint8_t val, int size) 766378Sgblack@eecs.umich.edu{ 775222Sksewell@umich.edu // quick and dirty... 786378Sgblack@eecs.umich.edu uint8_t *buf = new uint8_t[size]; 796378Sgblack@eecs.umich.edu 806378Sgblack@eecs.umich.edu memset(buf, val, size); 816378Sgblack@eecs.umich.edu blobHelper(addr, buf, size, Packet::WriteReq); 825222Sksewell@umich.edu 836378Sgblack@eecs.umich.edu delete [] buf; 846378Sgblack@eecs.umich.edu} 856378Sgblack@eecs.umich.edu