pseudo_inst.cc revision 711
1/* 2 * Copyright (c) 2003 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <string> 30 31#include "arch/alpha/pseudo_inst.hh" 32#include "cpu/exec_context.hh" 33#include "sim/param.hh" 34#include "sim/serialize.hh" 35#include "sim/sim_exit.hh" 36#include "sim/stat_control.hh" 37#include "sim/stats.hh" 38 39using namespace std; 40using namespace Statistics; 41 42namespace AlphaPseudo 43{ 44 bool doStatisticsInsts; 45 bool doCheckpointInsts; 46 bool doQuiesce; 47 48 void 49 arm(ExecContext *xc) 50 { 51 xc->kernelStats.arm(); 52 } 53 54 void 55 quiesce(ExecContext *xc) 56 { 57 if (!doQuiesce) 58 return; 59 60 xc->suspend(); 61 xc->kernelStats.quiesce(); 62 } 63 64 void 65 ivlb(ExecContext *xc) 66 { 67 xc->kernelStats.ivlb(); 68 } 69 70 void 71 ivle(ExecContext *xc) 72 { 73 } 74 75 void 76 m5exit_old(ExecContext *xc) 77 { 78 SimExit(curTick, "m5_exit_old instruction encountered"); 79 } 80 81 void 82 m5exit(ExecContext *xc) 83 { 84 Tick delay = xc->regs.intRegFile[16]; 85 Tick when = curTick + NS2Ticks(delay); 86 SimExit(when, "m5_exit instruction encountered"); 87 } 88 89 void 90 resetstats(ExecContext *xc) 91 { 92 if (!doStatisticsInsts) 93 return; 94 95 Tick delay = xc->regs.intRegFile[16]; 96 Tick period = xc->regs.intRegFile[17]; 97 98 Tick when = curTick + NS2Ticks(delay); 99 Tick repeat = NS2Ticks(period); 100 101 using namespace Statistics; 102 SetupEvent(Reset, when, repeat); 103 } 104 105 void 106 dumpstats(ExecContext *xc) 107 { 108 if (!doStatisticsInsts) 109 return; 110 111 Tick delay = xc->regs.intRegFile[16]; 112 Tick period = xc->regs.intRegFile[17]; 113 114 Tick when = curTick + NS2Ticks(delay); 115 Tick repeat = NS2Ticks(period); 116 117 using namespace Statistics; 118 SetupEvent(Dump, when, repeat); 119 } 120 121 void 122 dumpresetstats(ExecContext *xc) 123 { 124 if (!doStatisticsInsts) 125 return; 126 127 Tick delay = xc->regs.intRegFile[16]; 128 Tick period = xc->regs.intRegFile[17]; 129 130 Tick when = curTick + NS2Ticks(delay); 131 Tick repeat = NS2Ticks(period); 132 133 using namespace Statistics; 134 SetupEvent(Dump|Reset, when, repeat); 135 } 136 137 void 138 m5checkpoint(ExecContext *xc) 139 { 140 if (!doCheckpointInsts) 141 return; 142 143 Tick delay = xc->regs.intRegFile[16]; 144 Tick period = xc->regs.intRegFile[17]; 145 146 Tick when = curTick + NS2Ticks(delay); 147 Tick repeat = NS2Ticks(period); 148 149 Checkpoint::setup(when, repeat); 150 } 151 152 class Context : public ParamContext 153 { 154 public: 155 Context(const string §ion) : ParamContext(section) {} 156 void checkParams(); 157 }; 158 159 Context context("PseudoInsts"); 160 161 Param<bool> __quiesce(&context, "quiesce", 162 "enable quiesce instructions", 163 true); 164 Param<bool> __statistics(&context, "statistics", 165 "enable statistics pseudo instructions", 166 true); 167 Param<bool> __checkpoint(&context, "checkpoint", 168 "enable checkpoint pseudo instructions", 169 true); 170 171 void 172 Context::checkParams() 173 { 174 doQuiesce = __quiesce; 175 doStatisticsInsts = __statistics; 176 doCheckpointInsts = __checkpoint; 177 } 178} 179