unimp.isa revision 5222:bb733a878f85
1// -*- mode:c++ -*-
2
3// Copyright N) 2007 MIPS Technologies, Inc.  All Rights Reserved
4
5//  This software is part of the M5 simulator.
6
7//  THIS IS A LEGAL AGREEMENT.  BY DOWNLOADING, USING, COPYING, CREATING
8//  DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
9//  TO THESE TERMS AND CONDITIONS.
10
11//  Permission is granted to use, copy, create derivative works and
12//  distribute this software and such derivative works for any purpose,
13//  so long as (1) the copyright notice above, this grant of permission,
14//  and the disclaimer below appear in all copies and derivative works
15//  made, (2) the copyright notice above is augmented as appropriate to
16//  reflect the addition of any new copyrightable work in a derivative
17//  work (e.g., Copyright N) <Publication Year> Copyright Owner), and (3)
18//  the name of MIPS Technologies, Inc. ($(B!H(BMIPS$(B!I(B) is not used in any
19//  advertising or publicity pertaining to the use or distribution of
20//  this software without specific, written prior authorization.
21
22//  THIS SOFTWARE IS PROVIDED $(B!H(BAS IS.$(B!I(B  MIPS MAKES NO WARRANTIES AND
23//  DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
24//  OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25//  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
26//  NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
27//  IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
28//  INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
29//  ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
30//  THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
31//  IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
32//  STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
33//  POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
34
35//Authors: Korey L. Sewell
36
37
38////////////////////////////////////////////////////////////////////
39//
40// Unimplemented instructions
41//
42
43output header {{
44    /**
45     * Static instruction class for unimplemented instructions that
46     * cause simulator termination.  Note that these are recognized
47     * (legal) instructions that the simulator does not support; the
48     * 'Unknown' class is used for unrecognized/illegal instructions.
49     * This is a leaf class.
50     */
51    class FailUnimplemented : public MipsStaticInst
52    {
53      public:
54        /// Constructor
55        FailUnimplemented(const char *_mnemonic, MachInst _machInst)
56            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
57        {
58            // don't call execute() (which panics) if we're on a
59            // speculative path
60            flags[IsNonSpeculative] = true;
61        }
62
63        %(BasicExecDeclare)s
64
65        std::string
66        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
67    };
68    class CP0Unimplemented : public MipsStaticInst
69    {
70      public:
71        /// Constructor
72        CP0Unimplemented(const char *_mnemonic, MachInst _machInst)
73            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
74        {
75            // don't call execute() (which panics) if we're on a
76            // speculative path
77            flags[IsNonSpeculative] = true;
78        }
79
80        %(BasicExecDeclare)s
81
82        std::string
83        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
84    };
85    class CP1Unimplemented : public MipsStaticInst
86    {
87      public:
88        /// Constructor
89        CP1Unimplemented(const char *_mnemonic, MachInst _machInst)
90            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
91        {
92            // don't call execute() (which panics) if we're on a
93            // speculative path
94            flags[IsNonSpeculative] = true;
95        }
96
97        %(BasicExecDeclare)s
98
99        std::string
100        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
101    };
102    class CP2Unimplemented : public MipsStaticInst
103    {
104      public:
105        /// Constructor
106        CP2Unimplemented(const char *_mnemonic, MachInst _machInst)
107            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
108        {
109            // don't call execute() (which panics) if we're on a
110            // speculative path
111            flags[IsNonSpeculative] = true;
112        }
113
114        %(BasicExecDeclare)s
115
116        std::string
117        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
118    };
119
120    /**
121     * Base class for unimplemented instructions that cause a warning
122     * to be printed (but do not terminate simulation).  This
123     * implementation is a little screwy in that it will print a
124     * warning for each instance of a particular unimplemented machine
125     * instruction, not just for each unimplemented opcode.  Should
126     * probably make the 'warned' flag a static member of the derived
127     * class.
128     */
129    class WarnUnimplemented : public MipsStaticInst
130    {
131      private:
132        /// Have we warned on this instruction yet?
133        mutable bool warned;
134
135      public:
136        /// Constructor
137        WarnUnimplemented(const char *_mnemonic, MachInst _machInst)
138            : MipsStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
139        {
140            // don't call execute() (which panics) if we're on a
141            // speculative path
142            flags[IsNonSpeculative] = true;
143        }
144
145        %(BasicExecDeclare)s
146
147        std::string
148        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
149    };
150}};
151
152output decoder {{
153    std::string
154    FailUnimplemented::generateDisassembly(Addr pc,
155                                           const SymbolTable *symtab) const
156    {
157        return csprintf("%-10s (unimplemented)", mnemonic);
158    }
159
160    std::string
161    CP0Unimplemented::generateDisassembly(Addr pc,
162                                           const SymbolTable *symtab) const
163    {
164        return csprintf("%-10s (unimplemented)", mnemonic);
165    }
166
167    std::string
168    CP1Unimplemented::generateDisassembly(Addr pc,
169                                           const SymbolTable *symtab) const
170    {
171        return csprintf("%-10s (unimplemented)", mnemonic);
172    }
173    std::string
174    CP2Unimplemented::generateDisassembly(Addr pc,
175                                           const SymbolTable *symtab) const
176    {
177        return csprintf("%-10s (unimplemented)", mnemonic);
178    }
179
180    std::string
181    WarnUnimplemented::generateDisassembly(Addr pc,
182                                           const SymbolTable *symtab) const
183    {
184        return csprintf("%-10s (unimplemented)", mnemonic);
185    }
186}};
187
188output exec {{
189    Fault
190    FailUnimplemented::execute(%(CPU_exec_context)s *xc,
191                               Trace::InstRecord *traceData) const
192    {
193        panic("attempt to execute unimplemented instruction '%s' "
194              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
195              inst2string(machInst));
196        return new UnimplementedOpcodeFault;
197    }
198
199    Fault
200    CP0Unimplemented::execute(%(CPU_exec_context)s *xc,
201                               Trace::InstRecord *traceData) const
202    {
203#if  FULL_SYSTEM
204      if (!isCoprocessorEnabled(xc, 0)) {
205        return new CoprocessorUnusableFault(0);
206      }
207      return new ReservedInstructionFault;
208#else
209        panic("attempt to execute unimplemented instruction '%s' "
210              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
211              inst2string(machInst));
212        return new UnimplementedOpcodeFault;
213#endif
214    }
215
216    Fault
217    CP1Unimplemented::execute(%(CPU_exec_context)s *xc,
218                               Trace::InstRecord *traceData) const
219    {
220#if  FULL_SYSTEM
221      if (!isCoprocessorEnabled(xc, 1)) {
222        return new CoprocessorUnusableFault(1);
223      }
224      return new ReservedInstructionFault;
225#else
226        panic("attempt to execute unimplemented instruction '%s' "
227              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
228              inst2string(machInst));
229        return new UnimplementedOpcodeFault;
230#endif
231    }
232    Fault
233    CP2Unimplemented::execute(%(CPU_exec_context)s *xc,
234                               Trace::InstRecord *traceData) const
235    {
236#if  FULL_SYSTEM
237      if (!isCoprocessorEnabled(xc, 2)) {
238        return new CoprocessorUnusableFault(2);
239      }
240      return new ReservedInstructionFault;
241#else
242        panic("attempt to execute unimplemented instruction '%s' "
243              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
244              inst2string(machInst));
245        return new UnimplementedOpcodeFault;
246#endif
247    }
248
249    Fault
250    WarnUnimplemented::execute(%(CPU_exec_context)s *xc,
251                               Trace::InstRecord *traceData) const
252    {
253        if (!warned) {
254            warn("\tinstruction '%s' unimplemented\n", mnemonic);
255            warned = true;
256        }
257
258        return NoFault;
259    }
260}};
261
262
263def format FailUnimpl() {{
264    iop = InstObjParams(name, 'FailUnimplemented')
265    decode_block = BasicDecodeWithMnemonic.subst(iop)
266
267}};
268def format CP0Unimpl() {{
269    iop = InstObjParams(name, 'CP0Unimplemented')
270    decode_block = BasicDecodeWithMnemonic.subst(iop)
271}};
272def format CP1Unimpl() {{
273    iop = InstObjParams(name, 'CP1Unimplemented')
274    decode_block = BasicDecodeWithMnemonic.subst(iop)
275}};
276def format CP2Unimpl() {{
277    iop = InstObjParams(name, 'CP2Unimplemented')
278    decode_block = BasicDecodeWithMnemonic.subst(iop)
279}};
280def format WarnUnimpl() {{
281    iop = InstObjParams(name, 'WarnUnimplemented')
282    decode_block = BasicDecodeWithMnemonic.subst(iop)
283}};
284
285