12521SN/A/* 29814Sandreas.hansson@arm.com * Copyright (c) 2011,2013 ARM Limited 38706Sandreas.hansson@arm.com * All rights reserved 48706Sandreas.hansson@arm.com * 58706Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68706Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78706Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88706Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98706Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108706Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118706Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128706Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138706Sandreas.hansson@arm.com * 142521SN/A * Copyright (c) 2006 The Regents of The University of Michigan 152521SN/A * All rights reserved. 162521SN/A * 172521SN/A * Redistribution and use in source and binary forms, with or without 182521SN/A * modification, are permitted provided that the following conditions are 192521SN/A * met: redistributions of source code must retain the above copyright 202521SN/A * notice, this list of conditions and the following disclaimer; 212521SN/A * redistributions in binary form must reproduce the above copyright 222521SN/A * notice, this list of conditions and the following disclaimer in the 232521SN/A * documentation and/or other materials provided with the distribution; 242521SN/A * neither the name of the copyright holders nor the names of its 252521SN/A * contributors may be used to endorse or promote products derived from 262521SN/A * this software without specific prior written permission. 272521SN/A * 282521SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292521SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302521SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312521SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322521SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332521SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342521SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352521SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362521SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372521SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382521SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392665SN/A * 402665SN/A * Authors: Ali Saidi 418706Sandreas.hansson@arm.com * Andreas Hansson 422521SN/A */ 432521SN/A 442521SN/A/** 452982SN/A * @file 462982SN/A * Port object definitions. 472521SN/A */ 482521SN/A 4911793Sbrandon.potter@amd.com#include "mem/fs_translating_port_proxy.hh" 5011793Sbrandon.potter@amd.com 519850Sandreas.hansson@arm.com#include "arch/vtophys.hh" 522521SN/A#include "base/chunk_generator.hh" 538706Sandreas.hansson@arm.com#include "cpu/base.hh" 544070SN/A#include "cpu/thread_context.hh" 559814Sandreas.hansson@arm.com#include "sim/system.hh" 568706Sandreas.hansson@arm.com 578706Sandreas.hansson@arm.comFSTranslatingPortProxy::FSTranslatingPortProxy(ThreadContext *tc) 5814197Sgabeblack@google.com : PortProxy(tc->getCpuPtr()->getSendFunctional(), 599814Sandreas.hansson@arm.com tc->getSystemPtr()->cacheLineSize()), _tc(tc) 608706Sandreas.hansson@arm.com{ 618706Sandreas.hansson@arm.com} 628706Sandreas.hansson@arm.com 6314196Sgabeblack@google.comFSTranslatingPortProxy::FSTranslatingPortProxy( 6414196Sgabeblack@google.com SendFunctionalFunc func, unsigned int cacheLineSize) 6514196Sgabeblack@google.com : PortProxy(func, cacheLineSize), _tc(NULL) 6614196Sgabeblack@google.com{ 6714196Sgabeblack@google.com} 6814196Sgabeblack@google.com 6914196Sgabeblack@google.comFSTranslatingPortProxy::FSTranslatingPortProxy( 7014196Sgabeblack@google.com MasterPort &port, unsigned int cacheLineSize) 719814Sandreas.hansson@arm.com : PortProxy(port, cacheLineSize), _tc(NULL) 728706Sandreas.hansson@arm.com{ 738706Sandreas.hansson@arm.com} 748706Sandreas.hansson@arm.com 7514008Sgabeblack@google.combool 7614009Sgabeblack@google.comFSTranslatingPortProxy::tryReadBlob(Addr addr, void *p, int size) const 772521SN/A{ 782521SN/A Addr paddr; 792521SN/A for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done(); 808706Sandreas.hansson@arm.com gen.next()) 812521SN/A { 828706Sandreas.hansson@arm.com if (_tc) 838706Sandreas.hansson@arm.com paddr = TheISA::vtophys(_tc,gen.addr()); 842521SN/A else 852521SN/A paddr = TheISA::vtophys(gen.addr()); 862521SN/A 8712532Sandreas.sandberg@arm.com PortProxy::readBlobPhys(paddr, 0, p, gen.size()); 8814009Sgabeblack@google.com p = static_cast<uint8_t *>(p) + gen.size(); 892521SN/A } 9014008Sgabeblack@google.com return true; 912521SN/A} 922521SN/A 9314008Sgabeblack@google.combool 9414008Sgabeblack@google.comFSTranslatingPortProxy::tryWriteBlob( 9514009Sgabeblack@google.com Addr addr, const void *p, int size) const 962521SN/A{ 972521SN/A Addr paddr; 982521SN/A for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done(); 998706Sandreas.hansson@arm.com gen.next()) 1002521SN/A { 1018706Sandreas.hansson@arm.com if (_tc) 1028706Sandreas.hansson@arm.com paddr = TheISA::vtophys(_tc,gen.addr()); 1032521SN/A else 1042521SN/A paddr = TheISA::vtophys(gen.addr()); 1052521SN/A 10612532Sandreas.sandberg@arm.com PortProxy::writeBlobPhys(paddr, 0, p, gen.size()); 10714009Sgabeblack@google.com p = static_cast<const uint8_t *>(p) + gen.size(); 1082521SN/A } 10914008Sgabeblack@google.com return true; 1102521SN/A} 1112521SN/A 11214008Sgabeblack@google.combool 11314008Sgabeblack@google.comFSTranslatingPortProxy::tryMemsetBlob(Addr address, uint8_t v, int size) const 1148706Sandreas.hansson@arm.com{ 1158706Sandreas.hansson@arm.com Addr paddr; 1168706Sandreas.hansson@arm.com for (ChunkGenerator gen(address, size, TheISA::PageBytes); !gen.done(); 1178706Sandreas.hansson@arm.com gen.next()) 1188706Sandreas.hansson@arm.com { 1198706Sandreas.hansson@arm.com if (_tc) 1208706Sandreas.hansson@arm.com paddr = TheISA::vtophys(_tc,gen.addr()); 1218706Sandreas.hansson@arm.com else 1228706Sandreas.hansson@arm.com paddr = TheISA::vtophys(gen.addr()); 1238706Sandreas.hansson@arm.com 12412532Sandreas.sandberg@arm.com PortProxy::memsetBlobPhys(paddr, 0, v, gen.size()); 1258706Sandreas.hansson@arm.com } 12614008Sgabeblack@google.com return true; 1278706Sandreas.hansson@arm.com} 128