faults.hh revision 7652
11060SN/A/* 22702SN/A * Copyright (c) 2010 ARM Limited 31060SN/A * All rights reserved 41060SN/A * 51060SN/A * The license below extends only to copyright in the software and shall 61060SN/A * not be construed as granting a license to any other intellectual 71060SN/A * property including but not limited to intellectual property relating 81060SN/A * to a hardware implementation of the functionality of the software 91060SN/A * licensed hereunder. You may use the software subject to the license 101060SN/A * terms below provided that you ensure that this notice is replicated 111060SN/A * unmodified and in its entirety in all distributions of the software, 121060SN/A * modified or unmodified, in source code or in binary form. 131060SN/A * 141060SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 151060SN/A * Copyright (c) 2007-2008 The Florida State University 161060SN/A * All rights reserved. 171060SN/A * 181060SN/A * Redistribution and use in source and binary forms, with or without 191060SN/A * modification, are permitted provided that the following conditions are 201060SN/A * met: redistributions of source code must retain the above copyright 211060SN/A * notice, this list of conditions and the following disclaimer; 221060SN/A * redistributions in binary form must reproduce the above copyright 231060SN/A * notice, this list of conditions and the following disclaimer in the 241060SN/A * documentation and/or other materials provided with the distribution; 251060SN/A * neither the name of the copyright holders nor the names of its 261060SN/A * contributors may be used to endorse or promote products derived from 272665SN/A * this software without specific prior written permission. 282665SN/A * 291060SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 301060SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 311060SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 322292SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 331060SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 341060SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 351060SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 361060SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 371061SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 381060SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 392980Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 401060SN/A * 412669SN/A * Authors: Ali Saidi 421060SN/A * Gabe Black 431060SN/A */ 441060SN/A 451060SN/A#ifndef __ARM_FAULTS_HH__ 461060SN/A#define __ARM_FAULTS_HH__ 471060SN/A 481060SN/A#include "arch/arm/miscregs.hh" 491060SN/A#include "arch/arm/types.hh" 501060SN/A#include "config/full_system.hh" 511060SN/A#include "sim/faults.hh" 522292SN/A#include "base/misc.hh" 532292SN/A 541060SN/A// The design of the "name" and "vect" functions is in sim/faults.hh 552292SN/A 561060SN/Anamespace ArmISA 571060SN/A{ 582292SN/Atypedef const Addr FaultOffset; 592292SN/A 602292SN/Aclass ArmFault : public FaultBase 611060SN/A{ 621060SN/A protected: 631060SN/A Addr getVector(ThreadContext *tc); 641061SN/A 652980Sgblack@eecs.umich.edu public: 661060SN/A enum StatusEncoding 672733SN/A { 682733SN/A // Fault Status register encodings 691060SN/A // ARM ARM B3.9.4 701464SN/A AlignmentFault = 0x1, 711061SN/A DebugEvent = 0x2, 721464SN/A AccessFlag0 = 0x3, 732980Sgblack@eecs.umich.edu InstructionCacheMaintenance = 0x4, 742980Sgblack@eecs.umich.edu Translation0 = 0x5, 751464SN/A AccessFlag1 = 0x6, 761464SN/A Translation1 = 0x7, 771464SN/A SynchronousExternalAbort0 = 0x8, 781464SN/A Domain0 = 0x9, 791464SN/A SynchronousExternalAbort1 = 0x8, 801464SN/A Domain1 = 0xb, 812107SN/A TranslationTableWalkExtAbt0 = 0xc, 821464SN/A Permission0 = 0xd, 831464SN/A TranslationTableWalkExtAbt1 = 0xe, 842292SN/A Permission1 = 0xf, 851464SN/A AsynchronousExternalAbort = 0x16, 861464SN/A MemoryAccessAsynchronousParityError = 0x18, 871464SN/A MemoryAccessSynchronousParityError = 0x19, 881464SN/A TranslationTableWalkPrtyErr0 = 0x1c, 891464SN/A TranslationTableWalkPrtyErr1 = 0x1e, 901464SN/A 911464SN/A // not a real fault. This is a status code 922292SN/A // to allow the translation function to inform 932678SN/A // the memory access function not to proceed 942669SN/A // for a Prefetch that misses in the TLB. 952669SN/A PrefetchTLBMiss 961060SN/A }; 971060SN/A 981060SN/A struct FaultVals 992702SN/A { 1002702SN/A const FaultName name; 1012731SN/A const FaultOffset offset; 1022731SN/A const OperatingMode nextMode; 1031464SN/A const uint8_t armPcOffset; 1042292SN/A const uint8_t thumbPcOffset; 1052731SN/A const bool abortDisable; 1062292SN/A const bool fiqDisable; 1072292SN/A FaultStat count; 1082292SN/A }; 1091060SN/A 1101060SN/A#if FULL_SYSTEM 1111464SN/A void invoke(ThreadContext *tc); 1121060SN/A#endif 1131060SN/A virtual FaultStat& countStat() = 0; 1141060SN/A virtual FaultOffset offset() = 0; 1152698SN/A virtual OperatingMode nextMode() = 0; 1162292SN/A virtual uint8_t armPcOffset() = 0; 1171060SN/A virtual uint8_t thumbPcOffset() = 0; 1181060SN/A virtual bool abortDisable() = 0; 1191060SN/A virtual bool fiqDisable() = 0; 1202292SN/A}; 1212292SN/A 1222292SN/Atemplate<typename T> 1232292SN/Aclass ArmFaultVals : public ArmFault 1242292SN/A{ 1252292SN/A protected: 1262292SN/A static FaultVals vals; 1272292SN/A 1282292SN/A public: 1292292SN/A FaultName name() const { return vals.name; } 1302292SN/A FaultStat & countStat() {return vals.count;} 1312292SN/A FaultOffset offset() { return vals.offset; } 1322292SN/A OperatingMode nextMode() { return vals.nextMode; } 1332292SN/A uint8_t armPcOffset() { return vals.armPcOffset; } 1341060SN/A uint8_t thumbPcOffset() { return vals.thumbPcOffset; } 1351060SN/A bool abortDisable() { return vals.abortDisable; } 1361061SN/A bool fiqDisable() { return vals.fiqDisable; } 1371060SN/A}; 1381060SN/A 1392292SN/Aclass Reset : public ArmFaultVals<Reset> 1402678SN/A#if FULL_SYSTEM 1412678SN/A{ 1422678SN/A public: 1432678SN/A void invoke(ThreadContext *tc); 1442678SN/A}; 1452292SN/A#else 1462292SN/A{}; 1472292SN/A#endif //FULL_SYSTEM 1482292SN/A 1492292SN/Aclass UndefinedInstruction : public ArmFaultVals<UndefinedInstruction> 1502292SN/A{ 1512348SN/A#if !FULL_SYSTEM 1522348SN/A protected: 1531060SN/A ExtMachInst machInst; 1542292SN/A bool unknown; 1552292SN/A const char *mnemonic; 1562292SN/A bool disabled; 1572292SN/A 1582292SN/A public: 1592292SN/A UndefinedInstruction(ExtMachInst _machInst, 1601060SN/A bool _unknown, 1611464SN/A const char *_mnemonic = NULL, 1622292SN/A bool _disabled = false) : 1632292SN/A machInst(_machInst), unknown(_unknown), 1642292SN/A mnemonic(_mnemonic), disabled(_disabled) 1652292SN/A { 1662292SN/A } 1672292SN/A 1682292SN/A void invoke(ThreadContext *tc); 1692292SN/A#endif 1702292SN/A}; 1712292SN/A 1722292SN/Aclass SupervisorCall : public ArmFaultVals<SupervisorCall> 1732292SN/A{ 1742292SN/A#if !FULL_SYSTEM 1752292SN/A protected: 1762292SN/A ExtMachInst machInst; 1772292SN/A 1781061SN/A public: 1791060SN/A SupervisorCall(ExtMachInst _machInst) : machInst(_machInst) 1801060SN/A {} 1811060SN/A 1821060SN/A void invoke(ThreadContext *tc); 1831060SN/A#endif 1841060SN/A}; 1852669SN/A 1861060SN/Atemplate <class T> 1872292SN/Aclass AbortFault : public ArmFaultVals<T> 1881060SN/A{ 1891060SN/A protected: 1901060SN/A Addr faultAddr; 1912090SN/A bool write; 1921060SN/A uint8_t domain; 1931060SN/A uint8_t status; 1942292SN/A 1951060SN/A public: 1962090SN/A AbortFault(Addr _faultAddr, bool _write, 1971060SN/A uint8_t _domain, uint8_t _status) : 1981060SN/A faultAddr(_faultAddr), write(_write), 1991060SN/A domain(_domain), status(_status) 2001060SN/A {} 2011060SN/A 2021060SN/A void invoke(ThreadContext *tc); 2031060SN/A}; 2041060SN/A 2051060SN/Aclass PrefetchAbort : public AbortFault<PrefetchAbort> 2061060SN/A{ 2071060SN/A public: 2081060SN/A static const MiscRegIndex FsrIndex = MISCREG_IFSR; 2091060SN/A static const MiscRegIndex FarIndex = MISCREG_IFAR; 2101060SN/A 2111060SN/A PrefetchAbort(Addr _addr, uint8_t _status) : 2121060SN/A AbortFault<PrefetchAbort>(_addr, false, 0, _status) 2132669SN/A {} 2141060SN/A}; 2151060SN/A 2161061SN/Aclass DataAbort : public AbortFault<DataAbort> 2171060SN/A{ 2181060SN/A public: 2191060SN/A static const MiscRegIndex FsrIndex = MISCREG_DFSR; 2202702SN/A static const MiscRegIndex FarIndex = MISCREG_DFAR; 2211060SN/A 2221060SN/A DataAbort(Addr _addr, uint8_t _domain, bool _write, uint8_t _status) : 2231060SN/A AbortFault<DataAbort>(_addr, _write, _domain, _status) 2241060SN/A {} 2251060SN/A}; 2261061SN/A 2272132SN/Aclass Interrupt : public ArmFaultVals<Interrupt> {}; 2281060SN/Aclass FastInterrupt : public ArmFaultVals<FastInterrupt> {}; 2291060SN/A 2302702SN/A// A fault that flushes the pipe, excluding the faulting instructions 2312669SN/Aclass FlushPipe : public ArmFaultVals<FlushPipe> 2321060SN/A{ 2331060SN/A public: 2341060SN/A FlushPipe() {} 2351060SN/A void invoke(ThreadContext *tc); 2361060SN/A}; 2371061SN/A 2382132SN/Astatic inline Fault genMachineCheckFault() 2391060SN/A{ 2401060SN/A return new Reset(); 2412702SN/A} 2422669SN/A 2431060SN/A} // ArmISA namespace 2441060SN/A 2451061SN/A#endif // __ARM_FAULTS_HH__ 2461060SN/A