interrupts.hh revision 5565
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 605222Sksewell@umich.edu // which is called by check_interrupts 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 675222Sksewell@umich.edu // which is called by check_interrupts 685222Sksewell@umich.edu // 695222Sksewell@umich.edu void clear(int int_num, int index); 705222Sksewell@umich.edu // clear_all() 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 745222Sksewell@umich.edu // which is called by check_interrupts 755222Sksewell@umich.edu // 765222Sksewell@umich.edu void clear_all(); 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 945222Sksewell@umich.edu uint64_t get_vec(int int_num); 955222Sksewell@umich.edu 965222Sksewell@umich.edu bool check_interrupts(ThreadContext * tc) const{ 975222Sksewell@umich.edu //return (intstatus != 0) && !(tc->readPC() & 0x3); 985222Sksewell@umich.edu if (oncputimerintr == false){ 995222Sksewell@umich.edu updateIntrInfo(tc); 1005222Sksewell@umich.edu return ((intstatus != 0) || onCpuTimerInterrupt(tc)); 1015222Sksewell@umich.edu } 1025222Sksewell@umich.edu else 1035222Sksewell@umich.edu return true; 1045222Sksewell@umich.edu 1055222Sksewell@umich.edu } 1065222Sksewell@umich.edu */ 1075222Sksewell@umich.edu 1085222Sksewell@umich.edu 1095222Sksewell@umich.edu protected: 1105222Sksewell@umich.edu //uint8_t intstatus; 1115222Sksewell@umich.edu //bool oncputimerintr; 1125222Sksewell@umich.edu public: 1135222Sksewell@umich.edu Interrupts() 1145222Sksewell@umich.edu { 1155222Sksewell@umich.edu //intstatus = 0; 1165222Sksewell@umich.edu newInfoSet = false; 1175222Sksewell@umich.edu //oncputimerintr = false; 1185222Sksewell@umich.edu 1195222Sksewell@umich.edu } 1205222Sksewell@umich.edu // post(int int_num, int index) is responsible 1215222Sksewell@umich.edu // for posting an interrupt. It sets a bit 1225222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 1235222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 1245222Sksewell@umich.edu // which is called by check_interrupts 1255222Sksewell@umich.edu // 1265222Sksewell@umich.edu void post(int int_num, ThreadContext* tc); 1275222Sksewell@umich.edu void post(int int_num, int index); 1285222Sksewell@umich.edu 1295222Sksewell@umich.edu // clear(int int_num, int index) is responsible 1305222Sksewell@umich.edu // for clearing an interrupt. It clear a bit 1315222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 1325222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 1335222Sksewell@umich.edu // which is called by check_interrupts 1345222Sksewell@umich.edu // 1355222Sksewell@umich.edu void clear(int int_num, ThreadContext* tc); 1365222Sksewell@umich.edu void clear(int int_num, int index); 1375222Sksewell@umich.edu 1385222Sksewell@umich.edu // clear_all() is responsible 1395222Sksewell@umich.edu // for clearing all interrupts. It clears all bits 1405222Sksewell@umich.edu // in intstatus corresponding to Cause IP*. The 1415222Sksewell@umich.edu // MIPS register Cause is updated by updateIntrInfo 1425222Sksewell@umich.edu // which is called by check_interrupts 1435222Sksewell@umich.edu // 1445222Sksewell@umich.edu void clear_all(ThreadContext* tc); 1455222Sksewell@umich.edu void clear_all(); 1465222Sksewell@umich.edu 1475222Sksewell@umich.edu // getInterrupt(ThreadContext * tc) checks if an interrupt 1485222Sksewell@umich.edu // should be returned. It ands the interrupt mask and 1495222Sksewell@umich.edu // and interrupt pending bits to see if one exists. It 1505222Sksewell@umich.edu // also makes sure interrupts are enabled (IE) and 1515222Sksewell@umich.edu // that ERL and ERX are not set 1525222Sksewell@umich.edu // 1535222Sksewell@umich.edu Fault getInterrupt(ThreadContext * tc); 1545222Sksewell@umich.edu 1555222Sksewell@umich.edu // updateIntrInfo(ThreadContext *tc) const syncs the 1565222Sksewell@umich.edu // MIPS cause register with the instatus variable. instatus 1575222Sksewell@umich.edu // is essentially a copy of the MIPS cause[IP7:IP0] 1585222Sksewell@umich.edu // 1595222Sksewell@umich.edu void updateIntrInfo(ThreadContext *tc) const; 1605222Sksewell@umich.edu bool interruptsPending(ThreadContext *tc) const; 1615222Sksewell@umich.edu bool onCpuTimerInterrupt(ThreadContext *tc) const; 1625222Sksewell@umich.edu 1635222Sksewell@umich.edu uint64_t get_vec(int int_num); 1645222Sksewell@umich.edu 1655222Sksewell@umich.edu bool check_interrupts(ThreadContext * tc) const{ 1665222Sksewell@umich.edu return interruptsPending(tc); 1675222Sksewell@umich.edu } 1685222Sksewell@umich.edu 1695222Sksewell@umich.edu 1705222Sksewell@umich.edu void serialize(std::ostream &os) 1715222Sksewell@umich.edu { 1725222Sksewell@umich.edu fatal("Serialization of Interrupts Unimplemented for MIPS"); 1735222Sksewell@umich.edu //SERIALIZE_ARRAY(interrupts, NumInterruptLevels); 1745222Sksewell@umich.edu //SERIALIZE_SCALAR(intstatus); 1755222Sksewell@umich.edu } 1765222Sksewell@umich.edu 1775222Sksewell@umich.edu void unserialize(Checkpoint *cp, const std::string §ion) 1785222Sksewell@umich.edu { 1795222Sksewell@umich.edu fatal("Unserialization of Interrupts Unimplemented for MIPS"); 1805222Sksewell@umich.edu //UNSERIALIZE_ARRAY(interrupts, NumInterruptLevels); 1815222Sksewell@umich.edu //UNSERIALIZE_SCALAR(intstatus); 1825222Sksewell@umich.edu } 1835222Sksewell@umich.edu 1845222Sksewell@umich.edu 1855222Sksewell@umich.edu 1865222Sksewell@umich.edu private: 1875222Sksewell@umich.edu bool newInfoSet; 1885222Sksewell@umich.edu int newIpl; 1895222Sksewell@umich.edu int newSummary; 1905222Sksewell@umich.edu 1915222Sksewell@umich.edu}; 1925222Sksewell@umich.edu 1935222Sksewell@umich.edu} 1945222Sksewell@umich.edu 1955222Sksewell@umich.edu#endif 1965222Sksewell@umich.edu 197