interrupts.hh revision 5810
15222Sksewell@umich.edu/* 25254Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc. 35254Sksewell@umich.edu * All rights reserved. 45222Sksewell@umich.edu * 55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 145254Sksewell@umich.edu * this software without specific prior written permission. 155222Sksewell@umich.edu * 165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275222Sksewell@umich.edu * 285254Sksewell@umich.edu * Authors: Rick Strong 295222Sksewell@umich.edu */ 305222Sksewell@umich.edu 315222Sksewell@umich.edu#ifndef __ARCH_MIPS_INTERRUPT_HH__ 325222Sksewell@umich.edu#define __ARCH_MIPS_INTERRUPT_HH__ 335222Sksewell@umich.edu 345222Sksewell@umich.edu 355222Sksewell@umich.edu#include "arch/mips/faults.hh" 365222Sksewell@umich.edu#include "base/compiler.hh" 375222Sksewell@umich.edu 385222Sksewell@umich.edu 395222Sksewell@umich.edu 405222Sksewell@umich.edunamespace MipsISA 415222Sksewell@umich.edu{ 425222Sksewell@umich.educlass Interrupts 435222Sksewell@umich.edu{ 445222Sksewell@umich.edu /* 455222Sksewell@umich.edu protected: 465222Sksewell@umich.edu uint8_t intstatus; 475222Sksewell@umich.edu bool oncputimerintr; 485222Sksewell@umich.edu public: 495222Sksewell@umich.edu Interrupts() 505222Sksewell@umich.edu { 515222Sksewell@umich.edu intstatus = 0; 525222Sksewell@umich.edu newInfoSet = false; 535222Sksewell@umich.edu oncputimerintr = false; 545222Sksewell@umich.edu 555222Sksewell@umich.edu } 565222Sksewell@umich.edu // post(int int_num, int index) is responsible 575222Sksewell@umich.edu // for posting an interrupt. It sets a bit 585222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 595222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 605704Snate@binkert.org // which is called by checkInterrupts 615222Sksewell@umich.edu // 625222Sksewell@umich.edu void post(int int_num, int index); 635222Sksewell@umich.edu // clear(int int_num, int index) is responsible 645222Sksewell@umich.edu // for clearing an interrupt. It clear a bit 655222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 665222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 675704Snate@binkert.org // which is called by checkInterrupts 685222Sksewell@umich.edu // 695222Sksewell@umich.edu void clear(int int_num, int index); 705704Snate@binkert.org // clearAll() is responsible 715222Sksewell@umich.edu // for clearing all interrupts. It clears all bits 725222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 735222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 745704Snate@binkert.org // which is called by checkInterrupts 755222Sksewell@umich.edu // 765704Snate@binkert.org void clearAll(); 775222Sksewell@umich.edu 785222Sksewell@umich.edu // getInterrupt(ThreadContext * tc) checks if an interrupt 795222Sksewell@umich.edu // should be returned. It ands the interrupt mask and 805222Sksewell@umich.edu // and interrupt pending bits to see if one exists. It 815222Sksewell@umich.edu // also makes sure interrupts are enabled (IE) and 825222Sksewell@umich.edu // that ERL and ERX are not set 835222Sksewell@umich.edu // 845222Sksewell@umich.edu Fault getInterrupt(ThreadContext * tc); 855222Sksewell@umich.edu 865222Sksewell@umich.edu // updateIntrInfo(ThreadContext *tc) const syncs the 875222Sksewell@umich.edu // MIPS cause register with the instatus variable. instatus 885222Sksewell@umich.edu // is essentially a copy of the MIPS cause[IP7:IP0] 895222Sksewell@umich.edu // 905222Sksewell@umich.edu void updateIntrInfo(ThreadContext *tc) const; 915222Sksewell@umich.edu void updateIntrInfoCpuTimerIntr(ThreadContext *tc) const; 925222Sksewell@umich.edu bool onCpuTimerInterrupt(ThreadContext *tc) const; 935222Sksewell@umich.edu 945704Snate@binkert.org bool checkInterrupts(ThreadContext *tc) const { 955222Sksewell@umich.edu //return (intstatus != 0) && !(tc->readPC() & 0x3); 965222Sksewell@umich.edu if (oncputimerintr == false){ 975222Sksewell@umich.edu updateIntrInfo(tc); 985222Sksewell@umich.edu return ((intstatus != 0) || onCpuTimerInterrupt(tc)); 995222Sksewell@umich.edu } 1005222Sksewell@umich.edu else 1015222Sksewell@umich.edu return true; 1025222Sksewell@umich.edu 1035222Sksewell@umich.edu } 1045222Sksewell@umich.edu */ 1055222Sksewell@umich.edu 1065222Sksewell@umich.edu 1075222Sksewell@umich.edu protected: 1085222Sksewell@umich.edu //uint8_t intstatus; 1095222Sksewell@umich.edu //bool oncputimerintr; 1105222Sksewell@umich.edu public: 1115222Sksewell@umich.edu Interrupts() 1125222Sksewell@umich.edu { 1135222Sksewell@umich.edu //intstatus = 0; 1145222Sksewell@umich.edu newInfoSet = false; 1155222Sksewell@umich.edu //oncputimerintr = false; 1165222Sksewell@umich.edu 1175222Sksewell@umich.edu } 1185222Sksewell@umich.edu // post(int int_num, int index) is responsible 1195222Sksewell@umich.edu // for posting an interrupt. It sets a bit 1205222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 1215222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 1225704Snate@binkert.org // which is called by checkInterrupts 1235222Sksewell@umich.edu // 1245222Sksewell@umich.edu void post(int int_num, ThreadContext* tc); 1255222Sksewell@umich.edu void post(int int_num, int index); 1265222Sksewell@umich.edu 1275222Sksewell@umich.edu // clear(int int_num, int index) is responsible 1285222Sksewell@umich.edu // for clearing an interrupt. It clear a bit 1295222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 1305222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 1315704Snate@binkert.org // which is called by checkInterrupts 1325222Sksewell@umich.edu // 1335222Sksewell@umich.edu void clear(int int_num, ThreadContext* tc); 1345222Sksewell@umich.edu void clear(int int_num, int index); 1355222Sksewell@umich.edu 1365704Snate@binkert.org // clearAll() is responsible 1375222Sksewell@umich.edu // for clearing all interrupts. It clears all bits 1385222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 1395222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 1405704Snate@binkert.org // which is called by checkInterrupts 1415222Sksewell@umich.edu // 1425704Snate@binkert.org void clearAll(ThreadContext* tc); 1435704Snate@binkert.org void clearAll(); 1445222Sksewell@umich.edu 1455222Sksewell@umich.edu // getInterrupt(ThreadContext * tc) checks if an interrupt 1465222Sksewell@umich.edu // should be returned. It ands the interrupt mask and 1475222Sksewell@umich.edu // and interrupt pending bits to see if one exists. It 1485222Sksewell@umich.edu // also makes sure interrupts are enabled (IE) and 1495222Sksewell@umich.edu // that ERL and ERX are not set 1505222Sksewell@umich.edu // 1515222Sksewell@umich.edu Fault getInterrupt(ThreadContext * tc); 1525222Sksewell@umich.edu 1535222Sksewell@umich.edu // updateIntrInfo(ThreadContext *tc) const syncs the 1545222Sksewell@umich.edu // MIPS cause register with the instatus variable. instatus 1555222Sksewell@umich.edu // is essentially a copy of the MIPS cause[IP7:IP0] 1565222Sksewell@umich.edu // 1575222Sksewell@umich.edu void updateIntrInfo(ThreadContext *tc) const; 1585222Sksewell@umich.edu bool interruptsPending(ThreadContext *tc) const; 1595222Sksewell@umich.edu bool onCpuTimerInterrupt(ThreadContext *tc) const; 1605222Sksewell@umich.edu 1615704Snate@binkert.org bool 1625704Snate@binkert.org checkInterrupts(ThreadContext *tc) const 1635704Snate@binkert.org { 1645222Sksewell@umich.edu return interruptsPending(tc); 1655222Sksewell@umich.edu } 1665222Sksewell@umich.edu 1675222Sksewell@umich.edu 1685222Sksewell@umich.edu void serialize(std::ostream &os) 1695222Sksewell@umich.edu { 1705222Sksewell@umich.edu fatal("Serialization of Interrupts Unimplemented for MIPS"); 1715222Sksewell@umich.edu //SERIALIZE_ARRAY(interrupts, NumInterruptLevels); 1725222Sksewell@umich.edu //SERIALIZE_SCALAR(intstatus); 1735222Sksewell@umich.edu } 1745222Sksewell@umich.edu 1755222Sksewell@umich.edu void unserialize(Checkpoint *cp, const std::string §ion) 1765222Sksewell@umich.edu { 1775222Sksewell@umich.edu fatal("Unserialization of Interrupts Unimplemented for MIPS"); 1785222Sksewell@umich.edu //UNSERIALIZE_ARRAY(interrupts, NumInterruptLevels); 1795222Sksewell@umich.edu //UNSERIALIZE_SCALAR(intstatus); 1805222Sksewell@umich.edu } 1815222Sksewell@umich.edu 1825222Sksewell@umich.edu 1835222Sksewell@umich.edu 1845222Sksewell@umich.edu private: 1855222Sksewell@umich.edu bool newInfoSet; 1865222Sksewell@umich.edu int newIpl; 1875222Sksewell@umich.edu int newSummary; 1885222Sksewell@umich.edu 1895222Sksewell@umich.edu}; 1905222Sksewell@umich.edu 1915222Sksewell@umich.edu} 1925222Sksewell@umich.edu 1935222Sksewell@umich.edu#endif 1945222Sksewell@umich.edu 195