priv.isa revision 2526
1//////////////////////////////////////////////////////////////////// 2// 3// Privilege mode instructions 4// 5 6output header {{ 7 /** 8 * Base class for privelege mode operations. 9 */ 10 class Priv : public SparcStaticInst 11 { 12 protected: 13 // Constructor 14 Priv(const char *mnem, ExtMachInst _machInst, OpClass __opClass) : 15 SparcStaticInst(mnem, _machInst, __opClass) 16 { 17 } 18 19 std::string generateDisassembly(Addr pc, 20 const SymbolTable *symtab) const; 21 }; 22 23 /** 24 * Base class for user mode "tick" access. 25 */ 26 class PrivTick : public SparcStaticInst 27 { 28 protected: 29 // Constructor 30 PrivTick(const char *mnem, ExtMachInst _machInst, 31 OpClass __opClass) : 32 SparcStaticInst(mnem, _machInst, __opClass) 33 { 34 } 35 36 std::string generateDisassembly(Addr pc, 37 const SymbolTable *symtab) const; 38 }; 39 40 /** 41 * Base class for privelege mode operations with immediates. 42 */ 43 class PrivImm : public Priv 44 { 45 protected: 46 // Constructor 47 PrivImm(const char *mnem, ExtMachInst _machInst, 48 OpClass __opClass) : 49 Priv(mnem, _machInst, __opClass), imm(SIMM13) 50 { 51 } 52 53 int32_t imm; 54 }; 55 56 /** 57 * Base class for user mode "tick" access with immediates. 58 */ 59 class PrivTickImm : public PrivTick 60 { 61 protected: 62 // Constructor 63 PrivTickImm(const char *mnem, ExtMachInst _machInst, 64 OpClass __opClass) : 65 PrivTick(mnem, _machInst, __opClass), imm(SIMM13) 66 { 67 } 68 69 int32_t imm; 70 }; 71}}; 72 73output decoder {{ 74 std::string Priv::generateDisassembly(Addr pc, 75 const SymbolTable *symtab) const 76 { 77 return "Privileged Instruction"; 78 } 79 80 std::string PrivTick::generateDisassembly(Addr pc, 81 const SymbolTable *symtab) const 82 { 83 return "Regular access to Tick"; 84 } 85}}; 86 87def template PrivExecute {{ 88 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 89 Trace::InstRecord *traceData) const 90 { 91 %(op_decl)s; 92 %(op_rd)s; 93 94 //If the processor isn't in privileged mode, fault out right away 95 if(%(check)s) 96 return new PrivilegedAction; 97 98 %(code)s; 99 %(op_wb)s; 100 return NoFault; 101 } 102}}; 103 104let {{ 105 def doPrivFormat(code, checkCode, name, Name, opt_flags): 106 (usesImm, code, immCode, 107 rString, iString) = splitOutImm(code) 108 iop = InstObjParams(name, Name, 'Priv', code, 109 opt_flags, ("check", checkCode)) 110 header_output = BasicDeclare.subst(iop) 111 decoder_output = BasicConstructor.subst(iop) 112 exec_output = PrivExecute.subst(iop) 113 if usesImm: 114 imm_iop = InstObjParams(name, Name + 'Imm', 'PrivImm', 115 immCode, opt_flags, ("check", checkCode)) 116 header_output += BasicDeclare.subst(imm_iop) 117 decoder_output += BasicConstructor.subst(imm_iop) 118 exec_output += PrivExecute.subst(imm_iop) 119 decode_block = ROrImmDecode.subst(iop) 120 else: 121 decode_block = BasicDecode.subst(iop) 122 return (header_output, decoder_output, exec_output, decode_block) 123}}; 124 125// Primary format for integer operate instructions: 126def format Priv(code, *opt_flags) {{ 127 checkCode = "(!PstatePriv)" 128 (header_output, decoder_output, 129 exec_output, decode_block) = doPrivFormat(code, 130 checkCode, name, Name, opt_flags) 131}}; 132 133// Primary format for integer operate instructions: 134def format PrivTick(code, *opt_flags) {{ 135 checkCode = "(!PstatePriv && TickNpt)" 136 (header_output, decoder_output, 137 exec_output, decode_block) = doPrivFormat(code, 138 checkCode, name, Name, opt_flags) 139}}; 140