faults.hh revision 2201
12440SN/A/* 22440SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32440SN/A * All rights reserved. 42440SN/A * 52440SN/A * Redistribution and use in source and binary forms, with or without 62440SN/A * modification, are permitted provided that the following conditions are 72440SN/A * met: redistributions of source code must retain the above copyright 82440SN/A * notice, this list of conditions and the following disclaimer; 92440SN/A * redistributions in binary form must reproduce the above copyright 102440SN/A * notice, this list of conditions and the following disclaimer in the 112440SN/A * documentation and/or other materials provided with the distribution; 122440SN/A * neither the name of the copyright holders nor the names of its 132440SN/A * contributors may be used to endorse or promote products derived from 142440SN/A * this software without specific prior written permission. 152440SN/A * 162440SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172440SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182440SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192440SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202440SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212440SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222440SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232440SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242440SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252440SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262440SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A */ 282665SN/A 292440SN/A#ifndef __FAULTS_HH__ 302440SN/A#define __FAULTS_HH__ 316329Sgblack@eecs.umich.edu 326329Sgblack@eecs.umich.edu#include "base/refcnt.hh" 332440SN/A#include "sim/stats.hh" 348961Sgblack@eecs.umich.edu#include "config/full_system.hh" 356327SN/A 3612104Snathanael.premillieu@arm.comclass ExecContext; 3713610Sgiacomo.gabrielli@arm.comclass FaultBase; 3812109SRekai.GonzalezAlberquilla@arm.comtypedef RefCountingPtr<FaultBase> Fault; 396329Sgblack@eecs.umich.edu 402440SN/Atypedef const char * FaultName; 415569SN/Atypedef Stats::Scalar<> FaultStat; 422972SN/A 436329Sgblack@eecs.umich.edu// Each class has it's name statically define in _name, 446329Sgblack@eecs.umich.edu// and has a virtual function to access it's name. 456327SN/A// The function is necessary because otherwise, all objects 469046SAli.Saidi@ARM.com// which are being accessed cast as a FaultBase * (namely 479046SAli.Saidi@ARM.com// all faults returned using the Fault type) will use the 489046SAli.Saidi@ARM.com// generic FaultBase name. 4913610Sgiacomo.gabrielli@arm.com 5013610Sgiacomo.gabrielli@arm.comclass FaultBase : public RefCounted 5113610Sgiacomo.gabrielli@arm.com{ 5213610Sgiacomo.gabrielli@arm.com public: 5313610Sgiacomo.gabrielli@arm.com virtual FaultName name() = 0; 5413610Sgiacomo.gabrielli@arm.com virtual FaultStat & stat() = 0; 5513610Sgiacomo.gabrielli@arm.com#if FULL_SYSTEM 5613610Sgiacomo.gabrielli@arm.com virtual void invoke(ExecContext * xc) = 0; 5713610Sgiacomo.gabrielli@arm.com#else 5813610Sgiacomo.gabrielli@arm.com virtual void invoke(ExecContext * xc); 5913610Sgiacomo.gabrielli@arm.com#endif 6013610Sgiacomo.gabrielli@arm.com// template<typename T> 6113610Sgiacomo.gabrielli@arm.com// bool isA() {return dynamic_cast<T *>(this);} 6213610Sgiacomo.gabrielli@arm.com virtual bool isMachineCheckFault() {return false;} 6312109SRekai.GonzalezAlberquilla@arm.com virtual bool isAlignmentFault() {return false;} 646329Sgblack@eecs.umich.edu}; 656329Sgblack@eecs.umich.edu 666329Sgblack@eecs.umich.eduFaultBase * const NoFault = 0; 676329Sgblack@eecs.umich.edu 686329Sgblack@eecs.umich.edu//The ISAs are each responsible for providing a genMachineCheckFault and a 696329Sgblack@eecs.umich.edu//genAlignmentFault functions, which return faults to use in the case of a 707699Sgblack@eecs.umich.edu//machine check fault or an alignment fault, respectively. Base classes which 717699Sgblack@eecs.umich.edu//provide the name() function, and the isMachineCheckFault and isAlignmentFault 726329Sgblack@eecs.umich.edu//functions are provided below. 735569SN/A 746329Sgblack@eecs.umich.educlass MachineCheckFault : public virtual FaultBase 756329Sgblack@eecs.umich.edu{ 766329Sgblack@eecs.umich.edu private: 776329Sgblack@eecs.umich.edu static FaultName _name; 786329Sgblack@eecs.umich.edu public: 796329Sgblack@eecs.umich.edu FaultName name() {return _name;} 806329Sgblack@eecs.umich.edu bool isMachineCheckFault() {return true;} 816329Sgblack@eecs.umich.edu}; 826329Sgblack@eecs.umich.edu 836329Sgblack@eecs.umich.educlass AlignmentFault : public virtual FaultBase 846329Sgblack@eecs.umich.edu{ 856329Sgblack@eecs.umich.edu private: 866329Sgblack@eecs.umich.edu static FaultName _name; 876329Sgblack@eecs.umich.edu public: 886329Sgblack@eecs.umich.edu FaultName name() {return _name;} 896329Sgblack@eecs.umich.edu bool isAlignmentFault() {return true;} 906329Sgblack@eecs.umich.edu}; 916329Sgblack@eecs.umich.edu 926329Sgblack@eecs.umich.edu 936329Sgblack@eecs.umich.edu#endif // __FAULTS_HH__ 946329Sgblack@eecs.umich.edu