pagetable.hh revision 5570:13592d41f290
16019Shines@cs.fsu.edu/* 26019Shines@cs.fsu.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan 37100Sgblack@eecs.umich.edu * All rights reserved. 47100Sgblack@eecs.umich.edu * 57100Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 67100Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 77100Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 87100Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 97100Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 107100Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 117100Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 127100Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 137100Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 147100Sgblack@eecs.umich.edu * this software without specific prior written permission. 156019Shines@cs.fsu.edu * 166019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276019Shines@cs.fsu.edu * 286019Shines@cs.fsu.edu * Authors: Nathan Binkert 296019Shines@cs.fsu.edu * Steve Reinhardt 306019Shines@cs.fsu.edu */ 316019Shines@cs.fsu.edu 326019Shines@cs.fsu.edu#ifndef __ARCH_ALPHA_PAGETABLE_H__ 336019Shines@cs.fsu.edu#define __ARCH_ALPHA_PAGETABLE_H__ 346019Shines@cs.fsu.edu 356019Shines@cs.fsu.edu#include "arch/alpha/isa_traits.hh" 366019Shines@cs.fsu.edu#include "arch/alpha/utility.hh" 376019Shines@cs.fsu.edu#include "config/full_system.hh" 386019Shines@cs.fsu.edu 396019Shines@cs.fsu.edunamespace AlphaISA { 406019Shines@cs.fsu.edu 416019Shines@cs.fsu.edustruct VAddr 426757SAli.Saidi@ARM.com{ 436019Shines@cs.fsu.edu static const int ImplBits = 43; 446019Shines@cs.fsu.edu static const Addr ImplMask = (ULL(1) << ImplBits) - 1; 456019Shines@cs.fsu.edu static const Addr UnImplMask = ~ImplMask; 466019Shines@cs.fsu.edu 476019Shines@cs.fsu.edu Addr addr; 486019Shines@cs.fsu.edu 496019Shines@cs.fsu.edu VAddr(Addr a) : addr(a) {} 506019Shines@cs.fsu.edu operator Addr() const { return addr; } 516253Sgblack@eecs.umich.edu const VAddr &operator=(Addr a) { addr = a; return *this; } 527170Sgblack@eecs.umich.edu 536253Sgblack@eecs.umich.edu Addr vpn() const { return (addr & ImplMask) >> PageShift; } 546253Sgblack@eecs.umich.edu Addr page() const { return addr & PageMask; } 556253Sgblack@eecs.umich.edu Addr offset() const { return addr & PageOffset; } 566397Sgblack@eecs.umich.edu 576019Shines@cs.fsu.edu Addr level3() const 586019Shines@cs.fsu.edu { return PteAddr(addr >> PageShift); } 596019Shines@cs.fsu.edu Addr level2() const 606757SAli.Saidi@ARM.com { return PteAddr(addr >> (NPtePageShift + PageShift)); } 616019Shines@cs.fsu.edu Addr level1() const 626397Sgblack@eecs.umich.edu { return PteAddr(addr >> (2 * NPtePageShift + PageShift)); } 636019Shines@cs.fsu.edu}; 646397Sgblack@eecs.umich.edu 656019Shines@cs.fsu.edustruct PageTableEntry 666735Sgblack@eecs.umich.edu{ 677100Sgblack@eecs.umich.edu PageTableEntry(uint64_t e) : entry(e) {} 686019Shines@cs.fsu.edu uint64_t entry; 696757SAli.Saidi@ARM.com operator uint64_t() const { return entry; } 706757SAli.Saidi@ARM.com const PageTableEntry &operator=(uint64_t e) { entry = e; return *this; } 716757SAli.Saidi@ARM.com const PageTableEntry &operator=(const PageTableEntry &e) 726757SAli.Saidi@ARM.com { entry = e.entry; return *this; } 736757SAli.Saidi@ARM.com 746757SAli.Saidi@ARM.com Addr _pfn() const { return (entry >> 32) & 0xffffffff; } 756019Shines@cs.fsu.edu Addr _sw() const { return (entry >> 16) & 0xffff; } 766019Shines@cs.fsu.edu int _rsv0() const { return (entry >> 14) & 0x3; } 776019Shines@cs.fsu.edu bool _uwe() const { return (entry >> 13) & 0x1; } 786019Shines@cs.fsu.edu bool _kwe() const { return (entry >> 12) & 0x1; } 796019Shines@cs.fsu.edu int _rsv1() const { return (entry >> 10) & 0x3; } 806019Shines@cs.fsu.edu bool _ure() const { return (entry >> 9) & 0x1; } 816019Shines@cs.fsu.edu bool _kre() const { return (entry >> 8) & 0x1; } 826019Shines@cs.fsu.edu bool _nomb() const { return (entry >> 7) & 0x1; } 836019Shines@cs.fsu.edu int _gh() const { return (entry >> 5) & 0x3; } 846019Shines@cs.fsu.edu bool _asm_() const { return (entry >> 4) & 0x1; } 856019Shines@cs.fsu.edu bool _foe() const { return (entry >> 3) & 0x1; } 866019Shines@cs.fsu.edu bool _fow() const { return (entry >> 2) & 0x1; } 87 bool _for() const { return (entry >> 1) & 0x1; } 88 bool valid() const { return (entry >> 0) & 0x1; } 89 90 Addr paddr() const { return _pfn() << PageShift; } 91}; 92 93// ITB/DTB table entry 94struct TlbEntry 95{ 96 Addr tag; // virtual page number tag 97 Addr ppn; // physical page number 98 uint8_t xre; // read permissions - VMEM_PERM_* mask 99 uint8_t xwe; // write permissions - VMEM_PERM_* mask 100 uint8_t asn; // address space number 101 bool asma; // address space match 102 bool fonr; // fault on read 103 bool fonw; // fault on write 104 bool valid; // valid page table entry 105 106 107 //Construct an entry that maps to physical address addr. 108 TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr) 109 { 110 VAddr vaddr(_vaddr); 111 VAddr paddr(_paddr); 112 tag = vaddr.vpn(); 113 ppn = paddr.vpn(); 114 xre = 15; 115 xwe = 15; 116 asn = _asn; 117 asma = false; 118 fonr = false; 119 fonw = false; 120 valid = true; 121 } 122 123 TlbEntry() 124 {} 125 126 Addr 127 pageStart() 128 { 129 return ppn << PageShift; 130 } 131 132 void serialize(std::ostream &os); 133 void unserialize(Checkpoint *cp, const std::string §ion); 134}; 135 136} // namespace AlphaISA 137 138#endif // __ARCH_ALPHA_PAGETABLE_H__ 139 140