page_table.hh revision 2980
12379SN/A/* 22379SN/A * Copyright (c) 2003 The Regents of The University of Michigan 32379SN/A * All rights reserved. 42379SN/A * 52379SN/A * Redistribution and use in source and binary forms, with or without 62379SN/A * modification, are permitted provided that the following conditions are 72379SN/A * met: redistributions of source code must retain the above copyright 82379SN/A * notice, this list of conditions and the following disclaimer; 92379SN/A * redistributions in binary form must reproduce the above copyright 102379SN/A * notice, this list of conditions and the following disclaimer in the 112379SN/A * documentation and/or other materials provided with the distribution; 122379SN/A * neither the name of the copyright holders nor the names of its 132379SN/A * contributors may be used to endorse or promote products derived from 142379SN/A * this software without specific prior written permission. 152379SN/A * 162379SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172379SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182379SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192379SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202379SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212379SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222379SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232379SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242379SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252379SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262379SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt 292379SN/A */ 302379SN/A 312379SN/A/** 322379SN/A * @file 332379SN/A * Declaration of a non-full system Page Table. 342379SN/A */ 352379SN/A 362379SN/A#ifndef __PAGE_TABLE__ 372379SN/A#define __PAGE_TABLE__ 382379SN/A 392379SN/A#include <string> 402379SN/A 412980Sgblack@eecs.umich.edu#include "sim/faults.hh" 422423SN/A#include "arch/isa_traits.hh" 432809Ssaidi@eecs.umich.edu#include "base/hashmap.hh" 442379SN/A#include "base/trace.hh" 452394SN/A#include "mem/request.hh" 462394SN/A#include "mem/packet.hh" 472379SN/A#include "sim/sim_object.hh" 482379SN/A 492399SN/Aclass System; 502379SN/A 512379SN/A/** 522379SN/A * Page Table Decleration. 532379SN/A */ 542399SN/Aclass PageTable 552379SN/A{ 562379SN/A protected: 572809Ssaidi@eecs.umich.edu m5::hash_map<Addr,Addr> pTable; 582809Ssaidi@eecs.umich.edu 592809Ssaidi@eecs.umich.edu struct cacheElement { 602809Ssaidi@eecs.umich.edu Addr paddr; 612809Ssaidi@eecs.umich.edu Addr vaddr; 622809Ssaidi@eecs.umich.edu } ; 632809Ssaidi@eecs.umich.edu 642809Ssaidi@eecs.umich.edu struct cacheElement pTableCache[3]; 652379SN/A 662399SN/A const Addr pageSize; 672399SN/A const Addr offsetMask; 682399SN/A 692399SN/A System *system; 702379SN/A 712379SN/A public: 722379SN/A 732423SN/A PageTable(System *_system, Addr _pageSize = TheISA::VMPageSize); 742379SN/A 752379SN/A ~PageTable(); 762379SN/A 772399SN/A Addr pageAlign(Addr a) { return (a & ~offsetMask); } 782399SN/A Addr pageOffset(Addr a) { return (a & offsetMask); } 792379SN/A 802979Sgblack@eecs.umich.edu Fault page_check(Addr addr, int64_t size) const; 812379SN/A 822979Sgblack@eecs.umich.edu void allocate(Addr vaddr, int64_t size); 832399SN/A 842379SN/A /** 852379SN/A * Translate function 862379SN/A * @param vaddr The virtual address. 872379SN/A * @return Physical address from translation. 882379SN/A */ 892399SN/A bool translate(Addr vaddr, Addr &paddr); 902379SN/A 912379SN/A /** 922399SN/A * Perform a translation on the memory request, fills in paddr 932399SN/A * field of mem_req. 942379SN/A * @param req The memory request. 952379SN/A */ 962532SN/A Fault translate(RequestPtr &req); 972379SN/A 982379SN/A}; 992379SN/A 1002379SN/A#endif 101