interrupts.hh revision 4009
19793Sakash.bagdia@arm.com/* 27586SAli.Saidi@arm.com * Copyright (c) 2006 The Regents of The University of Michigan 37586SAli.Saidi@arm.com * All rights reserved. 47586SAli.Saidi@arm.com * 57586SAli.Saidi@arm.com * Redistribution and use in source and binary forms, with or without 67586SAli.Saidi@arm.com * modification, are permitted provided that the following conditions are 77586SAli.Saidi@arm.com * met: redistributions of source code must retain the above copyright 87586SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer; 97586SAli.Saidi@arm.com * redistributions in binary form must reproduce the above copyright 107586SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer in the 117586SAli.Saidi@arm.com * documentation and/or other materials provided with the distribution; 127586SAli.Saidi@arm.com * neither the name of the copyright holders nor the names of its 133970Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 143005Sstever@eecs.umich.edu * this software without specific prior written permission. 153005Sstever@eecs.umich.edu * 163005Sstever@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173005Sstever@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183005Sstever@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193005Sstever@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203005Sstever@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213005Sstever@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223005Sstever@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233005Sstever@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243005Sstever@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253005Sstever@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263005Sstever@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273005Sstever@eecs.umich.edu */ 283005Sstever@eecs.umich.edu 293005Sstever@eecs.umich.edu#ifndef __ARCH_SPARC_INTERRUPT_HH__ 303005Sstever@eecs.umich.edu#define __ARCH_SPARC_INTERRUPT_HH__ 313005Sstever@eecs.umich.edu 323005Sstever@eecs.umich.edu#include "arch/sparc/faults.hh" 333005Sstever@eecs.umich.edu#include "cpu/thread_context.hh" 343005Sstever@eecs.umich.edu 353005Sstever@eecs.umich.edunamespace SparcISA 363005Sstever@eecs.umich.edu{ 373005Sstever@eecs.umich.edu 383005Sstever@eecs.umich.eduenum interrupts_t { 393005Sstever@eecs.umich.edu trap_level_zero, 403005Sstever@eecs.umich.edu hstick_match, 416654Snate@binkert.org interrupt_vector, 426654Snate@binkert.org cpu_mondo, 432889SN/A dev_mondo, 442710SN/A resumable_error, 456654Snate@binkert.org soft_interrupt, 466654Snate@binkert.org num_interrupt_types 476654Snate@binkert.org}; 485457Ssaidi@eecs.umich.edu 496654Snate@binkert.orgclass Interrupts 506654Snate@binkert.org{ 512934SN/A 522549SN/A private: 532995SN/A 543395Shsul@eecs.umich.edu bool interrupts[num_interrupt_types]; 556981SLisa.Hsu@amd.com int numPosted; 569836Sandreas.hansson@arm.com 573448Shsul@eecs.umich.edu public: 588920Snilay@cs.wisc.edu Interrupts() 593444Sktlim@umich.edu { 602889SN/A for (int i = 0; i < num_interrupt_types; ++i) { 618920Snilay@cs.wisc.edu interrupts[i] = false; 628920Snilay@cs.wisc.edu } 633322Shsul@eecs.umich.edu numPosted = 0; 642710SN/A } 652710SN/A 662710SN/A void post(int int_type) 672710SN/A { 682710SN/A if (int_type < 0 || int_type >= num_interrupt_types) 692710SN/A panic("posting unknown interrupt!\n"); 703322Shsul@eecs.umich.edu interrupts[int_type] = true; 713304Sstever@eecs.umich.edu ++numPosted; 723322Shsul@eecs.umich.edu } 733322Shsul@eecs.umich.edu 743304Sstever@eecs.umich.edu void post(int int_num, int index) 759653SAndreas.Sandberg@ARM.com { 769653SAndreas.Sandberg@ARM.com 779653SAndreas.Sandberg@ARM.com } 789653SAndreas.Sandberg@ARM.com 799653SAndreas.Sandberg@ARM.com void clear(int int_num, int index) 809653SAndreas.Sandberg@ARM.com { 819653SAndreas.Sandberg@ARM.com 823481Shsul@eecs.umich.edu } 833481Shsul@eecs.umich.edu 842566SN/A void clear_all() 859665Sandreas.hansson@arm.com { 869665Sandreas.hansson@arm.com 879665Sandreas.hansson@arm.com } 889665Sandreas.hansson@arm.com 899665Sandreas.hansson@arm.com bool check_interrupts(ThreadContext * tc) const 902995SN/A { 913304Sstever@eecs.umich.edu if (numPosted) 923304Sstever@eecs.umich.edu return true; 933304Sstever@eecs.umich.edu else 942995SN/A return false; 952995SN/A } 962995SN/A 972917SN/A Fault getInterrupt(ThreadContext * tc) 982995SN/A { 998956Sjayneel@cs.wisc.edu int hpstate = tc->readMiscReg(MISCREG_HPSTATE); 1002995SN/A int pstate = tc->readMiscReg(MISCREG_PSTATE); 1018956Sjayneel@cs.wisc.edu bool ie = pstate & PSTATE::ie; 1023304Sstever@eecs.umich.edu 1036135Sgblack@eecs.umich.edu // THESE ARE IN ORDER OF PRIORITY 1046135Sgblack@eecs.umich.edu // since there are early returns, and the highest 1056654Snate@binkert.org // priority interrupts should get serviced, 1069826Sandreas.hansson@arm.com // it is v. important that new interrupts are inserted 1076654Snate@binkert.org // in the right order of processing 1089826Sandreas.hansson@arm.com if (hpstate & HPSTATE::hpriv) { 1096654Snate@binkert.org if (ie) { 1109826Sandreas.hansson@arm.com if (interrupts[hstick_match]) { 1116654Snate@binkert.org if (tc->readMiscReg(MISCREG_HINTP) & 1) { 1129826Sandreas.hansson@arm.com interrupts[hstick_match] = false; 1137586SAli.Saidi@arm.com --numPosted; 1149826Sandreas.hansson@arm.com return new HstickMatch; 1159826Sandreas.hansson@arm.com } 1169665Sandreas.hansson@arm.com } 1179935Sdam.sunwoo@arm.com if (interrupts[interrupt_vector]) { 1189935Sdam.sunwoo@arm.com interrupts[interrupt_vector] = false; 1193819Shsul@eecs.umich.edu --numPosted; 1209059Snilay@cs.wisc.edu //HAVEN'T IMPLed THIS YET 1213819Shsul@eecs.umich.edu return NoFault; 1229827Sakash.bagdia@arm.com } 1239827Sakash.bagdia@arm.com } else { 1249827Sakash.bagdia@arm.com if (interrupts[hstick_match]) { 1259793Sakash.bagdia@arm.com return NoFault; 1269827Sakash.bagdia@arm.com } 1279827Sakash.bagdia@arm.com 1289827Sakash.bagdia@arm.com } 1299827Sakash.bagdia@arm.com } else { 1309827Sakash.bagdia@arm.com if (interrupts[trap_level_zero]) { 1319793Sakash.bagdia@arm.com if ((pstate & HPSTATE::tlz) && (tc->readMiscReg(MISCREG_TL) == 0)) { 1329793Sakash.bagdia@arm.com interrupts[trap_level_zero] = false; 1339827Sakash.bagdia@arm.com --numPosted; 1349827Sakash.bagdia@arm.com return new TrapLevelZero; 1359827Sakash.bagdia@arm.com } 1369790Sakash.bagdia@arm.com } 1373873Sbinkertn@umich.edu if (interrupts[hstick_match]) { 1383873Sbinkertn@umich.edu if (tc->readMiscReg(MISCREG_HINTP) & 1) { 1393873Sbinkertn@umich.edu interrupts[hstick_match] = false; 1403873Sbinkertn@umich.edu --numPosted; 1413873Sbinkertn@umich.edu return new HstickMatch; 1423873Sbinkertn@umich.edu } 14310037SARM gem5 Developers } 14410037SARM gem5 Developers if (ie) { 14510037SARM gem5 Developers if (interrupts[cpu_mondo]) { 14610037SARM gem5 Developers interrupts[cpu_mondo] = false; 14710037SARM gem5 Developers --numPosted; 14810037SARM gem5 Developers return new CpuMondo; 1498659SAli.Saidi@ARM.com } 1508659SAli.Saidi@ARM.com if (interrupts[dev_mondo]) { 1519793Sakash.bagdia@arm.com interrupts[dev_mondo] = false; 1529793Sakash.bagdia@arm.com --numPosted; 1539793Sakash.bagdia@arm.com return new DevMondo; 1543668Srdreslin@umich.edu } 1559653SAndreas.Sandberg@ARM.com if (interrupts[soft_interrupt]) { 1569653SAndreas.Sandberg@ARM.com int il = InterruptLevel(tc->readMiscReg(MISCREG_SOFTINT)); 1579653SAndreas.Sandberg@ARM.com // it seems that interrupt vectors are right in 1586636Ssteve.reinhardt@amd.com // the middle of interrupt levels with regard to 1599788Sakash.bagdia@arm.com // priority, so have to check 1609788Sakash.bagdia@arm.com if ((il < 6) && 1618839Sandreas.hansson@arm.com interrupts[interrupt_vector]) { 1628839Sandreas.hansson@arm.com // may require more details here since there 1638713Sandreas.hansson@arm.com // may be lots of interrupts embedded in an 1649408Sandreas.hansson@arm.com // platform interrupt vector 1658839Sandreas.hansson@arm.com interrupts[interrupt_vector] = false; 1668839Sandreas.hansson@arm.com --numPosted; 1675142Ssaidi@eecs.umich.edu //HAVEN'T IMPLed YET 1688926Sandreas.hansson@arm.com return NoFault; 1699317Sandreas.hansson@arm.com } else { 1709317Sandreas.hansson@arm.com if (il > tc->readMiscReg(MISCREG_PIL)) { 1719317Sandreas.hansson@arm.com uint64_t si = tc->readMiscReg(MISCREG_SOFTINT); 1729317Sandreas.hansson@arm.com uint64_t more = si & ~(1 << (il + 1)); 1739317Sandreas.hansson@arm.com if (!InterruptLevel(more)) { 1748926Sandreas.hansson@arm.com interrupts[soft_interrupt] = false; 1753312Sstever@eecs.umich.edu --numPosted; 1764968Sacolyte@umich.edu } 1778926Sandreas.hansson@arm.com return new InterruptLevelN(il); 1788887Sgeoffrey.blake@arm.com } 1798887Sgeoffrey.blake@arm.com } 1809384SAndreas.Sandberg@arm.com } 1818887Sgeoffrey.blake@arm.com if (interrupts[resumable_error]) { 1828887Sgeoffrey.blake@arm.com interrupts[resumable_error] = false; 1839836Sandreas.hansson@arm.com --numPosted; 1849826Sandreas.hansson@arm.com return new ResumableError; 1853005Sstever@eecs.umich.edu } 1866654Snate@binkert.org } 1879826Sandreas.hansson@arm.com } 1886654Snate@binkert.org return NoFault; 1899826Sandreas.hansson@arm.com } 1906654Snate@binkert.org 1919826Sandreas.hansson@arm.com void updateIntrInfo(ThreadContext * tc) 1926654Snate@binkert.org { 1939826Sandreas.hansson@arm.com 1947586SAli.Saidi@arm.com } 1959826Sandreas.hansson@arm.com 1968661SAli.Saidi@ARM.com void serialize(std::ostream &os) 1979827Sakash.bagdia@arm.com { 1989827Sakash.bagdia@arm.com SERIALIZE_ARRAY(interrupts,num_interrupt_types); 1999827Sakash.bagdia@arm.com SERIALIZE_SCALAR(numPosted); 2009793Sakash.bagdia@arm.com } 2019793Sakash.bagdia@arm.com 2029790Sakash.bagdia@arm.com void unserialize(Checkpoint *cp, const std::string §ion) 2039827Sakash.bagdia@arm.com { 2049827Sakash.bagdia@arm.com UNSERIALIZE_ARRAY(interrupts,num_interrupt_types); 2059827Sakash.bagdia@arm.com UNSERIALIZE_SCALAR(numPosted); 2069793Sakash.bagdia@arm.com } 2079827Sakash.bagdia@arm.com}; 2089827Sakash.bagdia@arm.com} // namespace SPARC_ISA 2099827Sakash.bagdia@arm.com 2109793Sakash.bagdia@arm.com#endif // __ARCH_SPARC_INTERRUPT_HH__ 2119793Sakash.bagdia@arm.com