trap.isa revision 5222
12686Sksewell@umich.edu// -*- mode:c++ -*- 22686Sksewell@umich.edu 35222Sksewell@umich.edu// Copyright .AN) 2007 MIPS Technologies, Inc. All Rights Reserved 45222Sksewell@umich.edu 55222Sksewell@umich.edu// This software is part of the M5 simulator. 65222Sksewell@umich.edu 75222Sksewell@umich.edu// THIS IS A LEGAL AGREEMENT. BY DOWNLOADING, USING, COPYING, CREATING 85222Sksewell@umich.edu// DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING 95222Sksewell@umich.edu// TO THESE TERMS AND CONDITIONS. 105222Sksewell@umich.edu 115222Sksewell@umich.edu// Permission is granted to use, copy, create derivative works and 125222Sksewell@umich.edu// distribute this software and such derivative works for any purpose, 135222Sksewell@umich.edu// so long as (1) the copyright notice above, this grant of permission, 145222Sksewell@umich.edu// and the disclaimer below appear in all copies and derivative works 155222Sksewell@umich.edu// made, (2) the copyright notice above is augmented as appropriate to 165222Sksewell@umich.edu// reflect the addition of any new copyrightable work in a derivative 175222Sksewell@umich.edu// work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3) 185222Sksewell@umich.edu// the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any 195222Sksewell@umich.edu// advertising or publicity pertaining to the use or distribution of 205222Sksewell@umich.edu// this software without specific, written prior authorization. 215222Sksewell@umich.edu 225222Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B MIPS MAKES NO WARRANTIES AND 235222Sksewell@umich.edu// DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR 245222Sksewell@umich.edu// OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 255222Sksewell@umich.edu// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 265222Sksewell@umich.edu// NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE. 275222Sksewell@umich.edu// IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, 285222Sksewell@umich.edu// INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF 295222Sksewell@umich.edu// ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT, 305222Sksewell@umich.edu// THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY 315222Sksewell@umich.edu// IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR 325222Sksewell@umich.edu// STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE 335222Sksewell@umich.edu// POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE. 345222Sksewell@umich.edu 355222Sksewell@umich.edu//Authors: Korey L. Sewell 365222Sksewell@umich.edu// Jaidev Patwardhan 372706Sksewell@umich.edu 382022SN/A//////////////////////////////////////////////////////////////////// 392022SN/A// 402022SN/A// Trap instructions 412022SN/A// 422022SN/A 432022SN/Aoutput header {{ 442022SN/A /** 452022SN/A * Base class for integer operations. 462022SN/A */ 472028SN/A class Trap : public MipsStaticInst 482022SN/A { 492022SN/A protected: 502022SN/A 512022SN/A /// Constructor 522028SN/A Trap(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass) 532022SN/A { 542022SN/A } 552022SN/A 562022SN/A std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 572022SN/A }; 585222Sksewell@umich.edu class TrapImm : public MipsStaticInst 595222Sksewell@umich.edu { 605222Sksewell@umich.edu protected: 615222Sksewell@umich.edu 625222Sksewell@umich.edu int16_t imm; 635222Sksewell@umich.edu 645222Sksewell@umich.edu /// Constructor 655222Sksewell@umich.edu TrapImm(const char *mnem, MachInst _machInst, OpClass __opClass) : 665222Sksewell@umich.edu MipsStaticInst(mnem, _machInst, __opClass),imm(INTIMM) 675222Sksewell@umich.edu { 685222Sksewell@umich.edu } 695222Sksewell@umich.edu 705222Sksewell@umich.edu std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 715222Sksewell@umich.edu 725222Sksewell@umich.edu 735222Sksewell@umich.edu }; 745222Sksewell@umich.edu 752022SN/A}}; 762022SN/A 772022SN/Aoutput decoder {{ 782022SN/A std::string Trap::generateDisassembly(Addr pc, const SymbolTable *symtab) const 792022SN/A { 802686Sksewell@umich.edu return "Disassembly of trap instruction\n"; 812022SN/A } 825222Sksewell@umich.edu std::string TrapImm::generateDisassembly(Addr pc, const SymbolTable *symtab) const 835222Sksewell@umich.edu { 845222Sksewell@umich.edu return "Disassembly of trap instruction\n"; 855222Sksewell@umich.edu } 862022SN/A}}; 872022SN/A 882022SN/Adef template TrapExecute {{ 892686Sksewell@umich.edu //Edit This Template When Traps Are Implemented 902022SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 912022SN/A { 922022SN/A //Write the resulting state to the execution context 932022SN/A %(op_wb)s; 942022SN/A 952686Sksewell@umich.edu //Call into the trap handler with the appropriate fault 962022SN/A return No_Fault; 972022SN/A } 982022SN/A}}; 995222Sksewell@umich.edudef format Trap(code, *flags) {{ 1002022SN/A 1015222Sksewell@umich.edu code ='bool cond;\n' + code 1025222Sksewell@umich.edu code += 'if (cond) {\n' 1035222Sksewell@umich.edu code += 'fault = new TrapFault();\n};' 1045222Sksewell@umich.edu 1053951Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags) 1062022SN/A header_output = BasicDeclare.subst(iop) 1072022SN/A decoder_output = BasicConstructor.subst(iop) 1082239SN/A decode_block = BasicDecode.subst(iop) 1092239SN/A exec_output = BasicExecute.subst(iop) 1102022SN/A}}; 1115222Sksewell@umich.edudef format TrapImm(code, *flags) {{ 1125222Sksewell@umich.edu 1135222Sksewell@umich.edu code ='bool cond;\n' + code 1145222Sksewell@umich.edu code += 'if (cond) {\n' 1155222Sksewell@umich.edu code += 'fault = new TrapFault();\n};' 1165222Sksewell@umich.edu iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags) 1175222Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1185222Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1195222Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1205222Sksewell@umich.edu exec_output = BasicExecute.subst(iop) 1215222Sksewell@umich.edu}}; 122