tlb.hh revision 12749
14997SN/A/* 27944SN/A * Copyright (c) 2011 ARM Limited 37944SN/A * All rights reserved. 47944SN/A * 57944SN/A * The license below extends only to copyright in the software and shall 67944SN/A * not be construed as granting a license to any other intellectual 77944SN/A * property including but not limited to intellectual property relating 87944SN/A * to a hardware implementation of the functionality of the software 97944SN/A * licensed hereunder. You may use the software subject to the license 107944SN/A * terms below provided that you ensure that this notice is replicated 117944SN/A * unmodified and in its entirety in all distributions of the software, 127944SN/A * modified or unmodified, in source code or in binary form. 137944SN/A * 144997SN/A * Copyright (c) 2006 The Regents of The University of Michigan 154997SN/A * All rights reserved. 164997SN/A * 174997SN/A * Redistribution and use in source and binary forms, with or without 184997SN/A * modification, are permitted provided that the following conditions are 194997SN/A * met: redistributions of source code must retain the above copyright 204997SN/A * notice, this list of conditions and the following disclaimer; 214997SN/A * redistributions in binary form must reproduce the above copyright 224997SN/A * notice, this list of conditions and the following disclaimer in the 234997SN/A * documentation and/or other materials provided with the distribution; 244997SN/A * neither the name of the copyright holders nor the names of its 254997SN/A * contributors may be used to endorse or promote products derived from 264997SN/A * this software without specific prior written permission. 274997SN/A * 284997SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 294997SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 304997SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 314997SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 324997SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 334997SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 344997SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 354997SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 364997SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 374997SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 384997SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 394997SN/A * 404997SN/A * Authors: Gabe Black 414997SN/A */ 424997SN/A 4310687SAndreas.Sandberg@ARM.com#ifndef __ARCH_GENERIC_TLB_HH__ 4410687SAndreas.Sandberg@ARM.com#define __ARCH_GENERIC_TLB_HH__ 454997SN/A 4612334Sgabeblack@google.com#include "base/logging.hh" 474997SN/A#include "mem/request.hh" 484997SN/A#include "sim/sim_object.hh" 494997SN/A 504997SN/Aclass ThreadContext; 519294SN/Aclass BaseMasterPort; 524997SN/A 535358SN/Aclass BaseTLB : public SimObject 545004SN/A{ 555004SN/A protected: 566023SN/A BaseTLB(const Params *p) 576023SN/A : SimObject(p) 585004SN/A {} 595004SN/A 604997SN/A public: 616023SN/A enum Mode { Read, Write, Execute }; 626023SN/A 635894SN/A class Translation 645894SN/A { 655894SN/A public: 665894SN/A virtual ~Translation() 675894SN/A {} 685894SN/A 697944SN/A /** 707944SN/A * Signal that the translation has been delayed due to a hw page table 717944SN/A * walk. 727944SN/A */ 737944SN/A virtual void markDelayed() = 0; 747944SN/A 755894SN/A /* 765894SN/A * The memory for this object may be dynamically allocated, and it may 775894SN/A * be responsible for cleaning itself up which will happen in this 785894SN/A * function. Once it's called, the object is no longer valid. 795894SN/A */ 8012749Sgiacomo.travaglini@arm.com virtual void finish(const Fault &fault, const RequestPtr &req, 8110379SN/A ThreadContext *tc, Mode mode) = 0; 829258SN/A 839258SN/A /** This function is used by the page table walker to determine if it 849258SN/A * should translate the a pending request or if the underlying request 859258SN/A * has been squashed. 869258SN/A * @ return Is the instruction that requested this translation squashed? 879258SN/A */ 889258SN/A virtual bool squashed() const { return false; } 895894SN/A }; 905358SN/A 915358SN/A public: 9212406Sgabeblack@google.com virtual void demapPage(Addr vaddr, uint64_t asn) = 0; 935358SN/A 9412406Sgabeblack@google.com virtual Fault translateAtomic( 9512749Sgiacomo.travaglini@arm.com const RequestPtr &req, ThreadContext *tc, Mode mode) = 0; 9612406Sgabeblack@google.com virtual void translateTiming( 9712749Sgiacomo.travaglini@arm.com const RequestPtr &req, ThreadContext *tc, 9812406Sgabeblack@google.com Translation *translation, Mode mode) = 0; 9912406Sgabeblack@google.com virtual Fault 10012749Sgiacomo.travaglini@arm.com translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) 10112406Sgabeblack@google.com { 10212406Sgabeblack@google.com panic("Not implemented.\n"); 10312406Sgabeblack@google.com } 1049738SN/A 1059738SN/A /** 1069738SN/A * Do post-translation physical address finalization. 1079738SN/A * 1089738SN/A * This method is used by some architectures that need 1099738SN/A * post-translation massaging of physical addresses. For example, 1109738SN/A * X86 uses this to remap physical addresses in the APIC range to 1119738SN/A * a range of physical memory not normally available to real x86 1129738SN/A * implementations. 1139738SN/A * 1149738SN/A * @param req Request to updated in-place. 1159738SN/A * @param tc Thread context that created the request. 1169738SN/A * @param mode Request type (read/write/execute). 1179738SN/A * @return A fault on failure, NoFault otherwise. 1189738SN/A */ 11912406Sgabeblack@google.com virtual Fault finalizePhysical( 12012749Sgiacomo.travaglini@arm.com const RequestPtr &req, ThreadContext *tc, Mode mode) const = 0; 12112406Sgabeblack@google.com 12212406Sgabeblack@google.com /** 12312406Sgabeblack@google.com * Remove all entries from the TLB 12412406Sgabeblack@google.com */ 12512406Sgabeblack@google.com virtual void flushAll() = 0; 12612406Sgabeblack@google.com 12712406Sgabeblack@google.com /** 12812406Sgabeblack@google.com * Take over from an old tlb context 12912406Sgabeblack@google.com */ 13012406Sgabeblack@google.com virtual void takeOverFrom(BaseTLB *otlb) = 0; 13112406Sgabeblack@google.com 13212406Sgabeblack@google.com /** 13312406Sgabeblack@google.com * Get the table walker master port if present. This is used for 13412406Sgabeblack@google.com * migrating port connections during a CPU takeOverFrom() 13512406Sgabeblack@google.com * call. For architectures that do not have a table walker, NULL 13612406Sgabeblack@google.com * is returned, hence the use of a pointer rather than a 13712406Sgabeblack@google.com * reference. 13812406Sgabeblack@google.com * 13912406Sgabeblack@google.com * @return A pointer to the walker master port or NULL if not present 14012406Sgabeblack@google.com */ 14112406Sgabeblack@google.com virtual BaseMasterPort* getMasterPort() { return NULL; } 14212406Sgabeblack@google.com 14312406Sgabeblack@google.com void memInvalidate() { flushAll(); } 14412406Sgabeblack@google.com}; 14512406Sgabeblack@google.com 14612406Sgabeblack@google.comclass GenericTLB : public BaseTLB 14712406Sgabeblack@google.com{ 14812406Sgabeblack@google.com protected: 14912406Sgabeblack@google.com GenericTLB(const Params *p) 15012406Sgabeblack@google.com : BaseTLB(p) 15112406Sgabeblack@google.com {} 15212406Sgabeblack@google.com 15312406Sgabeblack@google.com public: 15412406Sgabeblack@google.com void demapPage(Addr vaddr, uint64_t asn) override; 15512406Sgabeblack@google.com 15612406Sgabeblack@google.com Fault translateAtomic( 15712749Sgiacomo.travaglini@arm.com const RequestPtr &req, ThreadContext *tc, Mode mode) override; 15812406Sgabeblack@google.com void translateTiming( 15912749Sgiacomo.travaglini@arm.com const RequestPtr &req, ThreadContext *tc, 16012406Sgabeblack@google.com Translation *translation, Mode mode) override; 16112406Sgabeblack@google.com 16212406Sgabeblack@google.com Fault finalizePhysical( 16312749Sgiacomo.travaglini@arm.com const RequestPtr &req, ThreadContext *tc, Mode mode) const override; 1644997SN/A}; 1654997SN/A 16610687SAndreas.Sandberg@ARM.com#endif // __ARCH_GENERIC_TLB_HH__ 167