faults.hh revision 2612
12889Sbinkertn@umich.edu/* 22889Sbinkertn@umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan 32889Sbinkertn@umich.edu * All rights reserved. 42889Sbinkertn@umich.edu * 52889Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without 62889Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are 72889Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright 82889Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer; 92889Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright 102889Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the 112889Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution; 122889Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its 132889Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from 142889Sbinkertn@umich.edu * this software without specific prior written permission. 152889Sbinkertn@umich.edu * 162889Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172889Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182889Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192889Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202889Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212889Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222889Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232889Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242889Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252889Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262889Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272889Sbinkertn@umich.edu */ 282889Sbinkertn@umich.edu 294850Snate@binkert.org#ifndef __FAULTS_HH__ 304850Snate@binkert.org#define __FAULTS_HH__ 314850Snate@binkert.org 324850Snate@binkert.org#include "base/refcnt.hh" 334850Snate@binkert.org#include "sim/stats.hh" 344850Snate@binkert.org#include "config/full_system.hh" 352889Sbinkertn@umich.edu 362889Sbinkertn@umich.educlass ExecContext; 378327Sgblack@eecs.umich.educlass FaultBase; 385470Snate@binkert.orgtypedef RefCountingPtr<FaultBase> Fault; 398333Snate@binkert.org 408333Snate@binkert.orgtypedef const char * FaultName; 412889Sbinkertn@umich.edutypedef Stats::Scalar<> FaultStat; 428234Snate@binkert.org 438234Snate@binkert.org// Each class has it's name statically define in _name, 448234Snate@binkert.org// and has a virtual function to access it's name. 452889Sbinkertn@umich.edu// The function is necessary because otherwise, all objects 468234Snate@binkert.org// which are being accessed cast as a FaultBase * (namely 478234Snate@binkert.org// all faults returned using the Fault type) will use the 488234Snate@binkert.org// generic FaultBase name. 498234Snate@binkert.org 502889Sbinkertn@umich.educlass FaultBase : public RefCounted 518234Snate@binkert.org{ 528234Snate@binkert.org public: 538234Snate@binkert.org virtual FaultName name() = 0; 548234Snate@binkert.org#if FULL_SYSTEM 558234Snate@binkert.org virtual void invoke(ExecContext * xc); 568234Snate@binkert.org#else 578234Snate@binkert.org virtual void invoke(ExecContext * xc); 582889Sbinkertn@umich.edu#endif 598234Snate@binkert.org// template<typename T> 608234Snate@binkert.org// bool isA() {return dynamic_cast<T *>(this);} 618234Snate@binkert.org virtual bool isMachineCheckFault() {return false;} 628234Snate@binkert.org virtual bool isAlignmentFault() {return false;} 638234Snate@binkert.org}; 648234Snate@binkert.org 658234Snate@binkert.orgFaultBase * const NoFault = 0; 668234Snate@binkert.org 678234Snate@binkert.orgclass UnimpFault : public FaultBase 688234Snate@binkert.org{ 698234Snate@binkert.org private: 708234Snate@binkert.org std::string panicStr; 718234Snate@binkert.org public: 728234Snate@binkert.org UnimpFault(std::string _str) 738234Snate@binkert.org : panicStr(_str) 748234Snate@binkert.org { } 758234Snate@binkert.org 768234Snate@binkert.org FaultName name() {return "Unimplemented simulator feature";} 778234Snate@binkert.org void invoke(ExecContext * xc); 788234Snate@binkert.org}; 798234Snate@binkert.org 802889Sbinkertn@umich.edu#endif // __FAULTS_HH__ 818234Snate@binkert.org