faults.hh revision 2665
11689SN/A/*
22326SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
31689SN/A * All rights reserved.
41689SN/A *
51689SN/A * Redistribution and use in source and binary forms, with or without
61689SN/A * modification, are permitted provided that the following conditions are
71689SN/A * met: redistributions of source code must retain the above copyright
81689SN/A * notice, this list of conditions and the following disclaimer;
91689SN/A * redistributions in binary form must reproduce the above copyright
101689SN/A * notice, this list of conditions and the following disclaimer in the
111689SN/A * documentation and/or other materials provided with the distribution;
121689SN/A * neither the name of the copyright holders nor the names of its
131689SN/A * contributors may be used to endorse or promote products derived from
141689SN/A * this software without specific prior written permission.
151689SN/A *
161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert
291689SN/A *          Gabe Black
301689SN/A */
311060SN/A
321060SN/A#ifndef __FAULTS_HH__
331689SN/A#define __FAULTS_HH__
341060SN/A
351060SN/A#include "base/refcnt.hh"
361060SN/A#include "sim/stats.hh"
371060SN/A#include "config/full_system.hh"
382292SN/A
391717SN/Aclass ExecContext;
401060SN/Aclass FaultBase;
412292SN/Atypedef RefCountingPtr<FaultBase> Fault;
421681SN/A
431681SN/Atypedef const char * FaultName;
442292SN/Atypedef Stats::Scalar<> FaultStat;
452326SN/A
461061SN/A// Each class has it's name statically define in _name,
471060SN/A// and has a virtual function to access it's name.
481061SN/A// The function is necessary because otherwise, all objects
492292SN/A// which are being accessed cast as a FaultBase * (namely
502292SN/A// all faults returned using the Fault type) will use the
512292SN/A// generic FaultBase name.
522292SN/A
532820Sktlim@umich.educlass FaultBase : public RefCounted
542292SN/A{
552820Sktlim@umich.edu  public:
562820Sktlim@umich.edu    virtual FaultName name() = 0;
572307SN/A#if FULL_SYSTEM
582307SN/A    virtual void invoke(ExecContext * xc);
591060SN/A#else
602292SN/A    virtual void invoke(ExecContext * xc);
612292SN/A#endif
622292SN/A//    template<typename T>
631060SN/A//    bool isA() {return dynamic_cast<T *>(this);}
641060SN/A    virtual bool isMachineCheckFault() {return false;}
651060SN/A    virtual bool isAlignmentFault() {return false;}
661060SN/A};
671060SN/A
681060SN/AFaultBase * const NoFault = 0;
691681SN/A
702292SN/Aclass UnimpFault : public FaultBase
711681SN/A{
722292SN/A  private:
732292SN/A    std::string panicStr;
742292SN/A  public:
752292SN/A    UnimpFault(std::string _str)
762292SN/A        : panicStr(_str)
772292SN/A    { }
782292SN/A
792820Sktlim@umich.edu    FaultName name() {return "Unimplemented simulator feature";}
802820Sktlim@umich.edu    void invoke(ExecContext * xc);
812292SN/A};
822292SN/A
832820Sktlim@umich.edu#endif // __FAULTS_HH__
842820Sktlim@umich.edu