interrupts.hh revision 5568
1/* 2 * Copyright (c) 2007 MIPS Technologies, Inc. 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 * Authors: Rick Strong 29 */ 30 31#ifndef __ARCH_MIPS_INTERRUPT_HH__ 32#define __ARCH_MIPS_INTERRUPT_HH__ 33 34 35#include "arch/mips/faults.hh" 36#include "base/compiler.hh" 37 38 39 40namespace MipsISA 41{ 42class Interrupts 43{ 44 /* 45 protected: 46 uint8_t intstatus; 47 bool oncputimerintr; 48 public: 49 Interrupts() 50 { 51 intstatus = 0; 52 newInfoSet = false; 53 oncputimerintr = false; 54 55 } 56 // post(int int_num, int index) is responsible 57 // for posting an interrupt. It sets a bit 58 // in intstatus corresponding to Cause IP*. The 59 // MIPS register Cause is updated by updateIntrInfo 60 // which is called by check_interrupts 61 // 62 void post(int int_num, int index); 63 // clear(int int_num, int index) is responsible 64 // for clearing an interrupt. It clear a bit 65 // in intstatus corresponding to Cause IP*. The 66 // MIPS register Cause is updated by updateIntrInfo 67 // which is called by check_interrupts 68 // 69 void clear(int int_num, int index); 70 // clear_all() is responsible 71 // for clearing all interrupts. It clears all bits 72 // in intstatus corresponding to Cause IP*. The 73 // MIPS register Cause is updated by updateIntrInfo 74 // which is called by check_interrupts 75 // 76 void clear_all(); 77 78 // getInterrupt(ThreadContext * tc) checks if an interrupt 79 // should be returned. It ands the interrupt mask and 80 // and interrupt pending bits to see if one exists. It 81 // also makes sure interrupts are enabled (IE) and 82 // that ERL and ERX are not set 83 // 84 Fault getInterrupt(ThreadContext * tc); 85 86 // updateIntrInfo(ThreadContext *tc) const syncs the 87 // MIPS cause register with the instatus variable. instatus 88 // is essentially a copy of the MIPS cause[IP7:IP0] 89 // 90 void updateIntrInfo(ThreadContext *tc) const; 91 void updateIntrInfoCpuTimerIntr(ThreadContext *tc) const; 92 bool onCpuTimerInterrupt(ThreadContext *tc) const; 93 94 uint64_t get_vec(int int_num); 95 96 bool check_interrupts(ThreadContext * tc) const{ 97 //return (intstatus != 0) && !(tc->readPC() & 0x3); 98 if (oncputimerintr == false){ 99 updateIntrInfo(tc); 100 return ((intstatus != 0) || onCpuTimerInterrupt(tc)); 101 } 102 else 103 return true; 104 105 } 106 */ 107 108 109 protected: 110 //uint8_t intstatus; 111 //bool oncputimerintr; 112 public: 113 Interrupts() 114 { 115 //intstatus = 0; 116 newInfoSet = false; 117 //oncputimerintr = false; 118 119 } 120 // post(int int_num, int index) is responsible 121 // for posting an interrupt. It sets a bit 122 // in intstatus corresponding to Cause IP*. The 123 // MIPS register Cause is updated by updateIntrInfo 124 // which is called by check_interrupts 125 // 126 void post(int int_num, ThreadContext* tc); 127 void post(int int_num, int index); 128 129 // clear(int int_num, int index) is responsible 130 // for clearing an interrupt. It clear a bit 131 // in intstatus corresponding to Cause IP*. The 132 // MIPS register Cause is updated by updateIntrInfo 133 // which is called by check_interrupts 134 // 135 void clear(int int_num, ThreadContext* tc); 136 void clear(int int_num, int index); 137 138 // clear_all() is responsible 139 // for clearing all interrupts. It clears all bits 140 // in intstatus corresponding to Cause IP*. The 141 // MIPS register Cause is updated by updateIntrInfo 142 // which is called by check_interrupts 143 // 144 void clear_all(ThreadContext* tc); 145 void clear_all(); 146 147 // getInterrupt(ThreadContext * tc) checks if an interrupt 148 // should be returned. It ands the interrupt mask and 149 // and interrupt pending bits to see if one exists. It 150 // also makes sure interrupts are enabled (IE) and 151 // that ERL and ERX are not set 152 // 153 Fault getInterrupt(ThreadContext * tc); 154 155 // updateIntrInfo(ThreadContext *tc) const syncs the 156 // MIPS cause register with the instatus variable. instatus 157 // is essentially a copy of the MIPS cause[IP7:IP0] 158 // 159 void updateIntrInfo(ThreadContext *tc) const; 160 bool interruptsPending(ThreadContext *tc) const; 161 bool onCpuTimerInterrupt(ThreadContext *tc) const; 162 163 uint64_t get_vec(int int_num); 164 165 bool check_interrupts(ThreadContext * tc) const{ 166 return interruptsPending(tc); 167 } 168 169 170 void serialize(std::ostream &os) 171 { 172 fatal("Serialization of Interrupts Unimplemented for MIPS"); 173 //SERIALIZE_ARRAY(interrupts, NumInterruptLevels); 174 //SERIALIZE_SCALAR(intstatus); 175 } 176 177 void unserialize(Checkpoint *cp, const std::string §ion) 178 { 179 fatal("Unserialization of Interrupts Unimplemented for MIPS"); 180 //UNSERIALIZE_ARRAY(interrupts, NumInterruptLevels); 181 //UNSERIALIZE_SCALAR(intstatus); 182 } 183 184 185 186 private: 187 bool newInfoSet; 188 int newIpl; 189 int newSummary; 190 191}; 192 193} 194 195#endif 196 197