1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Nathan Binkert 29 * Steve Reinhardt 30 */ 31 32#ifndef __ARCH_ALPHA_PAGETABLE_H__ 33#define __ARCH_ALPHA_PAGETABLE_H__ 34 35#include "arch/alpha/isa_traits.hh" 36#include "arch/alpha/utility.hh" 37#include "config/full_system.hh" 38 39namespace AlphaISA { 40
| 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Nathan Binkert 29 * Steve Reinhardt 30 */ 31 32#ifndef __ARCH_ALPHA_PAGETABLE_H__ 33#define __ARCH_ALPHA_PAGETABLE_H__ 34 35#include "arch/alpha/isa_traits.hh" 36#include "arch/alpha/utility.hh" 37#include "config/full_system.hh" 38 39namespace AlphaISA { 40
|
41 struct VAddr 42 { 43 static const int ImplBits = 43; 44 static const Addr ImplMask = (ULL(1) << ImplBits) - 1; 45 static const Addr UnImplMask = ~ImplMask;
| 41struct VAddr 42{ 43 static const int ImplBits = 43; 44 static const Addr ImplMask = (ULL(1) << ImplBits) - 1; 45 static const Addr UnImplMask = ~ImplMask;
|
46
| 46
|
47 VAddr(Addr a) : addr(a) {} 48 Addr addr; 49 operator Addr() const { return addr; } 50 const VAddr &operator=(Addr a) { addr = a; return *this; }
| 47 Addr addr;
|
51
| 48
|
52 Addr vpn() const { return (addr & ImplMask) >> PageShift; } 53 Addr page() const { return addr & PageMask; } 54 Addr offset() const { return addr & PageOffset; }
| 49 VAddr(Addr a) : addr(a) {} 50 operator Addr() const { return addr; } 51 const VAddr &operator=(Addr a) { addr = a; return *this; }
|
55
| 52
|
56 Addr level3() const 57 { return PteAddr(addr >> PageShift); } 58 Addr level2() const 59 { return PteAddr(addr >> NPtePageShift + PageShift); } 60 Addr level1() const 61 { return PteAddr(addr >> 2 * NPtePageShift + PageShift); } 62 };
| 53 Addr vpn() const { return (addr & ImplMask) >> PageShift; } 54 Addr page() const { return addr & PageMask; } 55 Addr offset() const { return addr & PageOffset; }
|
63
| 56
|
64 struct PageTableEntry 65 { 66 PageTableEntry(uint64_t e) : entry(e) {} 67 uint64_t entry; 68 operator uint64_t() const { return entry; } 69 const PageTableEntry &operator=(uint64_t e) { entry = e; return *this; } 70 const PageTableEntry &operator=(const PageTableEntry &e) 71 { entry = e.entry; return *this; }
| 57 Addr level3() const 58 { return PteAddr(addr >> PageShift); } 59 Addr level2() const 60 { return PteAddr(addr >> NPtePageShift + PageShift); } 61 Addr level1() const 62 { return PteAddr(addr >> 2 * NPtePageShift + PageShift); } 63};
|
72
| 64
|
73 Addr _pfn() const { return (entry >> 32) & 0xffffffff; } 74 Addr _sw() const { return (entry >> 16) & 0xffff; } 75 int _rsv0() const { return (entry >> 14) & 0x3; } 76 bool _uwe() const { return (entry >> 13) & 0x1; } 77 bool _kwe() const { return (entry >> 12) & 0x1; } 78 int _rsv1() const { return (entry >> 10) & 0x3; } 79 bool _ure() const { return (entry >> 9) & 0x1; } 80 bool _kre() const { return (entry >> 8) & 0x1; } 81 bool _nomb() const { return (entry >> 7) & 0x1; } 82 int _gh() const { return (entry >> 5) & 0x3; } 83 bool _asm_() const { return (entry >> 4) & 0x1; } 84 bool _foe() const { return (entry >> 3) & 0x1; } 85 bool _fow() const { return (entry >> 2) & 0x1; } 86 bool _for() const { return (entry >> 1) & 0x1; } 87 bool valid() const { return (entry >> 0) & 0x1; }
| 65struct PageTableEntry 66{ 67 PageTableEntry(uint64_t e) : entry(e) {} 68 uint64_t entry; 69 operator uint64_t() const { return entry; } 70 const PageTableEntry &operator=(uint64_t e) { entry = e; return *this; } 71 const PageTableEntry &operator=(const PageTableEntry &e) 72 { entry = e.entry; return *this; }
|
88
| 73
|
89 Addr paddr() const { return _pfn() << PageShift; } 90 };
| 74 Addr _pfn() const { return (entry >> 32) & 0xffffffff; } 75 Addr _sw() const { return (entry >> 16) & 0xffff; } 76 int _rsv0() const { return (entry >> 14) & 0x3; } 77 bool _uwe() const { return (entry >> 13) & 0x1; } 78 bool _kwe() const { return (entry >> 12) & 0x1; } 79 int _rsv1() const { return (entry >> 10) & 0x3; } 80 bool _ure() const { return (entry >> 9) & 0x1; } 81 bool _kre() const { return (entry >> 8) & 0x1; } 82 bool _nomb() const { return (entry >> 7) & 0x1; } 83 int _gh() const { return (entry >> 5) & 0x3; } 84 bool _asm_() const { return (entry >> 4) & 0x1; } 85 bool _foe() const { return (entry >> 3) & 0x1; } 86 bool _fow() const { return (entry >> 2) & 0x1; } 87 bool _for() const { return (entry >> 1) & 0x1; } 88 bool valid() const { return (entry >> 0) & 0x1; }
|
91
| 89
|
92 // ITB/DTB table entry 93 struct TlbEntry 94 { 95 //Construct an entry that maps to physical address addr. 96 TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr) 97 { 98 VAddr vaddr(_vaddr); 99 VAddr paddr(_paddr); 100 tag = vaddr.vpn(); 101 ppn = paddr.vpn(); 102 xre = 15; 103 xwe = 15; 104 asn = _asn; 105 asma = false; 106 fonr = false; 107 fonw = false; 108 valid = true; 109 } 110 TlbEntry() 111 {}
| 90 Addr paddr() const { return _pfn() << PageShift; } 91};
|
112
| 92
|
113 Addr tag; // virtual page number tag 114 Addr ppn; // physical page number 115 uint8_t xre; // read permissions - VMEM_PERM_* mask 116 uint8_t xwe; // write permissions - VMEM_PERM_* mask 117 uint8_t asn; // address space number 118 bool asma; // address space match 119 bool fonr; // fault on read 120 bool fonw; // fault on write 121 bool valid; // valid page table entry
| 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
|
122
| 105
|
123 Addr pageStart() 124 { 125 return ppn << PageShift; 126 }
| |
127
| 106
|
128 void serialize(std::ostream &os); 129 void unserialize(Checkpoint *cp, const std::string §ion); 130 };
| 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 }
|
131
| 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);
|
132};
| 134};
|
| 135 136} // namespace AlphaISA 137
|
133#endif // __ARCH_ALPHA_PAGETABLE_H__ 134
| 138#endif // __ARCH_ALPHA_PAGETABLE_H__ 139
|