tlb.hh revision 7399
16145SN/A/* 28688SN/A * Copyright (c) 2010 ARM Limited 36145SN/A * All rights reserved 46145SN/A * 56145SN/A * The license below extends only to copyright in the software and shall 66145SN/A * not be construed as granting a license to any other intellectual 76145SN/A * property including but not limited to intellectual property relating 86145SN/A * to a hardware implementation of the functionality of the software 96145SN/A * licensed hereunder. You may use the software subject to the license 106145SN/A * terms below provided that you ensure that this notice is replicated 116145SN/A * unmodified and in its entirety in all distributions of the software, 126145SN/A * modified or unmodified, in source code or in binary form. 136145SN/A * 146145SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan 156145SN/A * All rights reserved. 166145SN/A * 176145SN/A * Redistribution and use in source and binary forms, with or without 186145SN/A * modification, are permitted provided that the following conditions are 196145SN/A * met: redistributions of source code must retain the above copyright 206145SN/A * notice, this list of conditions and the following disclaimer; 216145SN/A * redistributions in binary form must reproduce the above copyright 226145SN/A * notice, this list of conditions and the following disclaimer in the 236145SN/A * documentation and/or other materials provided with the distribution; 246145SN/A * neither the name of the copyright holders nor the names of its 256145SN/A * contributors may be used to endorse or promote products derived from 266145SN/A * this software without specific prior written permission. 276145SN/A * 286145SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 296145SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 307039SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 317039SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 327039SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 336145SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 346145SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 357039SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 367039SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 376145SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 387039SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 399350SN/A * 4011108Sdavid.hashe@amd.com * Authors: Ali Saidi 4110301SN/A */ 4210301SN/A 4310301SN/A#ifndef __ARCH_ARM_TLB_HH__ 447039SN/A#define __ARCH_ARM_TLB_HH__ 459206SN/A 466145SN/A#include <map> 477039SN/A 4810920SN/A#include "arch/arm/isa_traits.hh" 496285SN/A#include "arch/arm/utility.hh" 509206SN/A#include "arch/arm/vtophys.hh" 517039SN/A#include "arch/arm/pagetable.hh" 527039SN/A#include "base/statistics.hh" 536876SN/A#include "mem/request.hh" 546876SN/A#include "params/ArmTLB.hh" 557039SN/A#include "sim/faults.hh" 566145SN/A#include "sim/tlb.hh" 577039SN/A 587039SN/Aclass ThreadContext; 599504SN/A 609504SN/Anamespace ArmISA { 619504SN/A 6210837SN/Aclass TLB : public BaseTLB 6310837SN/A{ 646285SN/A public: 6510525SN/A enum ArmFlags { 6610918SN/A AlignmentMask = 0x7, 6711294Sandreas.hansson@arm.com 6810525SN/A AlignByte = 0x0, 697039SN/A AlignHalfWord = 0x1, 707039SN/A AlignWord = 0x3, 717039SN/A AlignDoubleWord = 0x7, 727039SN/A 7310012SN/A AllowUnaligned = 0x8, 7410012SN/A // Because zero otherwise looks like a valid setting and may be used 757039SN/A // accidentally, this bit must be non-zero to show it was used on 766285SN/A // purpose. 7711523Sdavid.guillen@arm.com MustBeOne = 0x10 7811523Sdavid.guillen@arm.com }; 7911523Sdavid.guillen@arm.com protected: 8011523Sdavid.guillen@arm.com typedef std::multimap<Addr, int> PageTable; 8110012SN/A PageTable lookupTable; // Quick lookup into page table 8211169Sandreas.hansson@arm.com 836285SN/A ArmISA::PTE *table; // the Page Table 8411169Sandreas.hansson@arm.com int size; // TLB Size 8511168Sandreas.hansson@arm.com int nlu; // not last used entry (for replacement) 8611168Sandreas.hansson@arm.com 8711168Sandreas.hansson@arm.com void nextnlu() { if (++nlu >= size) nlu = 0; } 888688SN/A ArmISA::PTE *lookup(Addr vpn, uint8_t asn) const; 8911169Sandreas.hansson@arm.com 909270SN/A // Access Stats 919270SN/A mutable Stats::Scalar read_hits; 927562SN/A mutable Stats::Scalar read_misses; 938436SN/A mutable Stats::Scalar read_acv; 948436SN/A mutable Stats::Scalar read_accesses; 958436SN/A mutable Stats::Scalar write_hits; 968937SN/A mutable Stats::Scalar write_misses; 978937SN/A mutable Stats::Scalar write_acv; 988937SN/A mutable Stats::Scalar write_accesses; 9912133Sspwilson2@wisc.edu Stats::Formula hits; 10012133Sspwilson2@wisc.edu Stats::Formula misses; 1018937SN/A Stats::Formula invalids; 1028937SN/A Stats::Formula accesses; 1038937SN/A 1047039SN/A public: 1057039SN/A typedef ArmTLBParams Params; 1067039SN/A TLB(const Params *p); 1077039SN/A 1086285SN/A virtual ~TLB(); 10910991SN/A int getsize() const { return size; } 11011061SN/A 11111061SN/A void insert(Addr vaddr, ArmISA::PTE &pte); 11210991SN/A void flushAll(); 11311060SN/A void demapPage(Addr vaddr, uint64_t asn) 11411060SN/A { 11511061SN/A panic("demapPage unimplemented.\n"); 11611060SN/A } 11711061SN/A 1187039SN/A static bool validVirtualAddress(Addr vaddr); 11912133Sspwilson2@wisc.edu 1207039SN/A Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode); 1217039SN/A void translateTiming(RequestPtr req, ThreadContext *tc, 1227039SN/A Translation *translation, Mode mode); 1239504SN/A 1249504SN/A // Checkpointing 1259504SN/A void serialize(std::ostream &os); 12610919SN/A void unserialize(Checkpoint *cp, const std::string §ion); 12710837SN/A 12810837SN/A void regStats(); 12910837SN/A}; 13010525SN/A 13110706SN/A/* namespace ArmISA */ } 1327039SN/A 13310012SN/A#endif // __ARCH_ARM_TLB_HH__ 1349300SN/A