faults.hh revision 13475
13560SN/A/*
23560SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
33560SN/A * All rights reserved.
43560SN/A *
53560SN/A * Redistribution and use in source and binary forms, with or without
63560SN/A * modification, are permitted provided that the following conditions are
73560SN/A * met: redistributions of source code must retain the above copyright
83560SN/A * notice, this list of conditions and the following disclaimer;
93560SN/A * redistributions in binary form must reproduce the above copyright
103560SN/A * notice, this list of conditions and the following disclaimer in the
113560SN/A * documentation and/or other materials provided with the distribution;
123560SN/A * neither the name of the copyright holders nor the names of its
133560SN/A * contributors may be used to endorse or promote products derived from
143560SN/A * this software without specific prior written permission.
153560SN/A *
163560SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
173560SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
183560SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
193560SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
203560SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
213560SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
223560SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
233560SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243560SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253560SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
263560SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273560SN/A *
283560SN/A * Authors: Nathan Binkert
293560SN/A *          Gabe Black
303560SN/A */
313560SN/A
323560SN/A#ifndef __FAULTS_HH__
333560SN/A#define __FAULTS_HH__
343560SN/A
353560SN/A#include "base/types.hh"
369329Sdam.sunwoo@arm.com#include "cpu/static_inst.hh"
373565Sgblack@eecs.umich.edu#include "sim/stats.hh"
383560SN/A
393560SN/Aclass ThreadContext;
403560SN/A
418232Snate@binkert.orgtypedef const char * FaultName;
423560SN/Atypedef Stats::Scalar FaultStat;
433560SN/A
443560SN/Aclass FaultBase
453560SN/A{
463560SN/A  public:
473560SN/A    virtual FaultName name() const = 0;
483560SN/A    virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst =
493560SN/A                        StaticInst::nullStaticInstPtr);
503560SN/A
513560SN/A    virtual ~FaultBase() {};
523560SN/A};
533560SN/A
543560SN/Aclass UnimpFault : public FaultBase
553560SN/A{
563560SN/A  private:
573560SN/A    std::string panicStr;
583560SN/A  public:
593560SN/A    UnimpFault(std::string _str)
603560SN/A        : panicStr(_str)
613560SN/A    { }
623560SN/A
633560SN/A    FaultName name() const { return "Unimplemented simulator feature"; }
643560SN/A    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
653560SN/A                StaticInst::nullStaticInstPtr);
663560SN/A};
673560SN/A
683560SN/Aclass ReExec : public FaultBase
693560SN/A{
703560SN/A  public:
713560SN/A    virtual FaultName name() const { return "Re-execution fault"; }
723560SN/A    ReExec() {}
733560SN/A    void invoke(ThreadContext *tc, const StaticInstPtr &inst =
743560SN/A                StaticInst::nullStaticInstPtr);
753560SN/A};
763560SN/A
773560SN/A/*
783560SN/A * This class is needed to allow system call retries to occur for blocking
793560SN/A * system calls in SE mode. A retry fault will be generated by the system call
803560SN/A * emulation code if blocking conditions arise; the fault is passed up the
813560SN/A * function call chain into the CPU model where it is handled by retrying the
823560SN/A * syscall instruction on a later tick.
833560SN/A */
843560SN/Aclass SyscallRetryFault : public FaultBase
853560SN/A{
863560SN/A  public:
873560SN/A    virtual FaultName name() const { return "System call retry fault"; }
883560SN/A    SyscallRetryFault() {}
893560SN/A    void invoke(ThreadContext *tc, const StaticInstPtr &inst =
903560SN/A                StaticInst::nullStaticInstPtr);
913560SN/A};
923560SN/A
933560SN/Aclass GenericPageTableFault : public FaultBase
943560SN/A{
953560SN/A  private:
963560SN/A    Addr vaddr;
973560SN/A  public:
983560SN/A    FaultName name() const { return "Generic page table fault"; }
993560SN/A    GenericPageTableFault(Addr va) : vaddr(va) {}
1003560SN/A    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
1013560SN/A                StaticInst::nullStaticInstPtr);
1023560SN/A};
1033560SN/A
1043560SN/Aclass GenericAlignmentFault : public FaultBase
1053560SN/A{
1063560SN/A  private:
1073560SN/A    Addr vaddr;
1083560SN/A  public:
1093560SN/A    FaultName name() const { return "Generic alignment fault"; }
1103560SN/A    GenericAlignmentFault(Addr va) : vaddr(va) {}
1113560SN/A    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
1123560SN/A                StaticInst::nullStaticInstPtr);
1133560SN/A};
1143560SN/A
1153560SN/A#endif // __FAULTS_HH__
1163560SN/A