interrupts.hh revision 3895:5e8f0e3aeca2
12810SN/A/* 212724Snikos.nikoleris@arm.com * Copyright (c) 2006 The Regents of The University of Michigan 38856Sandreas.hansson@arm.com * All rights reserved. 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 68856Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 78856Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 88856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 98856Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 108856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 118856Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 128856Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 138856Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 142810SN/A * this software without specific prior written permission. 152810SN/A * 162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272810SN/A * 282810SN/A * Authors: Steve Reinhardt 292810SN/A * Kevin Lim 302810SN/A */ 312810SN/A 322810SN/A#ifndef __ARCH_ALPHA_INTERRUPT_HH__ 332810SN/A#define __ARCH_ALPHA_INTERRUPT_HH__ 342810SN/A 352810SN/A#include "arch/alpha/faults.hh" 362810SN/A#include "arch/alpha/isa_traits.hh" 372810SN/A#include "cpu/thread_context.hh" 382810SN/A 392810SN/Anamespace AlphaISA 402810SN/A{ 4112724Snikos.nikoleris@arm.com class Interrupts 422810SN/A { 432810SN/A protected: 442810SN/A uint64_t interrupts[NumInterruptLevels]; 452810SN/A uint64_t intstatus; 462810SN/A 472810SN/A public: 482810SN/A Interrupts() 4911486Snikos.nikoleris@arm.com { 5011486Snikos.nikoleris@arm.com memset(interrupts, 0, sizeof(interrupts)); 5112724Snikos.nikoleris@arm.com intstatus = 0; 5212724Snikos.nikoleris@arm.com newInfoSet = false; 538232Snate@binkert.org } 5412724Snikos.nikoleris@arm.com 5513222Sodanrc@yahoo.com.br void post(int int_type) 5612724Snikos.nikoleris@arm.com { 5711486Snikos.nikoleris@arm.com // sparc only 5812724Snikos.nikoleris@arm.com } 5912724Snikos.nikoleris@arm.com 6012724Snikos.nikoleris@arm.com void post(int int_num, int index) 6113352Snikos.nikoleris@arm.com { 6212724Snikos.nikoleris@arm.com DPRINTF(Interrupt, "Interrupt %d:%d posted\n", int_num, index); 6312724Snikos.nikoleris@arm.com 6412724Snikos.nikoleris@arm.com if (int_num < 0 || int_num >= NumInterruptLevels) 6512724Snikos.nikoleris@arm.com panic("int_num out of bounds\n"); 662810SN/A 672810SN/A if (index < 0 || index >= sizeof(uint64_t) * 8) 682810SN/A panic("int_num out of bounds\n"); 698856Sandreas.hansson@arm.com 708856Sandreas.hansson@arm.com interrupts[int_num] |= 1 << index; 718856Sandreas.hansson@arm.com intstatus |= (ULL(1) << int_num); 728922Swilliam.wang@arm.com } 7312084Sspwilson2@wisc.edu 7412084Sspwilson2@wisc.edu void clear(int int_num, int index) 758856Sandreas.hansson@arm.com { 768856Sandreas.hansson@arm.com DPRINTF(Interrupt, "Interrupt %d:%d cleared\n", int_num, index); 774475SN/A 7811053Sandreas.hansson@arm.com if (int_num < 0 || int_num >= TheISA::NumInterruptLevels) 795034SN/A panic("int_num out of bounds\n"); 8012724Snikos.nikoleris@arm.com 8112724Snikos.nikoleris@arm.com if (index < 0 || index >= sizeof(uint64_t) * 8) 8211377Sandreas.hansson@arm.com panic("int_num out of bounds\n"); 8311377Sandreas.hansson@arm.com 8412724Snikos.nikoleris@arm.com interrupts[int_num] &= ~(1 << index); 8512724Snikos.nikoleris@arm.com if (interrupts[int_num] == 0) 8612724Snikos.nikoleris@arm.com intstatus &= ~(ULL(1) << int_num); 8713352Snikos.nikoleris@arm.com } 8812724Snikos.nikoleris@arm.com 8912724Snikos.nikoleris@arm.com void clear_all() 9012724Snikos.nikoleris@arm.com { 9112724Snikos.nikoleris@arm.com DPRINTF(Interrupt, "Interrupts all cleared\n"); 9212724Snikos.nikoleris@arm.com 9311053Sandreas.hansson@arm.com memset(interrupts, 0, sizeof(interrupts)); 9411722Ssophiane.senni@gmail.com intstatus = 0; 9511722Ssophiane.senni@gmail.com } 9611722Ssophiane.senni@gmail.com 9711722Ssophiane.senni@gmail.com void serialize(std::ostream &os) 989263Smrinmoy.ghosh@arm.com { 995034SN/A SERIALIZE_ARRAY(interrupts, NumInterruptLevels); 10011331Sandreas.hansson@arm.com SERIALIZE_SCALAR(intstatus); 10112724Snikos.nikoleris@arm.com } 10210884Sandreas.hansson@arm.com 1034626SN/A void unserialize(Checkpoint *cp, const std::string §ion) 10410360Sandreas.hansson@arm.com { 10511484Snikos.nikoleris@arm.com UNSERIALIZE_ARRAY(interrupts, NumInterruptLevels); 1065034SN/A UNSERIALIZE_SCALAR(intstatus); 1078883SAli.Saidi@ARM.com } 1088833Sdam.sunwoo@arm.com 1094458SN/A bool check_interrupts(ThreadContext * tc) const 11011377Sandreas.hansson@arm.com { 11111377Sandreas.hansson@arm.com return (intstatus != 0) && !(tc->readPC() & 0x3); 11211377Sandreas.hansson@arm.com } 11311377Sandreas.hansson@arm.com 11411377Sandreas.hansson@arm.com Fault getInterrupt(ThreadContext * tc) 11511377Sandreas.hansson@arm.com { 11611331Sandreas.hansson@arm.com int ipl = 0; 11711331Sandreas.hansson@arm.com int summary = 0; 11812724Snikos.nikoleris@arm.com 11912843Srmk35@cl.cam.ac.uk if (tc->readMiscReg(IPR_ASTRR)) 12012724Snikos.nikoleris@arm.com panic("asynchronous traps not implemented\n"); 12113216Sodanrc@yahoo.com.br 12212724Snikos.nikoleris@arm.com if (tc->readMiscReg(IPR_SIRR)) { 12312724Snikos.nikoleris@arm.com for (int i = INTLEVEL_SOFTWARE_MIN; 12412724Snikos.nikoleris@arm.com i < INTLEVEL_SOFTWARE_MAX; i++) { 12512724Snikos.nikoleris@arm.com if (tc->readMiscReg(IPR_SIRR) & (ULL(1) << i)) { 12612724Snikos.nikoleris@arm.com // See table 4-19 of 21164 hardware reference 12712724Snikos.nikoleris@arm.com ipl = (i - INTLEVEL_SOFTWARE_MIN) + 1; 12812724Snikos.nikoleris@arm.com summary |= (ULL(1) << i); 1292810SN/A } 1302810SN/A } 1313013SN/A } 1328856Sandreas.hansson@arm.com 1332810SN/A uint64_t interrupts = intstatus; 1343013SN/A if (interrupts) { 13510714Sandreas.hansson@arm.com for (int i = INTLEVEL_EXTERNAL_MIN; 1362810SN/A i < INTLEVEL_EXTERNAL_MAX; i++) { 1379614Srene.dejong@arm.com if (interrupts & (ULL(1) << i)) { 1389614Srene.dejong@arm.com // See table 4-19 of 21164 hardware reference 1399614Srene.dejong@arm.com ipl = i; 14010345SCurtis.Dunham@arm.com summary |= (ULL(1) << i); 14110714Sandreas.hansson@arm.com } 14210345SCurtis.Dunham@arm.com } 1439614Srene.dejong@arm.com } 1442810SN/A 1452810SN/A if (ipl && ipl > tc->readMiscReg(IPR_IPLR)) { 1462810SN/A newIpl = ipl; 1478856Sandreas.hansson@arm.com newSummary = summary; 1482810SN/A newInfoSet = true; 1493013SN/A DPRINTF(Flow, "Interrupt! IPLR=%d ipl=%d summary=%x\n", 15010714Sandreas.hansson@arm.com tc->readMiscReg(IPR_IPLR), ipl, summary); 1513013SN/A 1528856Sandreas.hansson@arm.com return new InterruptFault; 15310714Sandreas.hansson@arm.com } else { 1548922Swilliam.wang@arm.com return NoFault; 1552897SN/A } 1562810SN/A } 1572810SN/A 15810344Sandreas.hansson@arm.com void updateIntrInfo(ThreadContext *tc) 15910344Sandreas.hansson@arm.com { 16010344Sandreas.hansson@arm.com assert(newInfoSet); 16110714Sandreas.hansson@arm.com tc->setMiscReg(IPR_ISR, newSummary); 16210344Sandreas.hansson@arm.com tc->setMiscReg(IPR_INTID, newIpl); 16310344Sandreas.hansson@arm.com newInfoSet = false; 16410344Sandreas.hansson@arm.com } 16510713Sandreas.hansson@arm.com 16610344Sandreas.hansson@arm.com private: 1672844SN/A bool newInfoSet; 16812730Sodanrc@yahoo.com.br int newIpl; 16912730Sodanrc@yahoo.com.br int newSummary; 17012730Sodanrc@yahoo.com.br }; 17112730Sodanrc@yahoo.com.br} 17212730Sodanrc@yahoo.com.br 17312730Sodanrc@yahoo.com.br#endif 17412730Sodanrc@yahoo.com.br 17512730Sodanrc@yahoo.com.br