faults.hh revision 7678
12810SN/A/* 211866Ssascha.bischoff@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 39663Suri.wiener@arm.com * All rights reserved. 49663Suri.wiener@arm.com * 59663Suri.wiener@arm.com * Redistribution and use in source and binary forms, with or without 69663Suri.wiener@arm.com * modification, are permitted provided that the following conditions are 79663Suri.wiener@arm.com * met: redistributions of source code must retain the above copyright 89663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer; 99663Suri.wiener@arm.com * redistributions in binary form must reproduce the above copyright 109663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer in the 119663Suri.wiener@arm.com * documentation and/or other materials provided with the distribution; 129663Suri.wiener@arm.com * neither the name of the copyright holders nor the names of its 139663Suri.wiener@arm.com * contributors may be used to endorse or promote products derived from 142810SN/A * this software without specific prior written permission. 157636Ssteve.reinhardt@amd.com * 162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272810SN/A * 282810SN/A * Authors: Gabe Black 292810SN/A * Kevin Lim 302810SN/A */ 312810SN/A 322810SN/A#ifndef __SPARC_FAULTS_HH__ 332810SN/A#define __SPARC_FAULTS_HH__ 342810SN/A 352810SN/A#include "config/full_system.hh" 362810SN/A#include "cpu/static_inst.hh" 372810SN/A#include "sim/faults.hh" 382810SN/A 392810SN/A// The design of the "name" and "vect" functions is in sim/faults.hh 402810SN/A 412810SN/Anamespace SparcISA 422810SN/A{ 432810SN/A 442810SN/Atypedef uint32_t TrapType; 452810SN/Atypedef uint32_t FaultPriority; 462810SN/A 472810SN/Aclass ITB; 482810SN/A 492810SN/Aclass SparcFaultBase : public FaultBase 5011486Snikos.nikoleris@arm.com{ 5111486Snikos.nikoleris@arm.com public: 526216Snate@binkert.org enum PrivilegeLevel 536216Snate@binkert.org { 542810SN/A U, User = U, 552810SN/A P, Privileged = P, 562810SN/A H, Hyperprivileged = H, 5712334Sgabeblack@google.com NumLevels, 586216Snate@binkert.org SH = -1, 598232Snate@binkert.org ShouldntHappen = SH 606216Snate@binkert.org }; 616216Snate@binkert.org struct FaultVals 622810SN/A { 632810SN/A const FaultName name; 642810SN/A const TrapType trapType; 6511375Sandreas.hansson@arm.com const FaultPriority priority; 6611284Sandreas.hansson@arm.com const PrivilegeLevel nextPrivilegeLevel[NumLevels]; 6710503SCurtis.Dunham@arm.com FaultStat count; 6811741Snikos.nikoleris@arm.com }; 692810SN/A#if FULL_SYSTEM 702810SN/A void invoke(ThreadContext * tc, 712810SN/A StaticInstPtr inst = StaticInst::nullStaticInstPtr); 724903SN/A#endif 7311741Snikos.nikoleris@arm.com virtual TrapType trapType() = 0; 744903SN/A virtual FaultPriority priority() = 0; 754903SN/A virtual FaultStat & countStat() = 0; 764903SN/A virtual PrivilegeLevel getNextLevel(PrivilegeLevel current) = 0; 7711740Snikos.nikoleris@arm.com}; 7811741Snikos.nikoleris@arm.com 7911741Snikos.nikoleris@arm.comtemplate<typename T> 804903SN/Aclass SparcFault : public SparcFaultBase 815875Ssteve.reinhardt@amd.com{ 8211284Sandreas.hansson@arm.com protected: 8311284Sandreas.hansson@arm.com static FaultVals vals; 844903SN/A public: 854903SN/A FaultName name() const {return vals.name;} 867669Ssteve.reinhardt@amd.com TrapType trapType() {return vals.trapType;} 877669Ssteve.reinhardt@amd.com FaultPriority priority() {return vals.priority;} 887669Ssteve.reinhardt@amd.com FaultStat & countStat() {return vals.count;} 897669Ssteve.reinhardt@amd.com PrivilegeLevel getNextLevel(PrivilegeLevel current) 904903SN/A { 914903SN/A return vals.nextPrivilegeLevel[current]; 9211741Snikos.nikoleris@arm.com } 9311741Snikos.nikoleris@arm.com}; 9411741Snikos.nikoleris@arm.com 9511741Snikos.nikoleris@arm.comclass PowerOnReset : public SparcFault<PowerOnReset> 965318SN/A{ 9711740Snikos.nikoleris@arm.com#if FULL_SYSTEM 984908SN/A void invoke(ThreadContext * tc, 9911740Snikos.nikoleris@arm.com StaticInstPtr inst = StaticInst::nullStaticInstPtr); 10011740Snikos.nikoleris@arm.com#endif 10111740Snikos.nikoleris@arm.com}; 10211740Snikos.nikoleris@arm.com 10311740Snikos.nikoleris@arm.comclass WatchDogReset : public SparcFault<WatchDogReset> {}; 10411741Snikos.nikoleris@arm.com 10511740Snikos.nikoleris@arm.comclass ExternallyInitiatedReset : public SparcFault<ExternallyInitiatedReset> {}; 10611740Snikos.nikoleris@arm.com 10711740Snikos.nikoleris@arm.comclass SoftwareInitiatedReset : public SparcFault<SoftwareInitiatedReset> {}; 10811740Snikos.nikoleris@arm.com 10911740Snikos.nikoleris@arm.comclass REDStateException : public SparcFault<REDStateException> {}; 11011741Snikos.nikoleris@arm.com 11111741Snikos.nikoleris@arm.comclass StoreError : public SparcFault<StoreError> {}; 11211740Snikos.nikoleris@arm.com 11311741Snikos.nikoleris@arm.comclass InstructionAccessException : public SparcFault<InstructionAccessException> {}; 1145318SN/A 1159543Ssascha.bischoff@arm.com//class InstructionAccessMMUMiss : public SparcFault<InstructionAccessMMUMiss> {}; 1169543Ssascha.bischoff@arm.com 1179543Ssascha.bischoff@arm.comclass InstructionAccessError : public SparcFault<InstructionAccessError> {}; 1189543Ssascha.bischoff@arm.com 11911484Snikos.nikoleris@arm.comclass IllegalInstruction : public SparcFault<IllegalInstruction> {}; 1204908SN/A 1214908SN/Aclass PrivilegedOpcode : public SparcFault<PrivilegedOpcode> {}; 12211083Sandreas.hansson@arm.com 12311083Sandreas.hansson@arm.com//class UnimplementedLDD : public SparcFault<UnimplementedLDD> {}; 12411083Sandreas.hansson@arm.com 1254908SN/A//class UnimplementedSTD : public SparcFault<UnimplementedSTD> {}; 1264903SN/A 1274903SN/Aclass FpDisabled : public SparcFault<FpDisabled> {}; 12811741Snikos.nikoleris@arm.com 1294903SN/Aclass FpExceptionIEEE754 : public SparcFault<FpExceptionIEEE754> {}; 1304903SN/A 1314903SN/Aclass FpExceptionOther : public SparcFault<FpExceptionOther> {}; 1327667Ssteve.reinhardt@amd.com 1337667Ssteve.reinhardt@amd.comclass TagOverflow : public SparcFault<TagOverflow> {}; 1347667Ssteve.reinhardt@amd.com 13511286Sandreas.hansson@arm.comclass CleanWindow : public SparcFault<CleanWindow> {}; 13611286Sandreas.hansson@arm.com 13711286Sandreas.hansson@arm.comclass DivisionByZero : public SparcFault<DivisionByZero> {}; 1387667Ssteve.reinhardt@amd.com 1397667Ssteve.reinhardt@amd.comclass InternalProcessorError : 1407667Ssteve.reinhardt@amd.com public SparcFault<InternalProcessorError> 1417667Ssteve.reinhardt@amd.com{ 1427667Ssteve.reinhardt@amd.com public: 1437667Ssteve.reinhardt@amd.com bool isMachineCheckFault() const {return true;} 1447669Ssteve.reinhardt@amd.com}; 1457669Ssteve.reinhardt@amd.com 1467669Ssteve.reinhardt@amd.comclass InstructionInvalidTSBEntry : public SparcFault<InstructionInvalidTSBEntry> {}; 1477667Ssteve.reinhardt@amd.com 14811286Sandreas.hansson@arm.comclass DataInvalidTSBEntry : public SparcFault<DataInvalidTSBEntry> {}; 14911286Sandreas.hansson@arm.com 15011286Sandreas.hansson@arm.comclass DataAccessException : public SparcFault<DataAccessException> {}; 15111286Sandreas.hansson@arm.com 15211286Sandreas.hansson@arm.com//class DataAccessMMUMiss : public SparcFault<DataAccessMMUMiss> {}; 15311286Sandreas.hansson@arm.com 15411286Sandreas.hansson@arm.comclass DataAccessError : public SparcFault<DataAccessError> {}; 15511286Sandreas.hansson@arm.com 15611286Sandreas.hansson@arm.comclass DataAccessProtection : public SparcFault<DataAccessProtection> {}; 15711286Sandreas.hansson@arm.com 15811286Sandreas.hansson@arm.comclass MemAddressNotAligned : 15911286Sandreas.hansson@arm.com public SparcFault<MemAddressNotAligned> 16011286Sandreas.hansson@arm.com{ 1617667Ssteve.reinhardt@amd.com public: 1627667Ssteve.reinhardt@amd.com bool isAlignmentFault() const {return true;} 1637667Ssteve.reinhardt@amd.com}; 1644903SN/A 1654903SN/Aclass LDDFMemAddressNotAligned : public SparcFault<LDDFMemAddressNotAligned> {}; 1664903SN/A 1674903SN/Aclass STDFMemAddressNotAligned : public SparcFault<STDFMemAddressNotAligned> {}; 1684903SN/A 1694903SN/Aclass PrivilegedAction : public SparcFault<PrivilegedAction> {}; 17010766Sandreas.hansson@arm.com 17110766Sandreas.hansson@arm.comclass LDQFMemAddressNotAligned : public SparcFault<LDQFMemAddressNotAligned> {}; 1724903SN/A 1734903SN/Aclass STQFMemAddressNotAligned : public SparcFault<STQFMemAddressNotAligned> {}; 1744903SN/A 1754903SN/Aclass InstructionRealTranslationMiss : 1764903SN/A public SparcFault<InstructionRealTranslationMiss> {}; 1774903SN/A 1782810SN/Aclass DataRealTranslationMiss : public SparcFault<DataRealTranslationMiss> {}; 1794908SN/A 1804908SN/A//class AsyncDataError : public SparcFault<AsyncDataError> {}; 18110766Sandreas.hansson@arm.com 18210766Sandreas.hansson@arm.comtemplate <class T> 1839543Ssascha.bischoff@arm.comclass EnumeratedFault : public SparcFault<T> 1849543Ssascha.bischoff@arm.com{ 1859543Ssascha.bischoff@arm.com protected: 1869543Ssascha.bischoff@arm.com uint32_t _n; 1879543Ssascha.bischoff@arm.com public: 1889543Ssascha.bischoff@arm.com EnumeratedFault(uint32_t n) : SparcFault<T>(), _n(n) {} 18910766Sandreas.hansson@arm.com TrapType trapType() {return SparcFault<T>::trapType() + _n;} 19011484Snikos.nikoleris@arm.com}; 1915318SN/A 1925318SN/Aclass InterruptLevelN : public EnumeratedFault<InterruptLevelN> 19311742Snikos.nikoleris@arm.com{ 1944908SN/A public: 1954908SN/A InterruptLevelN(uint32_t n) : EnumeratedFault<InterruptLevelN>(n) {;} 1964908SN/A FaultPriority priority() {return 3200 - _n*100;} 1974908SN/A}; 1984908SN/A 1994920SN/Aclass HstickMatch : public SparcFault<HstickMatch> {}; 2004920SN/A 2014920SN/Aclass TrapLevelZero : public SparcFault<TrapLevelZero> {}; 20210766Sandreas.hansson@arm.com 20310766Sandreas.hansson@arm.comclass InterruptVector : public SparcFault<InterruptVector> {}; 2044920SN/A 2054920SN/Aclass PAWatchpoint : public SparcFault<PAWatchpoint> {}; 2064920SN/A 2074920SN/Aclass VAWatchpoint : public SparcFault<VAWatchpoint> {}; 2084920SN/A 2094920SN/Aclass FastInstructionAccessMMUMiss : 2104920SN/A public SparcFault<FastInstructionAccessMMUMiss> 2114920SN/A{ 2124908SN/A#if !FULL_SYSTEM 21310766Sandreas.hansson@arm.com protected: 21410766Sandreas.hansson@arm.com Addr vaddr; 2155314SN/A public: 21610766Sandreas.hansson@arm.com FastInstructionAccessMMUMiss(Addr addr) : vaddr(addr) 2175875Ssteve.reinhardt@amd.com {} 21810766Sandreas.hansson@arm.com void invoke(ThreadContext * tc, 2198988SAli.Saidi@ARM.com StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2208988SAli.Saidi@ARM.com#endif 2218988SAli.Saidi@ARM.com}; 2228988SAli.Saidi@ARM.com 2238988SAli.Saidi@ARM.comclass FastDataAccessMMUMiss : public SparcFault<FastDataAccessMMUMiss> 2248988SAli.Saidi@ARM.com{ 2258988SAli.Saidi@ARM.com#if !FULL_SYSTEM 2268988SAli.Saidi@ARM.com protected: 2278988SAli.Saidi@ARM.com Addr vaddr; 2288988SAli.Saidi@ARM.com public: 2298988SAli.Saidi@ARM.com FastDataAccessMMUMiss(Addr addr) : vaddr(addr) 2308988SAli.Saidi@ARM.com {} 2315875Ssteve.reinhardt@amd.com void invoke(ThreadContext * tc, 2325875Ssteve.reinhardt@amd.com StaticInstPtr inst = StaticInst::nullStaticInstPtr); 23310766Sandreas.hansson@arm.com#endif 23411744Snikos.nikoleris@arm.com}; 2355314SN/A 2365314SN/Aclass FastDataAccessProtection : public SparcFault<FastDataAccessProtection> {}; 2375314SN/A 2385314SN/Aclass InstructionBreakpoint : public SparcFault<InstructionBreakpoint> {}; 2395314SN/A 24010764Sandreas.hansson@arm.comclass CpuMondo : public SparcFault<CpuMondo> {}; 24111197Sandreas.hansson@arm.com 2422810SN/Aclass DevMondo : public SparcFault<DevMondo> {}; 24310764Sandreas.hansson@arm.com 24410764Sandreas.hansson@arm.comclass ResumableError : public SparcFault<ResumableError> {}; 24510028SGiacomo.Gabrielli@arm.com 24610764Sandreas.hansson@arm.comclass SpillNNormal : public EnumeratedFault<SpillNNormal> 2474666SN/A{ 2484626SN/A public: 2495730SSteve.Reinhardt@amd.com SpillNNormal(uint32_t n) : EnumeratedFault<SpillNNormal>(n) {;} 2504626SN/A //These need to be handled specially to enable spill traps in SE 2514626SN/A#if !FULL_SYSTEM 2524908SN/A void invoke(ThreadContext * tc, 2539725Sandreas.hansson@arm.com StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2544626SN/A#endif 2555875Ssteve.reinhardt@amd.com}; 2565875Ssteve.reinhardt@amd.com 2575875Ssteve.reinhardt@amd.comclass SpillNOther : public EnumeratedFault<SpillNOther> 25811741Snikos.nikoleris@arm.com{ 2599725Sandreas.hansson@arm.com public: 2602810SN/A SpillNOther(uint32_t n) : EnumeratedFault<SpillNOther>(n) {;} 2612810SN/A}; 2624908SN/A 2635318SN/Aclass FillNNormal : public EnumeratedFault<FillNNormal> 2645318SN/A{ 2655318SN/A public: 2665318SN/A FillNNormal(uint32_t n) : EnumeratedFault<FillNNormal>(n) {;} 2675318SN/A //These need to be handled specially to enable fill traps in SE 2685318SN/A#if !FULL_SYSTEM 2695318SN/A void invoke(ThreadContext * tc, 2709725Sandreas.hansson@arm.com StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2715318SN/A#endif 2725318SN/A}; 27311375Sandreas.hansson@arm.com 27411284Sandreas.hansson@arm.comclass FillNOther : public EnumeratedFault<FillNOther> 2754908SN/A{ 2764908SN/A public: 27710424Sandreas.hansson@arm.com FillNOther(uint32_t n) : EnumeratedFault<FillNOther>(n) {;} 2784908SN/A}; 27911284Sandreas.hansson@arm.com 2807667Ssteve.reinhardt@amd.comclass TrapInstruction : public EnumeratedFault<TrapInstruction> 2817667Ssteve.reinhardt@amd.com{ 2824908SN/A public: 2834908SN/A TrapInstruction(uint32_t n) : EnumeratedFault<TrapInstruction>(n) {;} 2844908SN/A //In SE, trap instructions are requesting services from the OS. 2859725Sandreas.hansson@arm.com#if !FULL_SYSTEM 2864908SN/A void invoke(ThreadContext * tc, 2874908SN/A StaticInstPtr inst = StaticInst::nullStaticInstPtr); 2884908SN/A#endif 2894908SN/A}; 2902810SN/A 2912810SN/Astatic inline Fault genMachineCheckFault() 2922810SN/A{ 2939725Sandreas.hansson@arm.com return new InternalProcessorError; 2949725Sandreas.hansson@arm.com} 2959725Sandreas.hansson@arm.com 2962810SN/A 2972810SN/A} // SparcISA namespace 2982810SN/A 2992810SN/A#endif // __SPARC_FAULTS_HH__ 3002810SN/A