control.isa revision 4661
12686Sksewell@umich.edu// -*- mode:c++ -*- 22686Sksewell@umich.edu 32754Sksewell@umich.edu// Copyright (c) 2006 The Regents of The University of Michigan 42706Sksewell@umich.edu// All rights reserved. 52706Sksewell@umich.edu// 62706Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 72706Sksewell@umich.edu// modification, are permitted provided that the following conditions are 82706Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 92706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer; 102706Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 112706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 122706Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 132706Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 142706Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 152706Sksewell@umich.edu// this software without specific prior written permission. 162706Sksewell@umich.edu// 172706Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182706Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192706Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202706Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212706Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222706Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232706Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242706Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252706Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262706Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272706Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282706Sksewell@umich.edu// 292706Sksewell@umich.edu// Authors: Korey Sewell 302706Sksewell@umich.edu 312686Sksewell@umich.edu//////////////////////////////////////////////////////////////////// 322686Sksewell@umich.edu// 334661Sksewell@umich.edu// Coprocessor instructions 342686Sksewell@umich.edu// 352686Sksewell@umich.edu 362686Sksewell@umich.edu//Outputs to decoder.hh 372686Sksewell@umich.eduoutput header {{ 382686Sksewell@umich.edu 394661Sksewell@umich.edu class CP0Control : public MipsStaticInst 402686Sksewell@umich.edu { 412686Sksewell@umich.edu protected: 422686Sksewell@umich.edu 432686Sksewell@umich.edu /// Constructor 444661Sksewell@umich.edu CP0Control(const char *mnem, MachInst _machInst, OpClass __opClass) : 452686Sksewell@umich.edu MipsStaticInst(mnem, _machInst, __opClass) 462686Sksewell@umich.edu { 472686Sksewell@umich.edu } 482686Sksewell@umich.edu 492686Sksewell@umich.edu std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 502686Sksewell@umich.edu }; 512686Sksewell@umich.edu 524661Sksewell@umich.edu class CP1Control : public MipsStaticInst 532686Sksewell@umich.edu { 542686Sksewell@umich.edu protected: 552686Sksewell@umich.edu 562686Sksewell@umich.edu /// Constructor 572686Sksewell@umich.edu CP1Control(const char *mnem, MachInst _machInst, OpClass __opClass) : 584661Sksewell@umich.edu MipsStaticInst(mnem, _machInst, __opClass) 592686Sksewell@umich.edu { 602686Sksewell@umich.edu } 612686Sksewell@umich.edu 622686Sksewell@umich.edu std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 632686Sksewell@umich.edu }; 642686Sksewell@umich.edu 652686Sksewell@umich.edu}}; 662686Sksewell@umich.edu 674661Sksewell@umich.edu// Basic instruction class execute method template. 684661Sksewell@umich.edudef template ControlExecute {{ 694661Sksewell@umich.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 704661Sksewell@umich.edu { 714661Sksewell@umich.edu Fault fault = NoFault; 724661Sksewell@umich.edu %(op_decl)s; 734661Sksewell@umich.edu %(op_rd)s; 744661Sksewell@umich.edu 754661Sksewell@umich.edu if (isCoprocessorEnabled(xc, 0)) { 764661Sksewell@umich.edu %(code)s; 774661Sksewell@umich.edu } else { 784661Sksewell@umich.edu fault = new CoprocessorUnusableFault(); 794661Sksewell@umich.edu } 804661Sksewell@umich.edu 814661Sksewell@umich.edu if(fault == NoFault) 824661Sksewell@umich.edu { 834661Sksewell@umich.edu %(op_wb)s; 844661Sksewell@umich.edu } 854661Sksewell@umich.edu return fault; 864661Sksewell@umich.edu } 874661Sksewell@umich.edu}}; 884661Sksewell@umich.edu 892686Sksewell@umich.edu//Outputs to decoder.cc 902686Sksewell@umich.eduoutput decoder {{ 912686Sksewell@umich.edu std::string CP0Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const 922686Sksewell@umich.edu { 932686Sksewell@umich.edu std::stringstream ss; 944661Sksewell@umich.edu ccprintf(ss, "%-10s r%d, %d, %d", mnemonic, RT, RD, SEL); 952686Sksewell@umich.edu return ss.str(); 962686Sksewell@umich.edu } 972686Sksewell@umich.edu 982686Sksewell@umich.edu std::string CP1Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const 992686Sksewell@umich.edu { 1002686Sksewell@umich.edu std::stringstream ss; 1012686Sksewell@umich.edu ccprintf(ss, "%-10s r%d, f%d", mnemonic, RT, FS); 1022686Sksewell@umich.edu return ss.str(); 1032686Sksewell@umich.edu } 1042686Sksewell@umich.edu 1052686Sksewell@umich.edu}}; 1062686Sksewell@umich.edu 1074661Sksewell@umich.eduoutput exec {{ 1084661Sksewell@umich.edu bool isCoprocessorEnabled(%(CPU_exec_context)s *xc, unsigned cop_num) 1094661Sksewell@umich.edu { 1104661Sksewell@umich.edu switch(cop_num) 1114661Sksewell@umich.edu { 1124661Sksewell@umich.edu case 0: 1134661Sksewell@umich.edu#if FULL_SYSTEM 1144661Sksewell@umich.edu if((xc->readMiscReg(MipsISA::Status) & 0x10000006) == 0 && (xc->readMiscReg(MipsISA::Debug) & 0x40000000 ) == 0) { 1154661Sksewell@umich.edu // Unable to use Status_CU0, etc directly, using bitfields & masks 1164661Sksewell@umich.edu return false; 1174661Sksewell@umich.edu } 1184661Sksewell@umich.edu#else 1194661Sksewell@umich.edu //printf("Syscall Emulation Mode: CP0 Enable Check defaults to TRUE\n"); 1204661Sksewell@umich.edu#endif 1214661Sksewell@umich.edu break; 1224661Sksewell@umich.edu case 1: 1234661Sksewell@umich.edu break; 1244661Sksewell@umich.edu case 2: 1254661Sksewell@umich.edu break; 1264661Sksewell@umich.edu case 3: 1274661Sksewell@umich.edu break; 1284661Sksewell@umich.edu default: panic("Invalid Coprocessor Number Specified"); 1294661Sksewell@umich.edu break; 1304661Sksewell@umich.edu } 1314661Sksewell@umich.edu return true; 1324661Sksewell@umich.edu } 1332686Sksewell@umich.edu}}; 1342686Sksewell@umich.edu 1352686Sksewell@umich.edudef format CP0Control(code, *flags) {{ 1364661Sksewell@umich.edu flags += ('IsNonSpeculative', ) 1374661Sksewell@umich.edu iop = InstObjParams(name, Name, 'CP0Control', code, flags) 1384661Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1394661Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1404661Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1414661Sksewell@umich.edu exec_output = ControlExecute.subst(iop) 1422686Sksewell@umich.edu}}; 1432686Sksewell@umich.edu 1442686Sksewell@umich.edudef format CP1Control(code, *flags) {{ 1454661Sksewell@umich.edu flags += ('IsNonSpeculative', ) 1464661Sksewell@umich.edu iop = InstObjParams(name, Name, 'CP1Control', code, flags) 1474661Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1484661Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1494661Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1504661Sksewell@umich.edu exec_output = ControlExecute.subst(iop) 1512686Sksewell@umich.edu}}; 1522686Sksewell@umich.edu 1532686Sksewell@umich.edu 154