faults.cc revision 8750
12221SN/A/* 22221SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32221SN/A * All rights reserved. 42221SN/A * 52221SN/A * Redistribution and use in source and binary forms, with or without 62221SN/A * modification, are permitted provided that the following conditions are 72221SN/A * met: redistributions of source code must retain the above copyright 82221SN/A * notice, this list of conditions and the following disclaimer; 92221SN/A * redistributions in binary form must reproduce the above copyright 102221SN/A * notice, this list of conditions and the following disclaimer in the 112221SN/A * documentation and/or other materials provided with the distribution; 122221SN/A * neither the name of the copyright holders nor the names of its 132221SN/A * contributors may be used to endorse or promote products derived from 142221SN/A * this software without specific prior written permission. 152221SN/A * 162221SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172221SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182221SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192221SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202221SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212221SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222221SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232221SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242221SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252221SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262221SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu * Kevin Lim 302221SN/A */ 312221SN/A 323415Sgblack@eecs.umich.edu#include <algorithm> 333415Sgblack@eecs.umich.edu 342223SN/A#include "arch/sparc/faults.hh" 353415Sgblack@eecs.umich.edu#include "arch/sparc/isa_traits.hh" 363578Sgblack@eecs.umich.edu#include "arch/sparc/types.hh" 373415Sgblack@eecs.umich.edu#include "base/bitfield.hh" 383415Sgblack@eecs.umich.edu#include "base/trace.hh" 398750Sgblack@eecs.umich.edu#include "sim/full_system.hh" 403415Sgblack@eecs.umich.edu#include "cpu/base.hh" 412680Sktlim@umich.edu#include "cpu/thread_context.hh" 422800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM 433523Sgblack@eecs.umich.edu#include "arch/sparc/process.hh" 443415Sgblack@eecs.umich.edu#include "mem/page_table.hh" 452800Ssaidi@eecs.umich.edu#include "sim/process.hh" 462800Ssaidi@eecs.umich.edu#endif 478750Sgblack@eecs.umich.edu#include "sim/full_system.hh" 482221SN/A 493415Sgblack@eecs.umich.eduusing namespace std; 503415Sgblack@eecs.umich.edu 512223SN/Anamespace SparcISA 522221SN/A{ 532221SN/A 543573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 553576Sgblack@eecs.umich.edu SparcFault<PowerOnReset>::vals = 563576Sgblack@eecs.umich.edu {"power_on_reset", 0x001, 0, {H, H, H}}; 572221SN/A 583573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 593576Sgblack@eecs.umich.edu SparcFault<WatchDogReset>::vals = 603576Sgblack@eecs.umich.edu {"watch_dog_reset", 0x002, 120, {H, H, H}}; 612221SN/A 623573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 633576Sgblack@eecs.umich.edu SparcFault<ExternallyInitiatedReset>::vals = 643576Sgblack@eecs.umich.edu {"externally_initiated_reset", 0x003, 110, {H, H, H}}; 652221SN/A 663573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 673576Sgblack@eecs.umich.edu SparcFault<SoftwareInitiatedReset>::vals = 683576Sgblack@eecs.umich.edu {"software_initiated_reset", 0x004, 130, {SH, SH, H}}; 692221SN/A 703573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 713576Sgblack@eecs.umich.edu SparcFault<REDStateException>::vals = 723576Sgblack@eecs.umich.edu {"RED_state_exception", 0x005, 1, {H, H, H}}; 732221SN/A 743573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 753576Sgblack@eecs.umich.edu SparcFault<StoreError>::vals = 763576Sgblack@eecs.umich.edu {"store_error", 0x007, 201, {H, H, H}}; 772221SN/A 783573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 793576Sgblack@eecs.umich.edu SparcFault<InstructionAccessException>::vals = 803576Sgblack@eecs.umich.edu {"instruction_access_exception", 0x008, 300, {H, H, H}}; 813576Sgblack@eecs.umich.edu 823576Sgblack@eecs.umich.edu//XXX This trap is apparently dropped from ua2005 833576Sgblack@eecs.umich.edu/*template<> SparcFaultBase::FaultVals 843576Sgblack@eecs.umich.edu SparcFault<InstructionAccessMMUMiss>::vals = 853576Sgblack@eecs.umich.edu {"inst_mmu", 0x009, 2, {H, H, H}};*/ 862221SN/A 873573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 883576Sgblack@eecs.umich.edu SparcFault<InstructionAccessError>::vals = 893576Sgblack@eecs.umich.edu {"instruction_access_error", 0x00A, 400, {H, H, H}}; 902221SN/A 913573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 923576Sgblack@eecs.umich.edu SparcFault<IllegalInstruction>::vals = 933576Sgblack@eecs.umich.edu {"illegal_instruction", 0x010, 620, {H, H, H}}; 942221SN/A 953573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 963576Sgblack@eecs.umich.edu SparcFault<PrivilegedOpcode>::vals = 973576Sgblack@eecs.umich.edu {"privileged_opcode", 0x011, 700, {P, SH, SH}}; 983576Sgblack@eecs.umich.edu 993576Sgblack@eecs.umich.edu//XXX This trap is apparently dropped from ua2005 1003576Sgblack@eecs.umich.edu/*template<> SparcFaultBase::FaultVals 1013576Sgblack@eecs.umich.edu SparcFault<UnimplementedLDD>::vals = 1023576Sgblack@eecs.umich.edu {"unimp_ldd", 0x012, 6, {H, H, H}};*/ 1033576Sgblack@eecs.umich.edu 1043576Sgblack@eecs.umich.edu//XXX This trap is apparently dropped from ua2005 1053576Sgblack@eecs.umich.edu/*template<> SparcFaultBase::FaultVals 1063576Sgblack@eecs.umich.edu SparcFault<UnimplementedSTD>::vals = 1073576Sgblack@eecs.umich.edu {"unimp_std", 0x013, 6, {H, H, H}};*/ 1082221SN/A 1093573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1103576Sgblack@eecs.umich.edu SparcFault<FpDisabled>::vals = 1113576Sgblack@eecs.umich.edu {"fp_disabled", 0x020, 800, {P, P, H}}; 1122221SN/A 1133573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1143576Sgblack@eecs.umich.edu SparcFault<FpExceptionIEEE754>::vals = 1153576Sgblack@eecs.umich.edu {"fp_exception_ieee_754", 0x021, 1110, {P, P, H}}; 1162221SN/A 1173573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1183576Sgblack@eecs.umich.edu SparcFault<FpExceptionOther>::vals = 1193576Sgblack@eecs.umich.edu {"fp_exception_other", 0x022, 1110, {P, P, H}}; 1202221SN/A 1213573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1223576Sgblack@eecs.umich.edu SparcFault<TagOverflow>::vals = 1233576Sgblack@eecs.umich.edu {"tag_overflow", 0x023, 1400, {P, P, H}}; 1242221SN/A 1253573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1263576Sgblack@eecs.umich.edu SparcFault<CleanWindow>::vals = 1273576Sgblack@eecs.umich.edu {"clean_window", 0x024, 1010, {P, P, H}}; 1282221SN/A 1293573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1303576Sgblack@eecs.umich.edu SparcFault<DivisionByZero>::vals = 1313576Sgblack@eecs.umich.edu {"division_by_zero", 0x028, 1500, {P, P, H}}; 1322223SN/A 1333573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1343576Sgblack@eecs.umich.edu SparcFault<InternalProcessorError>::vals = 1353576Sgblack@eecs.umich.edu {"internal_processor_error", 0x029, 4, {H, H, H}}; 1362223SN/A 1373573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1383576Sgblack@eecs.umich.edu SparcFault<InstructionInvalidTSBEntry>::vals = 1393576Sgblack@eecs.umich.edu {"instruction_invalid_tsb_entry", 0x02A, 210, {H, H, SH}}; 1402223SN/A 1413573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1423576Sgblack@eecs.umich.edu SparcFault<DataInvalidTSBEntry>::vals = 1433576Sgblack@eecs.umich.edu {"data_invalid_tsb_entry", 0x02B, 1203, {H, H, H}}; 1442223SN/A 1453573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1463576Sgblack@eecs.umich.edu SparcFault<DataAccessException>::vals = 1473576Sgblack@eecs.umich.edu {"data_access_exception", 0x030, 1201, {H, H, H}}; 1483576Sgblack@eecs.umich.edu 1493576Sgblack@eecs.umich.edu//XXX This trap is apparently dropped from ua2005 1503576Sgblack@eecs.umich.edu/*template<> SparcFaultBase::FaultVals 1513576Sgblack@eecs.umich.edu SparcFault<DataAccessMMUMiss>::vals = 1523576Sgblack@eecs.umich.edu {"data_mmu", 0x031, 12, {H, H, H}};*/ 1532223SN/A 1543573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1553576Sgblack@eecs.umich.edu SparcFault<DataAccessError>::vals = 1563576Sgblack@eecs.umich.edu {"data_access_error", 0x032, 1210, {H, H, H}}; 1572223SN/A 1583573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1593576Sgblack@eecs.umich.edu SparcFault<DataAccessProtection>::vals = 1603576Sgblack@eecs.umich.edu {"data_access_protection", 0x033, 1207, {H, H, H}}; 1612223SN/A 1623573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1633576Sgblack@eecs.umich.edu SparcFault<MemAddressNotAligned>::vals = 1643576Sgblack@eecs.umich.edu {"mem_address_not_aligned", 0x034, 1020, {H, H, H}}; 1652223SN/A 1663573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1673576Sgblack@eecs.umich.edu SparcFault<LDDFMemAddressNotAligned>::vals = 1683576Sgblack@eecs.umich.edu {"LDDF_mem_address_not_aligned", 0x035, 1010, {H, H, H}}; 1692223SN/A 1703573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1713576Sgblack@eecs.umich.edu SparcFault<STDFMemAddressNotAligned>::vals = 1723576Sgblack@eecs.umich.edu {"STDF_mem_address_not_aligned", 0x036, 1010, {H, H, H}}; 1732223SN/A 1743573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1753576Sgblack@eecs.umich.edu SparcFault<PrivilegedAction>::vals = 1763576Sgblack@eecs.umich.edu {"privileged_action", 0x037, 1110, {H, H, SH}}; 1772223SN/A 1783573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1793576Sgblack@eecs.umich.edu SparcFault<LDQFMemAddressNotAligned>::vals = 1803576Sgblack@eecs.umich.edu {"LDQF_mem_address_not_aligned", 0x038, 1010, {H, H, H}}; 1812223SN/A 1823573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1833576Sgblack@eecs.umich.edu SparcFault<STQFMemAddressNotAligned>::vals = 1843576Sgblack@eecs.umich.edu {"STQF_mem_address_not_aligned", 0x039, 1010, {H, H, H}}; 1852223SN/A 1863573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1873576Sgblack@eecs.umich.edu SparcFault<InstructionRealTranslationMiss>::vals = 1883576Sgblack@eecs.umich.edu {"instruction_real_translation_miss", 0x03E, 208, {H, H, SH}}; 1892223SN/A 1903573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 1913576Sgblack@eecs.umich.edu SparcFault<DataRealTranslationMiss>::vals = 1923576Sgblack@eecs.umich.edu {"data_real_translation_miss", 0x03F, 1203, {H, H, H}}; 1932223SN/A 1943576Sgblack@eecs.umich.edu//XXX This trap is apparently dropped from ua2005 1953576Sgblack@eecs.umich.edu/*template<> SparcFaultBase::FaultVals 1963576Sgblack@eecs.umich.edu SparcFault<AsyncDataError>::vals = 1973576Sgblack@eecs.umich.edu {"async_data", 0x040, 2, {H, H, H}};*/ 1982527SN/A 1993573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2003576Sgblack@eecs.umich.edu SparcFault<InterruptLevelN>::vals = 2013890Ssaidi@eecs.umich.edu {"interrupt_level_n", 0x040, 0, {P, P, SH}}; 2022223SN/A 2033573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2043576Sgblack@eecs.umich.edu SparcFault<HstickMatch>::vals = 2053576Sgblack@eecs.umich.edu {"hstick_match", 0x05E, 1601, {H, H, H}}; 2062223SN/A 2073573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2083576Sgblack@eecs.umich.edu SparcFault<TrapLevelZero>::vals = 2093576Sgblack@eecs.umich.edu {"trap_level_zero", 0x05F, 202, {H, H, SH}}; 2102223SN/A 2113573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2124103Ssaidi@eecs.umich.edu SparcFault<InterruptVector>::vals = 2134103Ssaidi@eecs.umich.edu {"interrupt_vector", 0x060, 2630, {H, H, H}}; 2144103Ssaidi@eecs.umich.edu 2154103Ssaidi@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2163576Sgblack@eecs.umich.edu SparcFault<PAWatchpoint>::vals = 2173576Sgblack@eecs.umich.edu {"PA_watchpoint", 0x061, 1209, {H, H, H}}; 2182223SN/A 2193573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2203576Sgblack@eecs.umich.edu SparcFault<VAWatchpoint>::vals = 2213576Sgblack@eecs.umich.edu {"VA_watchpoint", 0x062, 1120, {P, P, SH}}; 2222223SN/A 2233573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2243576Sgblack@eecs.umich.edu SparcFault<FastInstructionAccessMMUMiss>::vals = 2253576Sgblack@eecs.umich.edu {"fast_instruction_access_MMU_miss", 0x064, 208, {H, H, SH}}; 2263576Sgblack@eecs.umich.edu 2273576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2283576Sgblack@eecs.umich.edu SparcFault<FastDataAccessMMUMiss>::vals = 2293576Sgblack@eecs.umich.edu {"fast_data_access_MMU_miss", 0x068, 1203, {H, H, H}}; 2303576Sgblack@eecs.umich.edu 2313576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2323576Sgblack@eecs.umich.edu SparcFault<FastDataAccessProtection>::vals = 2333576Sgblack@eecs.umich.edu {"fast_data_access_protection", 0x06C, 1207, {H, H, H}}; 2343576Sgblack@eecs.umich.edu 2353576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2363576Sgblack@eecs.umich.edu SparcFault<InstructionBreakpoint>::vals = 2373576Sgblack@eecs.umich.edu {"instruction_break", 0x076, 610, {H, H, H}}; 2383576Sgblack@eecs.umich.edu 2393576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2403576Sgblack@eecs.umich.edu SparcFault<CpuMondo>::vals = 2413576Sgblack@eecs.umich.edu {"cpu_mondo", 0x07C, 1608, {P, P, SH}}; 2423576Sgblack@eecs.umich.edu 2433576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2443576Sgblack@eecs.umich.edu SparcFault<DevMondo>::vals = 2453576Sgblack@eecs.umich.edu {"dev_mondo", 0x07D, 1611, {P, P, SH}}; 2463576Sgblack@eecs.umich.edu 2473576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2483893Shsul@eecs.umich.edu SparcFault<ResumableError>::vals = 2493576Sgblack@eecs.umich.edu {"resume_error", 0x07E, 3330, {P, P, SH}}; 2503576Sgblack@eecs.umich.edu 2513576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2523576Sgblack@eecs.umich.edu SparcFault<SpillNNormal>::vals = 2533576Sgblack@eecs.umich.edu {"spill_n_normal", 0x080, 900, {P, P, H}}; 2543576Sgblack@eecs.umich.edu 2553576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2563576Sgblack@eecs.umich.edu SparcFault<SpillNOther>::vals = 2573576Sgblack@eecs.umich.edu {"spill_n_other", 0x0A0, 900, {P, P, H}}; 2583576Sgblack@eecs.umich.edu 2593576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2603576Sgblack@eecs.umich.edu SparcFault<FillNNormal>::vals = 2613576Sgblack@eecs.umich.edu {"fill_n_normal", 0x0C0, 900, {P, P, H}}; 2623576Sgblack@eecs.umich.edu 2633576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2643576Sgblack@eecs.umich.edu SparcFault<FillNOther>::vals = 2653576Sgblack@eecs.umich.edu {"fill_n_other", 0x0E0, 900, {P, P, H}}; 2663576Sgblack@eecs.umich.edu 2673576Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals 2683576Sgblack@eecs.umich.edu SparcFault<TrapInstruction>::vals = 2693576Sgblack@eecs.umich.edu {"trap_instruction", 0x100, 1602, {P, P, H}}; 2702223SN/A 2713415Sgblack@eecs.umich.edu/** 2723578Sgblack@eecs.umich.edu * This causes the thread context to enter RED state. This causes the side 2733578Sgblack@eecs.umich.edu * effects which go with entering RED state because of a trap. 2743415Sgblack@eecs.umich.edu */ 2753415Sgblack@eecs.umich.edu 2767741Sgblack@eecs.umich.eduvoid 2777741Sgblack@eecs.umich.eduenterREDState(ThreadContext *tc) 2783415Sgblack@eecs.umich.edu{ 2793578Sgblack@eecs.umich.edu //@todo Disable the mmu? 2803578Sgblack@eecs.umich.edu //@todo Disable watchpoints? 2814172Ssaidi@eecs.umich.edu MiscReg HPSTATE = tc->readMiscRegNoEffect(MISCREG_HPSTATE); 2827741Sgblack@eecs.umich.edu // HPSTATE.red = 1 2833578Sgblack@eecs.umich.edu HPSTATE |= (1 << 5); 2847741Sgblack@eecs.umich.edu // HPSTATE.hpriv = 1 2853578Sgblack@eecs.umich.edu HPSTATE |= (1 << 2); 2864172Ssaidi@eecs.umich.edu tc->setMiscReg(MISCREG_HPSTATE, HPSTATE); 2877741Sgblack@eecs.umich.edu // PSTATE.priv is set to 1 here. The manual says it should be 0, but 2887741Sgblack@eecs.umich.edu // Legion sets it to 1. 2894172Ssaidi@eecs.umich.edu MiscReg PSTATE = tc->readMiscRegNoEffect(MISCREG_PSTATE); 2903746Sgblack@eecs.umich.edu PSTATE |= (1 << 2); 2914172Ssaidi@eecs.umich.edu tc->setMiscReg(MISCREG_PSTATE, PSTATE); 2923578Sgblack@eecs.umich.edu} 2933578Sgblack@eecs.umich.edu 2943578Sgblack@eecs.umich.edu/** 2953578Sgblack@eecs.umich.edu * This sets everything up for a RED state trap except for actually jumping to 2963578Sgblack@eecs.umich.edu * the handler. 2973578Sgblack@eecs.umich.edu */ 2983578Sgblack@eecs.umich.edu 2997741Sgblack@eecs.umich.eduvoid 3007741Sgblack@eecs.umich.edudoREDFault(ThreadContext *tc, TrapType tt) 3013578Sgblack@eecs.umich.edu{ 3024172Ssaidi@eecs.umich.edu MiscReg TL = tc->readMiscRegNoEffect(MISCREG_TL); 3034172Ssaidi@eecs.umich.edu MiscReg TSTATE = tc->readMiscRegNoEffect(MISCREG_TSTATE); 3044172Ssaidi@eecs.umich.edu MiscReg PSTATE = tc->readMiscRegNoEffect(MISCREG_PSTATE); 3054172Ssaidi@eecs.umich.edu MiscReg HPSTATE = tc->readMiscRegNoEffect(MISCREG_HPSTATE); 3063761Sgblack@eecs.umich.edu MiscReg CCR = tc->readIntReg(NumIntArchRegs + 2); 3074172Ssaidi@eecs.umich.edu MiscReg ASI = tc->readMiscRegNoEffect(MISCREG_ASI); 3084172Ssaidi@eecs.umich.edu MiscReg CWP = tc->readMiscRegNoEffect(MISCREG_CWP); 3094172Ssaidi@eecs.umich.edu MiscReg CANSAVE = tc->readMiscRegNoEffect(NumIntArchRegs + 3); 3104172Ssaidi@eecs.umich.edu MiscReg GL = tc->readMiscRegNoEffect(MISCREG_GL); 3117720Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 3123578Sgblack@eecs.umich.edu 3133578Sgblack@eecs.umich.edu TL++; 3143578Sgblack@eecs.umich.edu 3157720Sgblack@eecs.umich.edu Addr pcMask = bits(PSTATE, 3) ? mask(32) : mask(64); 3163928Ssaidi@eecs.umich.edu 3177741Sgblack@eecs.umich.edu // set TSTATE.gl to gl 3183578Sgblack@eecs.umich.edu replaceBits(TSTATE, 42, 40, GL); 3197741Sgblack@eecs.umich.edu // set TSTATE.ccr to ccr 3203578Sgblack@eecs.umich.edu replaceBits(TSTATE, 39, 32, CCR); 3217741Sgblack@eecs.umich.edu // set TSTATE.asi to asi 3223578Sgblack@eecs.umich.edu replaceBits(TSTATE, 31, 24, ASI); 3237741Sgblack@eecs.umich.edu // set TSTATE.pstate to pstate 3243578Sgblack@eecs.umich.edu replaceBits(TSTATE, 20, 8, PSTATE); 3257741Sgblack@eecs.umich.edu // set TSTATE.cwp to cwp 3263578Sgblack@eecs.umich.edu replaceBits(TSTATE, 4, 0, CWP); 3273578Sgblack@eecs.umich.edu 3287741Sgblack@eecs.umich.edu // Write back TSTATE 3294172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TSTATE, TSTATE); 3303578Sgblack@eecs.umich.edu 3317741Sgblack@eecs.umich.edu // set TPC to PC 3327720Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TPC, pc.pc() & pcMask); 3337741Sgblack@eecs.umich.edu // set TNPC to NPC 3347720Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TNPC, pc.npc() & pcMask); 3353578Sgblack@eecs.umich.edu 3367741Sgblack@eecs.umich.edu // set HTSTATE.hpstate to hpstate 3374172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_HTSTATE, HPSTATE); 3383578Sgblack@eecs.umich.edu 3397741Sgblack@eecs.umich.edu // TT = trap type; 3404172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TT, tt); 3413578Sgblack@eecs.umich.edu 3427741Sgblack@eecs.umich.edu // Update GL 3434172Ssaidi@eecs.umich.edu tc->setMiscReg(MISCREG_GL, min<int>(GL+1, MaxGL)); 3443578Sgblack@eecs.umich.edu 3453926Ssaidi@eecs.umich.edu PSTATE = mbits(PSTATE, 2, 2); // just save the priv bit 3467741Sgblack@eecs.umich.edu PSTATE |= (1 << 4); // set PSTATE.pef to 1 3474172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_PSTATE, PSTATE); 3483578Sgblack@eecs.umich.edu 3497741Sgblack@eecs.umich.edu // set HPSTATE.red to 1 3503578Sgblack@eecs.umich.edu HPSTATE |= (1 << 5); 3517741Sgblack@eecs.umich.edu // set HPSTATE.hpriv to 1 3523578Sgblack@eecs.umich.edu HPSTATE |= (1 << 2); 3537741Sgblack@eecs.umich.edu // set HPSTATE.ibe to 0 3543578Sgblack@eecs.umich.edu HPSTATE &= ~(1 << 10); 3557741Sgblack@eecs.umich.edu // set HPSTATE.tlz to 0 3563578Sgblack@eecs.umich.edu HPSTATE &= ~(1 << 0); 3574172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_HPSTATE, HPSTATE); 3583578Sgblack@eecs.umich.edu 3593578Sgblack@eecs.umich.edu bool changedCWP = true; 3603893Shsul@eecs.umich.edu if (tt == 0x24) 3613415Sgblack@eecs.umich.edu CWP++; 3623893Shsul@eecs.umich.edu else if (0x80 <= tt && tt <= 0xbf) 3633415Sgblack@eecs.umich.edu CWP += (CANSAVE + 2); 3643893Shsul@eecs.umich.edu else if (0xc0 <= tt && tt <= 0xff) 3653415Sgblack@eecs.umich.edu CWP--; 3663415Sgblack@eecs.umich.edu else 3673415Sgblack@eecs.umich.edu changedCWP = false; 3683420Sgblack@eecs.umich.edu 3697741Sgblack@eecs.umich.edu if (changedCWP) { 3703415Sgblack@eecs.umich.edu CWP = (CWP + NWindows) % NWindows; 3714172Ssaidi@eecs.umich.edu tc->setMiscReg(MISCREG_CWP, CWP); 3723415Sgblack@eecs.umich.edu } 3733415Sgblack@eecs.umich.edu} 3743415Sgblack@eecs.umich.edu 3757741Sgblack@eecs.umich.edu/** 3767741Sgblack@eecs.umich.edu * This sets everything up for a normal trap except for actually jumping to 3777741Sgblack@eecs.umich.edu * the handler. 3787741Sgblack@eecs.umich.edu */ 3797741Sgblack@eecs.umich.edu 3807741Sgblack@eecs.umich.eduvoid 3817741Sgblack@eecs.umich.edudoNormalFault(ThreadContext *tc, TrapType tt, bool gotoHpriv) 3827741Sgblack@eecs.umich.edu{ 3837741Sgblack@eecs.umich.edu MiscReg TL = tc->readMiscRegNoEffect(MISCREG_TL); 3847741Sgblack@eecs.umich.edu MiscReg TSTATE = tc->readMiscRegNoEffect(MISCREG_TSTATE); 3857741Sgblack@eecs.umich.edu MiscReg PSTATE = tc->readMiscRegNoEffect(MISCREG_PSTATE); 3867741Sgblack@eecs.umich.edu MiscReg HPSTATE = tc->readMiscRegNoEffect(MISCREG_HPSTATE); 3877741Sgblack@eecs.umich.edu MiscReg CCR = tc->readIntReg(NumIntArchRegs + 2); 3887741Sgblack@eecs.umich.edu MiscReg ASI = tc->readMiscRegNoEffect(MISCREG_ASI); 3897741Sgblack@eecs.umich.edu MiscReg CWP = tc->readMiscRegNoEffect(MISCREG_CWP); 3907741Sgblack@eecs.umich.edu MiscReg CANSAVE = tc->readIntReg(NumIntArchRegs + 3); 3917741Sgblack@eecs.umich.edu MiscReg GL = tc->readMiscRegNoEffect(MISCREG_GL); 3927741Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 3937741Sgblack@eecs.umich.edu 3947741Sgblack@eecs.umich.edu // Increment the trap level 3957741Sgblack@eecs.umich.edu TL++; 3967741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TL, TL); 3977741Sgblack@eecs.umich.edu 3987741Sgblack@eecs.umich.edu Addr pcMask = bits(PSTATE, 3) ? mask(32) : mask(64); 3997741Sgblack@eecs.umich.edu 4007741Sgblack@eecs.umich.edu // Save off state 4017741Sgblack@eecs.umich.edu 4027741Sgblack@eecs.umich.edu // set TSTATE.gl to gl 4037741Sgblack@eecs.umich.edu replaceBits(TSTATE, 42, 40, GL); 4047741Sgblack@eecs.umich.edu // set TSTATE.ccr to ccr 4057741Sgblack@eecs.umich.edu replaceBits(TSTATE, 39, 32, CCR); 4067741Sgblack@eecs.umich.edu // set TSTATE.asi to asi 4077741Sgblack@eecs.umich.edu replaceBits(TSTATE, 31, 24, ASI); 4087741Sgblack@eecs.umich.edu // set TSTATE.pstate to pstate 4097741Sgblack@eecs.umich.edu replaceBits(TSTATE, 20, 8, PSTATE); 4107741Sgblack@eecs.umich.edu // set TSTATE.cwp to cwp 4117741Sgblack@eecs.umich.edu replaceBits(TSTATE, 4, 0, CWP); 4127741Sgblack@eecs.umich.edu 4137741Sgblack@eecs.umich.edu // Write back TSTATE 4147741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TSTATE, TSTATE); 4157741Sgblack@eecs.umich.edu 4167741Sgblack@eecs.umich.edu // set TPC to PC 4177741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TPC, pc.pc() & pcMask); 4187741Sgblack@eecs.umich.edu // set TNPC to NPC 4197741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TNPC, pc.npc() & pcMask); 4207741Sgblack@eecs.umich.edu 4217741Sgblack@eecs.umich.edu // set HTSTATE.hpstate to hpstate 4227741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_HTSTATE, HPSTATE); 4237741Sgblack@eecs.umich.edu 4247741Sgblack@eecs.umich.edu // TT = trap type; 4257741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TT, tt); 4267741Sgblack@eecs.umich.edu 4277741Sgblack@eecs.umich.edu // Update the global register level 4287741Sgblack@eecs.umich.edu if (!gotoHpriv) 4297741Sgblack@eecs.umich.edu tc->setMiscReg(MISCREG_GL, min<int>(GL + 1, MaxPGL)); 4307741Sgblack@eecs.umich.edu else 4317741Sgblack@eecs.umich.edu tc->setMiscReg(MISCREG_GL, min<int>(GL + 1, MaxGL)); 4327741Sgblack@eecs.umich.edu 4337741Sgblack@eecs.umich.edu // PSTATE.mm is unchanged 4347741Sgblack@eecs.umich.edu PSTATE |= (1 << 4); // PSTATE.pef = whether or not an fpu is present 4357741Sgblack@eecs.umich.edu PSTATE &= ~(1 << 3); // PSTATE.am = 0 4367741Sgblack@eecs.umich.edu PSTATE &= ~(1 << 1); // PSTATE.ie = 0 4377741Sgblack@eecs.umich.edu // PSTATE.tle is unchanged 4387741Sgblack@eecs.umich.edu // PSTATE.tct = 0 4397741Sgblack@eecs.umich.edu 4407741Sgblack@eecs.umich.edu if (gotoHpriv) { 4417741Sgblack@eecs.umich.edu PSTATE &= ~(1 << 9); // PSTATE.cle = 0 4427741Sgblack@eecs.umich.edu // The manual says PSTATE.priv should be 0, but Legion leaves it alone 4437741Sgblack@eecs.umich.edu HPSTATE &= ~(1 << 5); // HPSTATE.red = 0 4447741Sgblack@eecs.umich.edu HPSTATE |= (1 << 2); // HPSTATE.hpriv = 1 4457741Sgblack@eecs.umich.edu HPSTATE &= ~(1 << 10); // HPSTATE.ibe = 0 4467741Sgblack@eecs.umich.edu // HPSTATE.tlz is unchanged 4477741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_HPSTATE, HPSTATE); 4487741Sgblack@eecs.umich.edu } else { // we are going to priv 4497741Sgblack@eecs.umich.edu PSTATE |= (1 << 2); // PSTATE.priv = 1 4507741Sgblack@eecs.umich.edu replaceBits(PSTATE, 9, 9, PSTATE >> 8); // PSTATE.cle = PSTATE.tle 4517741Sgblack@eecs.umich.edu } 4527741Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_PSTATE, PSTATE); 4537741Sgblack@eecs.umich.edu 4547741Sgblack@eecs.umich.edu 4557741Sgblack@eecs.umich.edu bool changedCWP = true; 4567741Sgblack@eecs.umich.edu if (tt == 0x24) 4577741Sgblack@eecs.umich.edu CWP++; 4587741Sgblack@eecs.umich.edu else if (0x80 <= tt && tt <= 0xbf) 4597741Sgblack@eecs.umich.edu CWP += (CANSAVE + 2); 4607741Sgblack@eecs.umich.edu else if (0xc0 <= tt && tt <= 0xff) 4617741Sgblack@eecs.umich.edu CWP--; 4627741Sgblack@eecs.umich.edu else 4637741Sgblack@eecs.umich.edu changedCWP = false; 4647741Sgblack@eecs.umich.edu 4657741Sgblack@eecs.umich.edu if (changedCWP) { 4667741Sgblack@eecs.umich.edu CWP = (CWP + NWindows) % NWindows; 4677741Sgblack@eecs.umich.edu tc->setMiscReg(MISCREG_CWP, CWP); 4687741Sgblack@eecs.umich.edu } 4697741Sgblack@eecs.umich.edu} 4707741Sgblack@eecs.umich.edu 4717741Sgblack@eecs.umich.eduvoid 4727741Sgblack@eecs.umich.edugetREDVector(MiscReg TT, Addr &PC, Addr &NPC) 4733578Sgblack@eecs.umich.edu{ 4743585Sgblack@eecs.umich.edu //XXX The following constant might belong in a header file. 4753603Ssaidi@eecs.umich.edu const Addr RSTVAddr = 0xFFF0000000ULL; 4763595Sgblack@eecs.umich.edu PC = RSTVAddr | ((TT << 5) & 0xFF); 4773578Sgblack@eecs.umich.edu NPC = PC + sizeof(MachInst); 4783578Sgblack@eecs.umich.edu} 4793578Sgblack@eecs.umich.edu 4807741Sgblack@eecs.umich.eduvoid 4817741Sgblack@eecs.umich.edugetHyperVector(ThreadContext * tc, Addr &PC, Addr &NPC, MiscReg TT) 4823578Sgblack@eecs.umich.edu{ 4834172Ssaidi@eecs.umich.edu Addr HTBA = tc->readMiscRegNoEffect(MISCREG_HTBA); 4843578Sgblack@eecs.umich.edu PC = (HTBA & ~mask(14)) | ((TT << 5) & mask(14)); 4853578Sgblack@eecs.umich.edu NPC = PC + sizeof(MachInst); 4863578Sgblack@eecs.umich.edu} 4873578Sgblack@eecs.umich.edu 4887741Sgblack@eecs.umich.eduvoid 4897741Sgblack@eecs.umich.edugetPrivVector(ThreadContext *tc, Addr &PC, Addr &NPC, MiscReg TT, MiscReg TL) 4903578Sgblack@eecs.umich.edu{ 4914172Ssaidi@eecs.umich.edu Addr TBA = tc->readMiscRegNoEffect(MISCREG_TBA); 4923578Sgblack@eecs.umich.edu PC = (TBA & ~mask(15)) | 4933578Sgblack@eecs.umich.edu (TL > 1 ? (1 << 14) : 0) | 4943578Sgblack@eecs.umich.edu ((TT << 5) & mask(14)); 4953578Sgblack@eecs.umich.edu NPC = PC + sizeof(MachInst); 4963578Sgblack@eecs.umich.edu} 4973578Sgblack@eecs.umich.edu 4987741Sgblack@eecs.umich.eduvoid 4997741Sgblack@eecs.umich.eduSparcFaultBase::invoke(ThreadContext * tc, StaticInstPtr inst) 5002221SN/A{ 5012680Sktlim@umich.edu FaultBase::invoke(tc); 5028750Sgblack@eecs.umich.edu if (!FullSystem) 5038750Sgblack@eecs.umich.edu return; 5048750Sgblack@eecs.umich.edu 5052223SN/A countStat()++; 5062221SN/A 5077741Sgblack@eecs.umich.edu // We can refer to this to see what the trap level -was-, but something 5087741Sgblack@eecs.umich.edu // in the middle could change it in the regfile out from under us. 5094172Ssaidi@eecs.umich.edu MiscReg tl = tc->readMiscRegNoEffect(MISCREG_TL); 5104172Ssaidi@eecs.umich.edu MiscReg tt = tc->readMiscRegNoEffect(MISCREG_TT); 5114172Ssaidi@eecs.umich.edu MiscReg pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE); 5124172Ssaidi@eecs.umich.edu MiscReg hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE); 5133578Sgblack@eecs.umich.edu 5143578Sgblack@eecs.umich.edu Addr PC, NPC; 5153578Sgblack@eecs.umich.edu 5163578Sgblack@eecs.umich.edu PrivilegeLevel current; 5173893Shsul@eecs.umich.edu if (hpstate & HPSTATE::hpriv) 5183746Sgblack@eecs.umich.edu current = Hyperprivileged; 5193893Shsul@eecs.umich.edu else if (pstate & PSTATE::priv) 5203578Sgblack@eecs.umich.edu current = Privileged; 5213578Sgblack@eecs.umich.edu else 5223746Sgblack@eecs.umich.edu current = User; 5233578Sgblack@eecs.umich.edu 5243578Sgblack@eecs.umich.edu PrivilegeLevel level = getNextLevel(current); 5253578Sgblack@eecs.umich.edu 5263893Shsul@eecs.umich.edu if ((hpstate & HPSTATE::red) || (tl == MaxTL - 1)) { 5273595Sgblack@eecs.umich.edu getREDVector(5, PC, NPC); 5283893Shsul@eecs.umich.edu doREDFault(tc, tt); 5297741Sgblack@eecs.umich.edu // This changes the hpstate and pstate, so we need to make sure we 5307741Sgblack@eecs.umich.edu // save the old version on the trap stack in doREDFault. 5313578Sgblack@eecs.umich.edu enterREDState(tc); 5323893Shsul@eecs.umich.edu } else if (tl == MaxTL) { 5333825Ssaidi@eecs.umich.edu panic("Should go to error state here.. crap\n"); 5347741Sgblack@eecs.umich.edu // Do error_state somehow? 5357741Sgblack@eecs.umich.edu // Probably inject a WDR fault using the interrupt mechanism. 5367741Sgblack@eecs.umich.edu // What should the PC and NPC be set to? 5373893Shsul@eecs.umich.edu } else if (tl > MaxPTL && level == Privileged) { 5387741Sgblack@eecs.umich.edu // guest_watchdog fault 5393578Sgblack@eecs.umich.edu doNormalFault(tc, trapType(), true); 5403585Sgblack@eecs.umich.edu getHyperVector(tc, PC, NPC, 2); 5413893Shsul@eecs.umich.edu } else if (level == Hyperprivileged || 5425570Snate@binkert.org (level == Privileged && trapType() >= 384)) { 5433578Sgblack@eecs.umich.edu doNormalFault(tc, trapType(), true); 5443585Sgblack@eecs.umich.edu getHyperVector(tc, PC, NPC, trapType()); 5453826Ssaidi@eecs.umich.edu } else { 5463578Sgblack@eecs.umich.edu doNormalFault(tc, trapType(), false); 5477741Sgblack@eecs.umich.edu getPrivVector(tc, PC, NPC, trapType(), tl + 1); 5483578Sgblack@eecs.umich.edu } 5493578Sgblack@eecs.umich.edu 5507720Sgblack@eecs.umich.edu PCState pc; 5517720Sgblack@eecs.umich.edu pc.pc(PC); 5527720Sgblack@eecs.umich.edu pc.npc(NPC); 5537720Sgblack@eecs.umich.edu pc.nnpc(NPC + sizeof(MachInst)); 5547720Sgblack@eecs.umich.edu pc.upc(0); 5557720Sgblack@eecs.umich.edu pc.nupc(1); 5567720Sgblack@eecs.umich.edu tc->pcState(pc); 5573420Sgblack@eecs.umich.edu} 5582221SN/A 5597741Sgblack@eecs.umich.eduvoid 5607741Sgblack@eecs.umich.eduPowerOnReset::invoke(ThreadContext *tc, StaticInstPtr inst) 5613523Sgblack@eecs.umich.edu{ 5627741Sgblack@eecs.umich.edu // For SPARC, when a system is first started, there is a power 5637741Sgblack@eecs.umich.edu // on reset Trap which sets the processor into the following state. 5647741Sgblack@eecs.umich.edu // Bits that aren't set aren't defined on startup. 5653595Sgblack@eecs.umich.edu 5664172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TL, MaxTL); 5674172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TT, trapType()); 5684172Ssaidi@eecs.umich.edu tc->setMiscReg(MISCREG_GL, MaxGL); 5693595Sgblack@eecs.umich.edu 5707741Sgblack@eecs.umich.edu // Turn on pef and priv, set everything else to 0 5714172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_PSTATE, (1 << 4) | (1 << 2)); 5723595Sgblack@eecs.umich.edu 5737741Sgblack@eecs.umich.edu // Turn on red and hpriv, set everything else to 0 5744172Ssaidi@eecs.umich.edu MiscReg HPSTATE = tc->readMiscRegNoEffect(MISCREG_HPSTATE); 5757741Sgblack@eecs.umich.edu // HPSTATE.red = 1 5763628Sgblack@eecs.umich.edu HPSTATE |= (1 << 5); 5777741Sgblack@eecs.umich.edu // HPSTATE.hpriv = 1 5783628Sgblack@eecs.umich.edu HPSTATE |= (1 << 2); 5797741Sgblack@eecs.umich.edu // HPSTATE.ibe = 0 5803628Sgblack@eecs.umich.edu HPSTATE &= ~(1 << 10); 5817741Sgblack@eecs.umich.edu // HPSTATE.tlz = 0 5823628Sgblack@eecs.umich.edu HPSTATE &= ~(1 << 0); 5834172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_HPSTATE, HPSTATE); 5843595Sgblack@eecs.umich.edu 5857741Sgblack@eecs.umich.edu // The tick register is unreadable by nonprivileged software 5864172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_TICK, 1ULL << 63); 5873595Sgblack@eecs.umich.edu 5887741Sgblack@eecs.umich.edu // Enter RED state. We do this last so that the actual state preserved in 5897741Sgblack@eecs.umich.edu // the trap stack is the state from before this fault. 5903746Sgblack@eecs.umich.edu enterREDState(tc); 5913746Sgblack@eecs.umich.edu 5923595Sgblack@eecs.umich.edu Addr PC, NPC; 5933595Sgblack@eecs.umich.edu getREDVector(trapType(), PC, NPC); 5947720Sgblack@eecs.umich.edu 5957720Sgblack@eecs.umich.edu PCState pc; 5967720Sgblack@eecs.umich.edu pc.pc(PC); 5977720Sgblack@eecs.umich.edu pc.npc(NPC); 5987720Sgblack@eecs.umich.edu pc.nnpc(NPC + sizeof(MachInst)); 5997720Sgblack@eecs.umich.edu pc.upc(0); 6007720Sgblack@eecs.umich.edu pc.nupc(1); 6017720Sgblack@eecs.umich.edu tc->pcState(pc); 6023595Sgblack@eecs.umich.edu 6037741Sgblack@eecs.umich.edu // These registers are specified as "undefined" after a POR, and they 6047741Sgblack@eecs.umich.edu // should have reasonable values after the miscregfile is reset 6053523Sgblack@eecs.umich.edu /* 6063595Sgblack@eecs.umich.edu // Clear all the soft interrupt bits 6073595Sgblack@eecs.umich.edu softint = 0; 6083595Sgblack@eecs.umich.edu // disable timer compare interrupts, reset tick_cmpr 6094172Ssaidi@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_ 6103595Sgblack@eecs.umich.edu tick_cmprFields.int_dis = 1; 6113523Sgblack@eecs.umich.edu tick_cmprFields.tick_cmpr = 0; // Reset to 0 for pretty printing 6127741Sgblack@eecs.umich.edu stickFields.npt = 1; // The TICK register is unreadable by by !priv 6133523Sgblack@eecs.umich.edu stick_cmprFields.int_dis = 1; // disable timer compare interrupts 6143523Sgblack@eecs.umich.edu stick_cmprFields.tick_cmpr = 0; // Reset to 0 for pretty printing 6153523Sgblack@eecs.umich.edu 6163523Sgblack@eecs.umich.edu tt[tl] = _trapType; 6173523Sgblack@eecs.umich.edu 6183523Sgblack@eecs.umich.edu hintp = 0; // no interrupts pending 6193523Sgblack@eecs.umich.edu hstick_cmprFields.int_dis = 1; // disable timer compare interrupts 6203523Sgblack@eecs.umich.edu hstick_cmprFields.tick_cmpr = 0; // Reset to 0 for pretty printing 6213523Sgblack@eecs.umich.edu */ 6222221SN/A} 6232221SN/A 6247741Sgblack@eecs.umich.eduvoid 6257741Sgblack@eecs.umich.eduFastInstructionAccessMMUMiss::invoke(ThreadContext *tc, StaticInstPtr inst) 6264997Sgblack@eecs.umich.edu{ 6278750Sgblack@eecs.umich.edu#if !FULL_SYSTEM 6284997Sgblack@eecs.umich.edu Process *p = tc->getProcessPtr(); 6295184Sgblack@eecs.umich.edu TlbEntry entry; 6305184Sgblack@eecs.umich.edu bool success = p->pTable->lookup(vaddr, entry); 6317741Sgblack@eecs.umich.edu if (!success) { 6324997Sgblack@eecs.umich.edu panic("Tried to execute unmapped address %#x.\n", vaddr); 6334997Sgblack@eecs.umich.edu } else { 6344997Sgblack@eecs.umich.edu Addr alignedVaddr = p->pTable->pageAlign(vaddr); 6354997Sgblack@eecs.umich.edu tc->getITBPtr()->insert(alignedVaddr, 0 /*partition id*/, 6365184Sgblack@eecs.umich.edu p->M5_pid /*context id*/, false, entry.pte); 6374997Sgblack@eecs.umich.edu } 6388750Sgblack@eecs.umich.edu#else 6398750Sgblack@eecs.umich.edu SparcFaultBase::invoke(tc, inst); 6408750Sgblack@eecs.umich.edu#endif 6414997Sgblack@eecs.umich.edu} 6424997Sgblack@eecs.umich.edu 6437741Sgblack@eecs.umich.eduvoid 6447741Sgblack@eecs.umich.eduFastDataAccessMMUMiss::invoke(ThreadContext *tc, StaticInstPtr inst) 6454997Sgblack@eecs.umich.edu{ 6468750Sgblack@eecs.umich.edu#if !FULL_SYSTEM 6474997Sgblack@eecs.umich.edu Process *p = tc->getProcessPtr(); 6485184Sgblack@eecs.umich.edu TlbEntry entry; 6495184Sgblack@eecs.umich.edu bool success = p->pTable->lookup(vaddr, entry); 6507741Sgblack@eecs.umich.edu if (!success) { 6518539Sgblack@eecs.umich.edu if (p->fixupStackFault(vaddr)) 6528539Sgblack@eecs.umich.edu success = p->pTable->lookup(vaddr, entry); 6534997Sgblack@eecs.umich.edu } 6547741Sgblack@eecs.umich.edu if (!success) { 6554997Sgblack@eecs.umich.edu panic("Tried to access unmapped address %#x.\n", vaddr); 6564997Sgblack@eecs.umich.edu } else { 6574997Sgblack@eecs.umich.edu Addr alignedVaddr = p->pTable->pageAlign(vaddr); 6584997Sgblack@eecs.umich.edu tc->getDTBPtr()->insert(alignedVaddr, 0 /*partition id*/, 6595184Sgblack@eecs.umich.edu p->M5_pid /*context id*/, false, entry.pte); 6604997Sgblack@eecs.umich.edu } 6618750Sgblack@eecs.umich.edu#else 6628750Sgblack@eecs.umich.edu SparcFaultBase::invoke(tc, inst); 6638750Sgblack@eecs.umich.edu#endif 6644997Sgblack@eecs.umich.edu} 6654997Sgblack@eecs.umich.edu 6667741Sgblack@eecs.umich.eduvoid 6677741Sgblack@eecs.umich.eduSpillNNormal::invoke(ThreadContext *tc, StaticInstPtr inst) 6683415Sgblack@eecs.umich.edu{ 6698750Sgblack@eecs.umich.edu#if !FULL_SYSTEM 6703578Sgblack@eecs.umich.edu doNormalFault(tc, trapType(), false); 6713415Sgblack@eecs.umich.edu 6723415Sgblack@eecs.umich.edu Process *p = tc->getProcessPtr(); 6733415Sgblack@eecs.umich.edu 6743578Sgblack@eecs.umich.edu //XXX This will only work in faults from a SparcLiveProcess 6753415Sgblack@eecs.umich.edu SparcLiveProcess *lp = dynamic_cast<SparcLiveProcess *>(p); 6763415Sgblack@eecs.umich.edu assert(lp); 6773415Sgblack@eecs.umich.edu 6787741Sgblack@eecs.umich.edu // Then adjust the PC and NPC 6797720Sgblack@eecs.umich.edu tc->pcState(lp->readSpillStart()); 6808750Sgblack@eecs.umich.edu#else 6818750Sgblack@eecs.umich.edu SparcFaultBase::invoke(tc, inst); 6828750Sgblack@eecs.umich.edu#endif 6833415Sgblack@eecs.umich.edu} 6843415Sgblack@eecs.umich.edu 6857741Sgblack@eecs.umich.eduvoid 6867741Sgblack@eecs.umich.eduFillNNormal::invoke(ThreadContext *tc, StaticInstPtr inst) 6873415Sgblack@eecs.umich.edu{ 6888750Sgblack@eecs.umich.edu#if !FULL_SYSTEM 6893578Sgblack@eecs.umich.edu doNormalFault(tc, trapType(), false); 6903415Sgblack@eecs.umich.edu 6917741Sgblack@eecs.umich.edu Process *p = tc->getProcessPtr(); 6923415Sgblack@eecs.umich.edu 6933578Sgblack@eecs.umich.edu //XXX This will only work in faults from a SparcLiveProcess 6943415Sgblack@eecs.umich.edu SparcLiveProcess *lp = dynamic_cast<SparcLiveProcess *>(p); 6953415Sgblack@eecs.umich.edu assert(lp); 6963415Sgblack@eecs.umich.edu 6977741Sgblack@eecs.umich.edu // Then adjust the PC and NPC 6987720Sgblack@eecs.umich.edu tc->pcState(lp->readFillStart()); 6998750Sgblack@eecs.umich.edu#else 7008750Sgblack@eecs.umich.edu SparcFaultBase::invoke(tc, inst); 7018750Sgblack@eecs.umich.edu#endif 7023415Sgblack@eecs.umich.edu} 7033415Sgblack@eecs.umich.edu 7047741Sgblack@eecs.umich.eduvoid 7057741Sgblack@eecs.umich.eduTrapInstruction::invoke(ThreadContext *tc, StaticInstPtr inst) 7064111Sgblack@eecs.umich.edu{ 7078750Sgblack@eecs.umich.edu#if !FULL_SYSTEM 7087741Sgblack@eecs.umich.edu // In SE, this mechanism is how the process requests a service from the 7097741Sgblack@eecs.umich.edu // operating system. We'll get the process object from the thread context 7107741Sgblack@eecs.umich.edu // and let it service the request. 7114111Sgblack@eecs.umich.edu 7124111Sgblack@eecs.umich.edu Process *p = tc->getProcessPtr(); 7134111Sgblack@eecs.umich.edu 7144111Sgblack@eecs.umich.edu SparcLiveProcess *lp = dynamic_cast<SparcLiveProcess *>(p); 7154111Sgblack@eecs.umich.edu assert(lp); 7164111Sgblack@eecs.umich.edu 7174111Sgblack@eecs.umich.edu lp->handleTrap(_n, tc); 7184111Sgblack@eecs.umich.edu 7197741Sgblack@eecs.umich.edu // We need to explicitly advance the pc, since that's not done for us 7207741Sgblack@eecs.umich.edu // on a faulting instruction 7217720Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 7227720Sgblack@eecs.umich.edu pc.advance(); 7237720Sgblack@eecs.umich.edu tc->pcState(pc); 7248750Sgblack@eecs.umich.edu#else 7258750Sgblack@eecs.umich.edu SparcFaultBase::invoke(tc, inst); 7268750Sgblack@eecs.umich.edu#endif 7274111Sgblack@eecs.umich.edu} 7284111Sgblack@eecs.umich.edu 7292223SN/A} // namespace SparcISA 7302221SN/A 731