faults.hh revision 3573
1/* 2 * Copyright (c) 2003-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: Gabe Black 29 * Kevin Lim 30 */ 31 32#ifndef __ALPHA_FAULTS_HH__ 33#define __ALPHA_FAULTS_HH__ 34 35#include "sim/faults.hh" 36 37// The design of the "name" and "vect" functions is in sim/faults.hh 38 39namespace SparcISA 40{ 41 42typedef uint32_t TrapType; 43typedef uint32_t FaultPriority; 44 45class SparcFaultBase : public FaultBase 46{ 47 public: 48 struct FaultVals 49 { 50 const FaultName name; 51 const TrapType trapType; 52 const FaultPriority priority; 53 FaultStat count; 54 }; 55#if FULL_SYSTEM 56 void invoke(ThreadContext * tc); 57#endif 58 virtual FaultName name() = 0; 59 virtual TrapType trapType() = 0; 60 virtual FaultPriority priority() = 0; 61 virtual FaultStat & countStat() = 0; 62}; 63 64template<typename T> 65class SparcFault : public SparcFaultBase 66{ 67 protected: 68 static FaultVals vals; 69 public: 70 FaultName name() {return vals.name;} 71 TrapType trapType() {return vals.trapType;} 72 FaultPriority priority() {return vals.priority;} 73 FaultStat & countStat() {return vals.count;} 74}; 75 76class InternalProcessorError : 77 public SparcFault<InternalProcessorError> 78{ 79 public: 80 bool isMachineCheckFault() {return true;} 81}; 82 83class MemAddressNotAligned : 84 public SparcFault<MemAddressNotAligned> 85{ 86 public: 87 bool isAlignmentFault() {return true;} 88}; 89 90#if !FULL_SYSTEM 91class PageTableFault : public SparcFault<PageTableFault> 92{ 93 private: 94 Addr vaddr; 95 public: 96 PageTableFault(Addr va) : vaddr(va) {} 97 void invoke(ThreadContext * tc); 98}; 99 100static inline Fault genPageTableFault(Addr va) 101{ 102 return new PageTableFault(va); 103} 104#endif 105 106static inline Fault genMachineCheckFault() 107{ 108 return new InternalProcessorError; 109} 110 111static inline Fault genAlignmentFault() 112{ 113 return new MemAddressNotAligned; 114} 115 116class PowerOnReset : public SparcFault<PowerOnReset> {}; 117 118class WatchDogReset : public SparcFault<WatchDogReset> {}; 119 120class ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {}; 121 122class SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {}; 123 124class REDStateException : public SparcFault<REDStateException> {}; 125 126class InstructionAccessException : public SparcFault<InstructionAccessException> {}; 127 128class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {}; 129 130class InstructionAccessError : public SparcFault<InstructionAccessError> {}; 131 132class IllegalInstruction : public SparcFault<IllegalInstruction> {}; 133 134class PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {}; 135 136class UnimplementedLDD : public SparcFault<UnimplementedLDD> {}; 137 138class UnimplementedSTD : public SparcFault<UnimplementedSTD> {}; 139 140class FpDisabled : public SparcFault<FpDisabled> {}; 141 142class FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {}; 143 144class FpExceptionOther : public SparcFault<FpExceptionOther> {}; 145 146class TagOverflow : public SparcFault<TagOverflow> {}; 147 148class DivisionByZero : public SparcFault<DivisionByZero> {}; 149 150class DataAccessException : public SparcFault<DataAccessException> {}; 151 152class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {}; 153 154class DataAccessError : public SparcFault<DataAccessError> {}; 155 156class DataAccessProtection : public SparcFault<DataAccessProtection> {}; 157 158class LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {}; 159 160class STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {}; 161 162class PrivilegedAction : public SparcFault<PrivilegedAction> {}; 163 164class LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {}; 165 166class STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {}; 167 168class AsyncDataError : public SparcFault<AsyncDataError> {}; 169 170class CleanWindow : public SparcFault<CleanWindow> {}; 171 172template <class T> 173class EnumeratedFault : public SparcFault<T> 174{ 175 protected: 176 uint32_t _n; 177 public: 178 EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {} 179 TrapType trapType() {return SparcFault<T>::trapType() + _n;} 180}; 181 182class InterruptLevelN : public EnumeratedFault<InterruptLevelN> 183{ 184 public: 185 InterruptLevelN(uint32_t n) : 186 EnumeratedFault<InterruptLevelN>(n) {;} 187 FaultPriority priority() {return 32 - _n;} 188}; 189 190class SpillNNormal : public EnumeratedFault<SpillNNormal> 191{ 192 public: 193 SpillNNormal(uint32_t n) : 194 EnumeratedFault<SpillNNormal>(n) {;} 195 void invoke(ThreadContext * tc); 196}; 197 198class SpillNOther : public EnumeratedFault<SpillNOther> 199{ 200 public: 201 SpillNOther(uint32_t n) : 202 EnumeratedFault<SpillNOther>(n) {;} 203}; 204 205class FillNNormal : public EnumeratedFault<FillNNormal> 206{ 207 public: 208 FillNNormal(uint32_t n) : 209 EnumeratedFault<FillNNormal>(n) {;} 210 void invoke(ThreadContext * tc); 211}; 212 213class FillNOther : public EnumeratedFault<FillNOther> 214{ 215 public: 216 FillNOther(uint32_t n) : 217 EnumeratedFault<FillNOther>(n) {;} 218}; 219 220class TrapInstruction : public EnumeratedFault<TrapInstruction> 221{ 222 private: 223 uint64_t syscall_num; 224 public: 225 TrapInstruction(uint32_t n, uint64_t syscall) : 226 EnumeratedFault<TrapInstruction>(n), syscall_num(syscall) {;} 227#if !FULL_SYSTEM 228 void invoke(ThreadContext * tc); 229#endif 230}; 231 232 233} // SparcISA namespace 234 235#endif // __FAULTS_HH__ 236