2 * Copyright (c) 2014 ARM Limited
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2007-2008 The Florida State University
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 * Authors: Andreas Sandberg
44 #include "arch/arm/insts/pseudo.hh"
45 #include "cpu/exec_context.hh"
47 DecoderFaultInst::DecoderFaultInst(ExtMachInst _machInst
)
48 : ArmStaticInst("gem5decoderFault", _machInst
, No_OpClass
),
49 faultId(static_cast<DecoderFault
>(
50 static_cast<uint8_t>(_machInst
.decoderFault
)))
52 // Don't call execute() if we're on a speculative path and the
53 // fault is an internal panic fault.
54 flags
[IsNonSpeculative
] = (faultId
== DecoderFault::PANIC
);
58 DecoderFaultInst::execute(ExecContext
*xc
, Trace::InstRecord
*traceData
) const
60 const PCState
pc_state(xc
->pcState());
61 const Addr
pc(pc_state
.instAddr());
64 case DecoderFault::UNALIGNED
:
65 if (machInst
.aarch64
) {
66 return std::make_shared
<PCAlignmentFault
>(pc
);
68 // TODO: We should check if we the receiving end is in
69 // aarch64 mode and raise a PCAlignment fault instead.
70 return std::make_shared
<PrefetchAbort
>(
71 pc
, ArmFault::AlignmentFault
);
74 case DecoderFault::PANIC
:
75 panic("Internal error in instruction decoder\n");
77 case DecoderFault::OK
:
78 panic("Decoder fault instruction without decoder fault.\n");
81 panic("Unhandled fault type");
85 DecoderFaultInst::faultName() const
88 case DecoderFault::OK
:
91 case DecoderFault::UNALIGNED
:
92 return "UnalignedInstruction";
94 case DecoderFault::PANIC
:
95 return "DecoderPanic";
98 panic("Unhandled fault type");
102 DecoderFaultInst::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
104 return csprintf("gem5fault %s", faultName());
109 FailUnimplemented::FailUnimplemented(const char *_mnemonic
,
110 ExtMachInst _machInst
)
111 : ArmStaticInst(_mnemonic
, _machInst
, No_OpClass
)
113 // don't call execute() (which panics) if we're on a
115 flags
[IsNonSpeculative
] = true;
118 FailUnimplemented::FailUnimplemented(const char *_mnemonic
,
119 ExtMachInst _machInst
,
120 const std::string
& _fullMnemonic
)
121 : ArmStaticInst(_mnemonic
, _machInst
, No_OpClass
),
122 fullMnemonic(_fullMnemonic
)
124 // don't call execute() (which panics) if we're on a
126 flags
[IsNonSpeculative
] = true;
130 FailUnimplemented::execute(ExecContext
*xc
, Trace::InstRecord
*traceData
) const
132 return std::make_shared
<UndefinedInstruction
>(machInst
, false, mnemonic
);
136 FailUnimplemented::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
138 return csprintf("%-10s (unimplemented)",
139 fullMnemonic
.size() ? fullMnemonic
.c_str() : mnemonic
);
144 WarnUnimplemented::WarnUnimplemented(const char *_mnemonic
,
145 ExtMachInst _machInst
)
146 : ArmStaticInst(_mnemonic
, _machInst
, No_OpClass
), warned(false)
148 // don't call execute() (which panics) if we're on a
150 flags
[IsNonSpeculative
] = true;
153 WarnUnimplemented::WarnUnimplemented(const char *_mnemonic
,
154 ExtMachInst _machInst
,
155 const std::string
& _fullMnemonic
)
156 : ArmStaticInst(_mnemonic
, _machInst
, No_OpClass
), warned(false),
157 fullMnemonic(_fullMnemonic
)
159 // don't call execute() (which panics) if we're on a
161 flags
[IsNonSpeculative
] = true;
165 WarnUnimplemented::execute(ExecContext
*xc
, Trace::InstRecord
*traceData
) const
168 warn("\tinstruction '%s' unimplemented\n",
169 fullMnemonic
.size() ? fullMnemonic
.c_str() : mnemonic
);
177 WarnUnimplemented::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
179 return csprintf("%-10s (unimplemented)",
180 fullMnemonic
.size() ? fullMnemonic
.c_str() : mnemonic
);
185 FlushPipeInst::FlushPipeInst(const char *_mnemonic
, ExtMachInst _machInst
)
186 : ArmStaticInst(_mnemonic
, _machInst
, No_OpClass
)
188 flags
[IsNonSpeculative
] = true;
192 FlushPipeInst::execute(ExecContext
*xc
, Trace::InstRecord
*traceData
) const
194 Fault fault
= std::make_shared
<FlushPipe
>();
199 FlushPipeInst::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
201 return csprintf("%-10s (pipe flush)", mnemonic
);