Finish test clean-up & reorg.
[gem5.git] / src / arch / alpha / ev5.hh
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: Steve Reinhardt
29 * Nathan Binkert
30 * Ali Saidi
31 */
32
33 #ifndef __ARCH_ALPHA_EV5_HH__
34 #define __ARCH_ALPHA_EV5_HH__
35
36 #include "config/alpha_tlaser.hh"
37 #include "arch/alpha/isa_traits.hh"
38
39 namespace EV5 {
40
41 //It seems like a safe assumption EV5 only applies to alpha
42 using namespace AlphaISA;
43
44 #if ALPHA_TLASER
45 const uint64_t AsnMask = ULL(0x7f);
46 #else
47 const uint64_t AsnMask = ULL(0xff);
48 #endif
49
50 const int VAddrImplBits = 43;
51 const Addr VAddrImplMask = (ULL(1) << VAddrImplBits) - 1;
52 const Addr VAddrUnImplMask = ~VAddrImplMask;
53 inline Addr VAddrImpl(Addr a) { return a & VAddrImplMask; }
54 inline Addr VAddrVPN(Addr a) { return a >> AlphaISA::PageShift; }
55 inline Addr VAddrOffset(Addr a) { return a & AlphaISA::PageOffset; }
56 inline Addr VAddrSpaceEV5(Addr a) { return a >> 41 & 0x3; }
57 inline Addr VAddrSpaceEV6(Addr a) { return a >> 41 & 0x7f; }
58
59 #if ALPHA_TLASER
60 inline bool PAddrIprSpace(Addr a) { return a >= ULL(0xFFFFF00000); }
61 const int PAddrImplBits = 40;
62 #else
63 inline bool PAddrIprSpace(Addr a) { return a >= ULL(0xFFFFFF00000); }
64 const int PAddrImplBits = 44; // for Tsunami
65 #endif
66 const Addr PAddrImplMask = (ULL(1) << PAddrImplBits) - 1;
67 const Addr PAddrUncachedBit39 = ULL(0x8000000000);
68 const Addr PAddrUncachedBit40 = ULL(0x10000000000);
69 const Addr PAddrUncachedBit43 = ULL(0x80000000000);
70 const Addr PAddrUncachedMask = ULL(0x807ffffffff); // Clear PA<42:35>
71 inline Addr Phys2K0Seg(Addr addr)
72 {
73 #if !ALPHA_TLASER
74 if (addr & PAddrUncachedBit43) {
75 addr &= PAddrUncachedMask;
76 addr |= PAddrUncachedBit40;
77 }
78 #endif
79 return addr | AlphaISA::K0SegBase;
80 }
81
82 inline int DTB_ASN_ASN(uint64_t reg) { return reg >> 57 & AsnMask; }
83 inline Addr DTB_PTE_PPN(uint64_t reg)
84 { return reg >> 32 & (ULL(1) << PAddrImplBits - AlphaISA::PageShift) - 1; }
85 inline int DTB_PTE_XRE(uint64_t reg) { return reg >> 8 & 0xf; }
86 inline int DTB_PTE_XWE(uint64_t reg) { return reg >> 12 & 0xf; }
87 inline int DTB_PTE_FONR(uint64_t reg) { return reg >> 1 & 0x1; }
88 inline int DTB_PTE_FONW(uint64_t reg) { return reg >> 2 & 0x1; }
89 inline int DTB_PTE_GH(uint64_t reg) { return reg >> 5 & 0x3; }
90 inline int DTB_PTE_ASMA(uint64_t reg) { return reg >> 4 & 0x1; }
91
92 inline int ITB_ASN_ASN(uint64_t reg) { return reg >> 4 & AsnMask; }
93 inline Addr ITB_PTE_PPN(uint64_t reg)
94 { return reg >> 32 & (ULL(1) << PAddrImplBits - AlphaISA::PageShift) - 1; }
95 inline int ITB_PTE_XRE(uint64_t reg) { return reg >> 8 & 0xf; }
96 inline bool ITB_PTE_FONR(uint64_t reg) { return reg >> 1 & 0x1; }
97 inline bool ITB_PTE_FONW(uint64_t reg) { return reg >> 2 & 0x1; }
98 inline int ITB_PTE_GH(uint64_t reg) { return reg >> 5 & 0x3; }
99 inline bool ITB_PTE_ASMA(uint64_t reg) { return reg >> 4 & 0x1; }
100
101 inline uint64_t MCSR_SP(uint64_t reg) { return reg >> 1 & 0x3; }
102
103 inline bool ICSR_SDE(uint64_t reg) { return reg >> 30 & 0x1; }
104 inline int ICSR_SPE(uint64_t reg) { return reg >> 28 & 0x3; }
105 inline bool ICSR_FPE(uint64_t reg) { return reg >> 26 & 0x1; }
106
107 inline uint64_t ALT_MODE_AM(uint64_t reg) { return reg >> 3 & 0x3; }
108 inline uint64_t DTB_CM_CM(uint64_t reg) { return reg >> 3 & 0x3; }
109 inline uint64_t ICM_CM(uint64_t reg) { return reg >> 3 & 0x3; }
110
111 const uint64_t MM_STAT_BAD_VA_MASK = ULL(0x0020);
112 const uint64_t MM_STAT_DTB_MISS_MASK = ULL(0x0010);
113 const uint64_t MM_STAT_FONW_MASK = ULL(0x0008);
114 const uint64_t MM_STAT_FONR_MASK = ULL(0x0004);
115 const uint64_t MM_STAT_ACV_MASK = ULL(0x0002);
116 const uint64_t MM_STAT_WR_MASK = ULL(0x0001);
117 inline int Opcode(AlphaISA::MachInst inst) { return inst >> 26 & 0x3f; }
118 inline int Ra(AlphaISA::MachInst inst) { return inst >> 21 & 0x1f; }
119
120 const Addr PalBase = 0x4000;
121 const Addr PalMax = 0x10000;
122
123 /* namespace EV5 */ }
124
125 #endif // __ARCH_ALPHA_EV5_HH__