tlb.hh revision 3603
12650Ssaidi@eecs.umich.edu/* 22650Ssaidi@eecs.umich.edu * Copyright (c) 2006 The Regents of The University of Michigan 32650Ssaidi@eecs.umich.edu * All rights reserved. 42650Ssaidi@eecs.umich.edu * 52650Ssaidi@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 62650Ssaidi@eecs.umich.edu * modification, are permitted provided that the following conditions are 72650Ssaidi@eecs.umich.edu * met: redistributions of source code must retain the above copyright 82650Ssaidi@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 92650Ssaidi@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 102650Ssaidi@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 112650Ssaidi@eecs.umich.edu * documentation and/or other materials provided with the distribution; 122650Ssaidi@eecs.umich.edu * neither the name of the copyright holders nor the names of its 132650Ssaidi@eecs.umich.edu * contributors may be used to endorse or promote products derived from 142650Ssaidi@eecs.umich.edu * this software without specific prior written permission. 152650Ssaidi@eecs.umich.edu * 162650Ssaidi@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172650Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182650Ssaidi@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192650Ssaidi@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202650Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212650Ssaidi@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222650Ssaidi@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232650Ssaidi@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242650Ssaidi@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252650Ssaidi@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262650Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272650Ssaidi@eecs.umich.edu * 282650Ssaidi@eecs.umich.edu * Authors: Ali Saidi 292650Ssaidi@eecs.umich.edu */ 302650Ssaidi@eecs.umich.edu 312650Ssaidi@eecs.umich.edu#ifndef __ARCH_SPARC_TLB_HH__ 322650Ssaidi@eecs.umich.edu#define __ARCH_SPARC_TLB_HH__ 332650Ssaidi@eecs.umich.edu 343602Sgblack@eecs.umich.edu#include "base/misc.hh" 353569Sgblack@eecs.umich.edu#include "mem/request.hh" 363468Sgblack@eecs.umich.edu#include "sim/faults.hh" 373569Sgblack@eecs.umich.edu#include "sim/sim_object.hh" 383468Sgblack@eecs.umich.edu 393468Sgblack@eecs.umich.educlass ThreadContext; 403468Sgblack@eecs.umich.edu 413468Sgblack@eecs.umich.edunamespace SparcISA 423468Sgblack@eecs.umich.edu{ 433603Ssaidi@eecs.umich.edu const int PAddrImplBits = 40; 443603Ssaidi@eecs.umich.edu const Addr PAddrImplMask = (ULL(1) << PAddrImplBits) - 1; 453603Ssaidi@eecs.umich.edu 463569Sgblack@eecs.umich.edu class TLB : public SimObject 473468Sgblack@eecs.umich.edu { 483569Sgblack@eecs.umich.edu public: 493569Sgblack@eecs.umich.edu TLB(const std::string &name, int size) : SimObject(name) 503569Sgblack@eecs.umich.edu { 513569Sgblack@eecs.umich.edu } 523468Sgblack@eecs.umich.edu }; 533468Sgblack@eecs.umich.edu 543468Sgblack@eecs.umich.edu class ITB : public TLB 553468Sgblack@eecs.umich.edu { 563468Sgblack@eecs.umich.edu public: 573569Sgblack@eecs.umich.edu ITB(const std::string &name, int size) : TLB(name, size) 583569Sgblack@eecs.umich.edu { 593569Sgblack@eecs.umich.edu } 603569Sgblack@eecs.umich.edu 613468Sgblack@eecs.umich.edu Fault translate(RequestPtr &req, ThreadContext *tc) const 623468Sgblack@eecs.umich.edu { 633602Sgblack@eecs.umich.edu //For now, always assume the address is already physical. 643602Sgblack@eecs.umich.edu //Also assume that there are 40 bits of physical address space. 653603Ssaidi@eecs.umich.edu req->setPaddr(req->getVaddr() & PAddrImplMask); 663468Sgblack@eecs.umich.edu return NoFault; 673468Sgblack@eecs.umich.edu } 683468Sgblack@eecs.umich.edu }; 693468Sgblack@eecs.umich.edu 703468Sgblack@eecs.umich.edu class DTB : public TLB 713468Sgblack@eecs.umich.edu { 723468Sgblack@eecs.umich.edu public: 733569Sgblack@eecs.umich.edu DTB(const std::string &name, int size) : TLB(name, size) 743569Sgblack@eecs.umich.edu { 753569Sgblack@eecs.umich.edu } 763569Sgblack@eecs.umich.edu 773468Sgblack@eecs.umich.edu Fault translate(RequestPtr &req, ThreadContext *tc, bool write) const 783468Sgblack@eecs.umich.edu { 793602Sgblack@eecs.umich.edu //For now, always assume the address is already physical. 803602Sgblack@eecs.umich.edu //Also assume that there are 40 bits of physical address space. 813602Sgblack@eecs.umich.edu req->setPaddr(req->getVaddr() & ((1ULL << 40) - 1)); 823468Sgblack@eecs.umich.edu return NoFault; 833468Sgblack@eecs.umich.edu } 843468Sgblack@eecs.umich.edu }; 853468Sgblack@eecs.umich.edu} 862650Ssaidi@eecs.umich.edu 872650Ssaidi@eecs.umich.edu#endif // __ARCH_SPARC_TLB_HH__ 88