pagetable.hh (6019:76890d8b28f5) | pagetable.hh (7399:a378ac1e1615) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * |
|
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan | 14 * Copyright (c) 2002-2005 The Regents of The University of Michigan |
3 * Copyright (c) 2007 MIPS Technologies, Inc. 4 * Copyright (c) 2007-2008 The Florida State University | |
5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer; 11 * redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the --- 11 unchanged lines hidden (view full) --- 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Authors: Nathan Binkert 31 * Steve Reinhardt | 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the --- 11 unchanged lines hidden (view full) --- 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Nathan Binkert 41 * Steve Reinhardt |
32 * Jaidev Patwardhan 33 * Stephen Hines | 42 * Ali Saidi |
34 */ 35 36#ifndef __ARCH_ARM_PAGETABLE_H__ 37#define __ARCH_ARM_PAGETABLE_H__ 38 39#include "arch/arm/isa_traits.hh" 40#include "arch/arm/utility.hh" 41#include "arch/arm/vtophys.hh" 42#include "config/full_system.hh" 43 44namespace ArmISA { 45 | 43 */ 44 45#ifndef __ARCH_ARM_PAGETABLE_H__ 46#define __ARCH_ARM_PAGETABLE_H__ 47 48#include "arch/arm/isa_traits.hh" 49#include "arch/arm/utility.hh" 50#include "arch/arm/vtophys.hh" 51#include "config/full_system.hh" 52 53namespace ArmISA { 54 |
46 struct VAddr | 55struct VAddr 56{ 57 VAddr(Addr a) { panic("not implemented yet."); } 58}; 59 60 61// ITB/DTB page table entry 62struct PTE 63{ 64 void serialize(std::ostream &os) |
47 { | 65 { |
48 static const int ImplBits = 43; 49 static const Addr ImplMask = (ULL(1) << ImplBits) - 1; 50 static const Addr UnImplMask = ~ImplMask; | 66 panic("Need to implement PTE serialization\n"); 67 } |
51 | 68 |
52 VAddr(Addr a) : addr(a) {} 53 Addr addr; 54 operator Addr() const { return addr; } 55 const VAddr &operator=(Addr a) { addr = a; return *this; } | 69 void unserialize(Checkpoint *cp, const std::string §ion) 70 { 71 panic("Need to implement PTE serialization\n"); 72 } |
56 | 73 |
57 Addr vpn() const { return (addr & ImplMask) >> PageShift; } 58 Addr page() const { return addr & Page_Mask; } 59 Addr offset() const { return addr & PageOffset; } | 74}; |
60 | 75 |
61 Addr level3() const 62 { return ArmISA::PteAddr(addr >> PageShift); } 63 Addr level2() const 64 { return ArmISA::PteAddr(addr >> (NPtePageShift + PageShift)); } 65 Addr level1() const 66 { return ArmISA::PteAddr(addr >> (2 * NPtePageShift + PageShift)); } 67 }; | 76// ITB/DTB table entry 77struct TlbEntry 78{ 79 Addr tag; // virtual page number tag 80 Addr ppn; // physical page number 81 uint8_t asn; // address space number 82 bool valid; // valid page table entry |
68 | 83 |
69 // ITB/DTB page table entry 70 struct PTE | 84 85 //Construct an entry that maps to physical address addr. 86 TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr) |
71 { | 87 { |
72 Addr Mask; // What parts of the VAddr (from bits 28..11) should be used in translation (includes Mask and MaskX from PageMask) 73 Addr VPN; // Virtual Page Number (/2) (Includes VPN2 + VPN2X .. bits 31..11 from EntryHi) 74 uint8_t asid; // Address Space ID (8 bits) // Lower 8 bits of EntryHi | 88 tag = _vaddr >> PageShift; 89 ppn = _paddr >> PageShift; 90 asn = _asn; 91 valid = true; 92 } |
75 | 93 |
76 bool G; // Global Bit - Obtained by an *AND* of EntryLo0 and EntryLo1 G bit | 94 TlbEntry() 95 {} |
77 | 96 |
78 /* Contents of Entry Lo0 */ 79 Addr PFN0; // Physical Frame Number - Even 80 bool D0; // Even entry Dirty Bit 81 bool V0; // Even entry Valid Bit 82 uint8_t C0; // Cache Coherency Bits - Even | 97 void 98 updateVaddr(Addr new_vaddr) 99 { 100 tag = new_vaddr >> PageShift; 101 } |
83 | 102 |
84 /* Contents of Entry Lo1 */ 85 Addr PFN1; // Physical Frame Number - Odd 86 bool D1; // Odd entry Dirty Bit 87 bool V1; // Odd entry Valid Bit 88 uint8_t C1; // Cache Coherency Bits (3 bits) | 103 Addr 104 pageStart() 105 { 106 return ppn << PageShift; 107 } |
89 | 108 |
90 /* The next few variables are put in as optimizations to reduce TLB lookup overheads */ 91 /* For a given Mask, what is the address shift amount, and what is the OffsetMask */ 92 int AddrShiftAmount; 93 int OffsetMask; | 109 void serialize(std::ostream &os); 110 void unserialize(Checkpoint *cp, const std::string §ion); 111}; |
94 | 112 |
95 bool Valid() { return (V0 | V1);}; 96 void serialize(std::ostream &os); 97 void unserialize(Checkpoint *cp, const std::string §ion); 98 }; | |
99 | 113 |
114 |
|
100}; 101#endif // __ARCH_ARM_PAGETABLE_H__ 102 | 115}; 116#endif // __ARCH_ARM_PAGETABLE_H__ 117 |