faults.hh revision 7678
11689SN/A/*
210333Smitch.hayenga@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
39920Syasuko.eckert@amd.com * All rights reserved.
47944SGiacomo.Gabrielli@arm.com *
57944SGiacomo.Gabrielli@arm.com * Redistribution and use in source and binary forms, with or without
67944SGiacomo.Gabrielli@arm.com * modification, are permitted provided that the following conditions are
77944SGiacomo.Gabrielli@arm.com * met: redistributions of source code must retain the above copyright
87944SGiacomo.Gabrielli@arm.com * notice, this list of conditions and the following disclaimer;
97944SGiacomo.Gabrielli@arm.com * redistributions in binary form must reproduce the above copyright
107944SGiacomo.Gabrielli@arm.com * notice, this list of conditions and the following disclaimer in the
117944SGiacomo.Gabrielli@arm.com * documentation and/or other materials provided with the distribution;
127944SGiacomo.Gabrielli@arm.com * neither the name of the copyright holders nor the names of its
137944SGiacomo.Gabrielli@arm.com * contributors may be used to endorse or promote products derived from
147944SGiacomo.Gabrielli@arm.com * this software without specific prior written permission.
152326SN/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.
271689SN/A *
281689SN/A * Authors: Nathan Binkert
291689SN/A *          Gabe Black
301689SN/A */
311689SN/A
321689SN/A#ifndef __FAULTS_HH__
331689SN/A#define __FAULTS_HH__
341689SN/A
351689SN/A#include "base/refcnt.hh"
361689SN/A#include "base/types.hh"
371689SN/A#include "sim/fault.hh"
381689SN/A#include "sim/stats.hh"
391689SN/A#include "config/full_system.hh"
402665Ssaidi@eecs.umich.edu#include "cpu/static_inst.hh"
412665Ssaidi@eecs.umich.edu
422831Sksewell@umich.educlass ThreadContext;
431689SN/A
441689SN/Atypedef const char * FaultName;
459944Smatt.horsnell@ARM.comtypedef Stats::Scalar FaultStat;
469944Smatt.horsnell@ARM.com
479944Smatt.horsnell@ARM.com// Each class has it's name statically define in _name,
482064SN/A// and has a virtual function to access it's name.
491060SN/A// The function is necessary because otherwise, all objects
501060SN/A// which are being accessed cast as a FaultBase * (namely
512292SN/A// all faults returned using the Fault type) will use the
521717SN/A// generic FaultBase name.
538232Snate@binkert.org
544762Snate@binkert.orgclass FaultBase : public RefCounted
556221Snate@binkert.org{
564762Snate@binkert.org  public:
571060SN/A    virtual FaultName name() const = 0;
588737Skoansin.tan@gmail.com    virtual void invoke(ThreadContext * tc,
598737Skoansin.tan@gmail.com            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
608737Skoansin.tan@gmail.com    virtual bool isMachineCheckFault() const {return false;}
615529Snate@binkert.org    virtual bool isAlignmentFault() const {return false;}
621061SN/A};
632292SN/A
645606Snate@binkert.orgFaultBase * const NoFault = 0;
658581Ssteve.reinhardt@amd.com
668581Ssteve.reinhardt@amd.comclass UnimpFault : public FaultBase
671060SN/A{
682292SN/A  private:
692292SN/A    std::string panicStr;
702292SN/A  public:
712292SN/A    UnimpFault(std::string _str)
722292SN/A        : panicStr(_str)
732292SN/A    { }
742326SN/A
752292SN/A    FaultName name() const {return "Unimplemented simulator feature";}
762292SN/A    void invoke(ThreadContext * tc,
772292SN/A            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
782292SN/A};
792292SN/A
802292SN/A#if !FULL_SYSTEM
815336Shines@cs.fsu.educlass GenericPageTableFault : public FaultBase
822292SN/A{
834873Sstever@eecs.umich.edu  private:
842292SN/A    Addr vaddr;
852292SN/A  public:
862292SN/A    FaultName name() const {return "Generic page table fault";}
874329Sktlim@umich.edu    GenericPageTableFault(Addr va) : vaddr(va) {}
885529Snate@binkert.org    void invoke(ThreadContext * tc,
894329Sktlim@umich.edu            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
904329Sktlim@umich.edu};
914329Sktlim@umich.edu
922292SN/Aclass GenericAlignmentFault : public FaultBase
932292SN/A{
942292SN/A  private:
952292SN/A    Addr vaddr;
962292SN/A  public:
972292SN/A    FaultName name() const {return "Generic alignment fault";}
985529Snate@binkert.org    GenericAlignmentFault(Addr va) : vaddr(va) {}
991060SN/A    void invoke(ThreadContext * tc,
1009920Syasuko.eckert@amd.com            StaticInstPtr inst = StaticInst::nullStaticInstPtr);
10112109SRekai.GonzalezAlberquilla@arm.com};
1029920Syasuko.eckert@amd.com#endif
10312109SRekai.GonzalezAlberquilla@arm.com
10412109SRekai.GonzalezAlberquilla@arm.com#endif // __FAULTS_HH__
10512109SRekai.GonzalezAlberquilla@arm.com