fs_translating_port_proxy.cc revision 14019:4732393f8210
18504SN/A/* 28504SN/A * Copyright (c) 2011,2013 ARM Limited 38504SN/A * All rights reserved 49988Snilay@cs.wisc.edu * 58825Snilay@cs.wisc.edu * The license below extends only to copyright in the software and shall 69988Snilay@cs.wisc.edu * not be construed as granting a license to any other intellectual 78504SN/A * property including but not limited to intellectual property relating 88504SN/A * to a hardware implementation of the functionality of the software 98504SN/A * licensed hereunder. You may use the software subject to the license 108504SN/A * terms below provided that you ensure that this notice is replicated 118504SN/A * unmodified and in its entirety in all distributions of the software, 128504SN/A * modified or unmodified, in source code or in binary form. 1310315Snilay@cs.wisc.edu * 148504SN/A * Copyright (c) 2006 The Regents of The University of Michigan 158504SN/A * All rights reserved. 169885Sstever@gmail.com * 179885Sstever@gmail.com * Redistribution and use in source and binary forms, with or without 188504SN/A * modification, are permitted provided that the following conditions are 199988Snilay@cs.wisc.edu * met: redistributions of source code must retain the above copyright 208504SN/A * notice, this list of conditions and the following disclaimer; 218504SN/A * redistributions in binary form must reproduce the above copyright 228504SN/A * notice, this list of conditions and the following disclaimer in the 2310549Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2410315Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its 258504SN/A * contributors may be used to endorse or promote products derived from 2610242Ssteve.reinhardt@amd.com * this software without specific prior written permission. 278504SN/A * 289449SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 298504SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 308673SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3110540Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 328504SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 338504SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 348504SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 358504SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 368504SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 378504SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 388504SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 398504SN/A * 408504SN/A * Authors: Ali Saidi 418963Sgblack@eecs.umich.edu * Andreas Hansson 428504SN/A */ 438504SN/A 448504SN/A/** 458504SN/A * @file 469988Snilay@cs.wisc.edu * Port object definitions. 478504SN/A */ 488504SN/A 498504SN/A#include "mem/fs_translating_port_proxy.hh" 508504SN/A 518504SN/A#include "arch/vtophys.hh" 528504SN/A#include "base/chunk_generator.hh" 538504SN/A#include "cpu/base.hh" 548504SN/A#include "cpu/thread_context.hh" 558504SN/A#include "sim/system.hh" 568504SN/A 579988Snilay@cs.wisc.eduFSTranslatingPortProxy::FSTranslatingPortProxy(ThreadContext *tc) 588504SN/A : PortProxy(tc->getCpuPtr()->getDataPort(), 598504SN/A tc->getSystemPtr()->cacheLineSize()), _tc(tc) 608504SN/A{ 618504SN/A} 628835SAli.Saidi@ARM.com 638835SAli.Saidi@ARM.comFSTranslatingPortProxy::FSTranslatingPortProxy(MasterPort &port, 649885Sstever@gmail.com unsigned int cacheLineSize) 658835SAli.Saidi@ARM.com : PortProxy(port, cacheLineSize), _tc(NULL) 669988Snilay@cs.wisc.edu{ 678835SAli.Saidi@ARM.com} 688835SAli.Saidi@ARM.com 698835SAli.Saidi@ARM.combool 708963Sgblack@eecs.umich.eduFSTranslatingPortProxy::tryReadBlob(Addr addr, void *p, int size) const 718963Sgblack@eecs.umich.edu{ 728835SAli.Saidi@ARM.com Addr paddr; 738504SN/A for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done(); 748504SN/A gen.next()) 759885Sstever@gmail.com { 768504SN/A if (_tc) 779988Snilay@cs.wisc.edu paddr = TheISA::vtophys(_tc,gen.addr()); 7810451Snilay@cs.wisc.edu else 798721SN/A paddr = TheISA::vtophys(gen.addr()); 808721SN/A 818963Sgblack@eecs.umich.edu PortProxy::readBlobPhys(paddr, 0, p, gen.size()); 829885Sstever@gmail.com p = static_cast<uint8_t *>(p) + gen.size(); 839885Sstever@gmail.com } 849885Sstever@gmail.com return true; 859885Sstever@gmail.com} 869885Sstever@gmail.com 8710315Snilay@cs.wisc.edubool 889988Snilay@cs.wisc.eduFSTranslatingPortProxy::tryWriteBlob( 8910315Snilay@cs.wisc.edu Addr addr, const void *p, int size) const 909885Sstever@gmail.com{ 918504SN/A Addr paddr; 928504SN/A for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done(); 938504SN/A gen.next()) 949885Sstever@gmail.com { 958504SN/A if (_tc) 968504SN/A paddr = TheISA::vtophys(_tc,gen.addr()); 978504SN/A else 988504SN/A paddr = TheISA::vtophys(gen.addr()); 998504SN/A 1008504SN/A PortProxy::writeBlobPhys(paddr, 0, p, gen.size()); 1018504SN/A p = static_cast<const uint8_t *>(p) + gen.size(); 1028504SN/A } 1039481Snilay@cs.wisc.edu return true; 1048504SN/A} 1058504SN/A 1069885Sstever@gmail.combool 1078504SN/AFSTranslatingPortProxy::tryMemsetBlob(Addr address, uint8_t v, int size) const 1088504SN/A{ 1098504SN/A Addr paddr; 1108504SN/A for (ChunkGenerator gen(address, size, TheISA::PageBytes); !gen.done(); 1118504SN/A gen.next()) 1128504SN/A { 1138504SN/A if (_tc) 1148504SN/A paddr = TheISA::vtophys(_tc,gen.addr()); 1158504SN/A else 1168504SN/A paddr = TheISA::vtophys(gen.addr()); 1178504SN/A 1188504SN/A PortProxy::memsetBlobPhys(paddr, 0, v, gen.size()); 1198504SN/A } 1208504SN/A return true; 1219988Snilay@cs.wisc.edu} 1229988Snilay@cs.wisc.edu