isa.cc revision 8284
16313Sgblack@eecs.umich.edu/*
26313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan
36313Sgblack@eecs.umich.edu * All rights reserved.
46313Sgblack@eecs.umich.edu *
56313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
66313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
76313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
86313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
96313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
106313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
116313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
126313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
136313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
146313Sgblack@eecs.umich.edu * this software without specific prior written permission.
156313Sgblack@eecs.umich.edu *
166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276313Sgblack@eecs.umich.edu *
286313Sgblack@eecs.umich.edu * Authors: Gabe Black
296313Sgblack@eecs.umich.edu */
306313Sgblack@eecs.umich.edu
316335Sgblack@eecs.umich.edu#include "arch/sparc/asi.hh"
326313Sgblack@eecs.umich.edu#include "arch/sparc/isa.hh"
336335Sgblack@eecs.umich.edu#include "base/bitfield.hh"
346335Sgblack@eecs.umich.edu#include "base/trace.hh"
356335Sgblack@eecs.umich.edu#include "config/full_system.hh"
366335Sgblack@eecs.umich.edu#include "cpu/base.hh"
376313Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
388232Snate@binkert.org#include "debug/MiscRegs.hh"
398232Snate@binkert.org#include "debug/Timer.hh"
406313Sgblack@eecs.umich.edu
416313Sgblack@eecs.umich.edunamespace SparcISA
426313Sgblack@eecs.umich.edu{
436313Sgblack@eecs.umich.edu
446335Sgblack@eecs.umich.eduenum RegMask
456335Sgblack@eecs.umich.edu{
467741Sgblack@eecs.umich.edu    PSTATE_MASK = (((1 << 4) - 1) << 1) | (((1 << 4) - 1) << 6) | (1 << 12)
476335Sgblack@eecs.umich.edu};
486335Sgblack@eecs.umich.edu
496313Sgblack@eecs.umich.eduvoid
506337Sgblack@eecs.umich.eduISA::reloadRegMap()
516337Sgblack@eecs.umich.edu{
526337Sgblack@eecs.umich.edu    installGlobals(gl, CurrentGlobalsOffset);
536337Sgblack@eecs.umich.edu    installWindow(cwp, CurrentWindowOffset);
546337Sgblack@eecs.umich.edu    // Microcode registers.
556337Sgblack@eecs.umich.edu    for (int i = 0; i < NumMicroIntRegs; i++)
566337Sgblack@eecs.umich.edu        intRegMap[MicroIntOffset + i] = i + TotalGlobals + NWindows * 16;
576337Sgblack@eecs.umich.edu    installGlobals(gl, NextGlobalsOffset);
586337Sgblack@eecs.umich.edu    installWindow(cwp - 1, NextWindowOffset);
596337Sgblack@eecs.umich.edu    installGlobals(gl, PreviousGlobalsOffset);
606337Sgblack@eecs.umich.edu    installWindow(cwp + 1, PreviousWindowOffset);
616337Sgblack@eecs.umich.edu}
626337Sgblack@eecs.umich.edu
636337Sgblack@eecs.umich.eduvoid
646337Sgblack@eecs.umich.eduISA::installWindow(int cwp, int offset)
656337Sgblack@eecs.umich.edu{
666337Sgblack@eecs.umich.edu    assert(offset >= 0 && offset + NumWindowedRegs <= NumIntRegs);
676337Sgblack@eecs.umich.edu    RegIndex *mapChunk = intRegMap + offset;
686337Sgblack@eecs.umich.edu    for (int i = 0; i < NumWindowedRegs; i++)
696337Sgblack@eecs.umich.edu        mapChunk[i] = TotalGlobals +
706337Sgblack@eecs.umich.edu            ((i - cwp * RegsPerWindow + TotalWindowed) % (TotalWindowed));
716337Sgblack@eecs.umich.edu}
726337Sgblack@eecs.umich.edu
736337Sgblack@eecs.umich.eduvoid
746337Sgblack@eecs.umich.eduISA::installGlobals(int gl, int offset)
756337Sgblack@eecs.umich.edu{
766337Sgblack@eecs.umich.edu    assert(offset >= 0 && offset + NumGlobalRegs <= NumIntRegs);
776337Sgblack@eecs.umich.edu    RegIndex *mapChunk = intRegMap + offset;
786337Sgblack@eecs.umich.edu    mapChunk[0] = 0;
796337Sgblack@eecs.umich.edu    for (int i = 1; i < NumGlobalRegs; i++)
806337Sgblack@eecs.umich.edu        mapChunk[i] = i + gl * NumGlobalRegs;
816337Sgblack@eecs.umich.edu}
826337Sgblack@eecs.umich.edu
836337Sgblack@eecs.umich.eduvoid
846313Sgblack@eecs.umich.eduISA::clear()
856313Sgblack@eecs.umich.edu{
866337Sgblack@eecs.umich.edu    cwp = 0;
876337Sgblack@eecs.umich.edu    gl = 0;
886337Sgblack@eecs.umich.edu    reloadRegMap();
896337Sgblack@eecs.umich.edu
907741Sgblack@eecs.umich.edu    // y = 0;
917741Sgblack@eecs.umich.edu    // ccr = 0;
926335Sgblack@eecs.umich.edu    asi = 0;
936335Sgblack@eecs.umich.edu    tick = ULL(1) << 63;
946335Sgblack@eecs.umich.edu    fprs = 0;
956335Sgblack@eecs.umich.edu    gsr = 0;
966335Sgblack@eecs.umich.edu    softint = 0;
976335Sgblack@eecs.umich.edu    tick_cmpr = 0;
986335Sgblack@eecs.umich.edu    stick = 0;
996335Sgblack@eecs.umich.edu    stick_cmpr = 0;
1006335Sgblack@eecs.umich.edu    memset(tpc, 0, sizeof(tpc));
1016335Sgblack@eecs.umich.edu    memset(tnpc, 0, sizeof(tnpc));
1026335Sgblack@eecs.umich.edu    memset(tstate, 0, sizeof(tstate));
1036335Sgblack@eecs.umich.edu    memset(tt, 0, sizeof(tt));
1047703Sgblack@eecs.umich.edu    tba = 0;
1056335Sgblack@eecs.umich.edu    pstate = 0;
1066335Sgblack@eecs.umich.edu    tl = 0;
1076335Sgblack@eecs.umich.edu    pil = 0;
1087741Sgblack@eecs.umich.edu    // cansave = 0;
1097741Sgblack@eecs.umich.edu    // canrestore = 0;
1107741Sgblack@eecs.umich.edu    // cleanwin = 0;
1117741Sgblack@eecs.umich.edu    // otherwin = 0;
1127741Sgblack@eecs.umich.edu    // wstate = 0;
1137741Sgblack@eecs.umich.edu    // In a T1, bit 11 is apparently always 1
1146335Sgblack@eecs.umich.edu    hpstate = (1 << 11);
1156335Sgblack@eecs.umich.edu    memset(htstate, 0, sizeof(htstate));
1166335Sgblack@eecs.umich.edu    hintp = 0;
1176335Sgblack@eecs.umich.edu    htba = 0;
1186335Sgblack@eecs.umich.edu    hstick_cmpr = 0;
1197741Sgblack@eecs.umich.edu    // This is set this way in Legion for some reason
1206335Sgblack@eecs.umich.edu    strandStatusReg = 0x50000;
1216335Sgblack@eecs.umich.edu    fsr = 0;
1226335Sgblack@eecs.umich.edu
1236335Sgblack@eecs.umich.edu    priContext = 0;
1246335Sgblack@eecs.umich.edu    secContext = 0;
1256335Sgblack@eecs.umich.edu    partId = 0;
1266335Sgblack@eecs.umich.edu    lsuCtrlReg = 0;
1276335Sgblack@eecs.umich.edu
1286335Sgblack@eecs.umich.edu    memset(scratchPad, 0, sizeof(scratchPad));
1297703Sgblack@eecs.umich.edu
1307703Sgblack@eecs.umich.edu    cpu_mondo_head = 0;
1317703Sgblack@eecs.umich.edu    cpu_mondo_tail = 0;
1327703Sgblack@eecs.umich.edu    dev_mondo_head = 0;
1337703Sgblack@eecs.umich.edu    dev_mondo_tail = 0;
1347703Sgblack@eecs.umich.edu    res_error_head = 0;
1357703Sgblack@eecs.umich.edu    res_error_tail = 0;
1367703Sgblack@eecs.umich.edu    nres_error_head = 0;
1377703Sgblack@eecs.umich.edu    nres_error_tail = 0;
1387703Sgblack@eecs.umich.edu
1396335Sgblack@eecs.umich.edu#if FULL_SYSTEM
1407703Sgblack@eecs.umich.edu    // If one of these events is active, it's not obvious to me how to get
1417703Sgblack@eecs.umich.edu    // rid of it cleanly. For now we'll just assert that they're not.
1427703Sgblack@eecs.umich.edu    if (tickCompare != NULL && sTickCompare != NULL && hSTickCompare != NULL)
1437703Sgblack@eecs.umich.edu        panic("Tick comparison event active when clearing the ISA object.\n");
1446335Sgblack@eecs.umich.edu#endif
1456313Sgblack@eecs.umich.edu}
1466313Sgblack@eecs.umich.edu
1476313Sgblack@eecs.umich.eduMiscReg
1486313Sgblack@eecs.umich.eduISA::readMiscRegNoEffect(int miscReg)
1496313Sgblack@eecs.umich.edu{
1506335Sgblack@eecs.umich.edu
1516335Sgblack@eecs.umich.edu  // The three miscRegs are moved up from the switch statement
1526335Sgblack@eecs.umich.edu  // due to more frequent calls.
1536335Sgblack@eecs.umich.edu
1546335Sgblack@eecs.umich.edu  if (miscReg == MISCREG_GL)
1556335Sgblack@eecs.umich.edu    return gl;
1566335Sgblack@eecs.umich.edu  if (miscReg == MISCREG_CWP)
1576335Sgblack@eecs.umich.edu    return cwp;
1586335Sgblack@eecs.umich.edu  if (miscReg == MISCREG_TLB_DATA) {
1596335Sgblack@eecs.umich.edu    /* Package up all the data for the tlb:
1606335Sgblack@eecs.umich.edu     * 6666555555555544444444443333333333222222222211111111110000000000
1616335Sgblack@eecs.umich.edu     * 3210987654321098765432109876543210987654321098765432109876543210
1626335Sgblack@eecs.umich.edu     *   secContext   | priContext    |             |tl|partid|  |||||^hpriv
1636335Sgblack@eecs.umich.edu     *                                                           ||||^red
1646335Sgblack@eecs.umich.edu     *                                                           |||^priv
1656335Sgblack@eecs.umich.edu     *                                                           ||^am
1666335Sgblack@eecs.umich.edu     *                                                           |^lsuim
1676335Sgblack@eecs.umich.edu     *                                                           ^lsudm
1686335Sgblack@eecs.umich.edu     */
1696335Sgblack@eecs.umich.edu    return bits((uint64_t)hpstate,2,2) |
1706335Sgblack@eecs.umich.edu           bits((uint64_t)hpstate,5,5) << 1 |
1716335Sgblack@eecs.umich.edu           bits((uint64_t)pstate,3,2) << 2 |
1726335Sgblack@eecs.umich.edu           bits((uint64_t)lsuCtrlReg,3,2) << 4 |
1736335Sgblack@eecs.umich.edu           bits((uint64_t)partId,7,0) << 8 |
1746335Sgblack@eecs.umich.edu           bits((uint64_t)tl,2,0) << 16 |
1756335Sgblack@eecs.umich.edu                (uint64_t)priContext << 32 |
1766335Sgblack@eecs.umich.edu                (uint64_t)secContext << 48;
1776335Sgblack@eecs.umich.edu  }
1786335Sgblack@eecs.umich.edu
1796335Sgblack@eecs.umich.edu    switch (miscReg) {
1807741Sgblack@eecs.umich.edu      // case MISCREG_TLB_DATA:
1816335Sgblack@eecs.umich.edu      //  [original contents see above]
1827741Sgblack@eecs.umich.edu      // case MISCREG_Y:
1836335Sgblack@eecs.umich.edu      //  return y;
1847741Sgblack@eecs.umich.edu      // case MISCREG_CCR:
1856335Sgblack@eecs.umich.edu      //  return ccr;
1866335Sgblack@eecs.umich.edu      case MISCREG_ASI:
1876335Sgblack@eecs.umich.edu        return asi;
1886335Sgblack@eecs.umich.edu      case MISCREG_FPRS:
1896335Sgblack@eecs.umich.edu        return fprs;
1906335Sgblack@eecs.umich.edu      case MISCREG_TICK:
1916335Sgblack@eecs.umich.edu        return tick;
1926335Sgblack@eecs.umich.edu      case MISCREG_PCR:
1936335Sgblack@eecs.umich.edu        panic("PCR not implemented\n");
1946335Sgblack@eecs.umich.edu      case MISCREG_PIC:
1956335Sgblack@eecs.umich.edu        panic("PIC not implemented\n");
1966335Sgblack@eecs.umich.edu      case MISCREG_GSR:
1976335Sgblack@eecs.umich.edu        return gsr;
1986335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT:
1996335Sgblack@eecs.umich.edu        return softint;
2006335Sgblack@eecs.umich.edu      case MISCREG_TICK_CMPR:
2016335Sgblack@eecs.umich.edu        return tick_cmpr;
2026335Sgblack@eecs.umich.edu      case MISCREG_STICK:
2036335Sgblack@eecs.umich.edu        return stick;
2046335Sgblack@eecs.umich.edu      case MISCREG_STICK_CMPR:
2056335Sgblack@eecs.umich.edu        return stick_cmpr;
2066335Sgblack@eecs.umich.edu
2076335Sgblack@eecs.umich.edu        /** Privilged Registers */
2086335Sgblack@eecs.umich.edu      case MISCREG_TPC:
2096335Sgblack@eecs.umich.edu        return tpc[tl-1];
2106335Sgblack@eecs.umich.edu      case MISCREG_TNPC:
2116335Sgblack@eecs.umich.edu        return tnpc[tl-1];
2126335Sgblack@eecs.umich.edu      case MISCREG_TSTATE:
2136335Sgblack@eecs.umich.edu        return tstate[tl-1];
2146335Sgblack@eecs.umich.edu      case MISCREG_TT:
2156335Sgblack@eecs.umich.edu        return tt[tl-1];
2166335Sgblack@eecs.umich.edu      case MISCREG_PRIVTICK:
2176335Sgblack@eecs.umich.edu        panic("Priviliged access to tick registers not implemented\n");
2186335Sgblack@eecs.umich.edu      case MISCREG_TBA:
2196335Sgblack@eecs.umich.edu        return tba;
2206335Sgblack@eecs.umich.edu      case MISCREG_PSTATE:
2216335Sgblack@eecs.umich.edu        return pstate;
2226335Sgblack@eecs.umich.edu      case MISCREG_TL:
2236335Sgblack@eecs.umich.edu        return tl;
2246335Sgblack@eecs.umich.edu      case MISCREG_PIL:
2256335Sgblack@eecs.umich.edu        return pil;
2267741Sgblack@eecs.umich.edu      // CWP, GL moved
2277741Sgblack@eecs.umich.edu      // case MISCREG_CWP:
2287741Sgblack@eecs.umich.edu      //   return cwp;
2297741Sgblack@eecs.umich.edu      // case MISCREG_CANSAVE:
2307741Sgblack@eecs.umich.edu      //   return cansave;
2317741Sgblack@eecs.umich.edu      // case MISCREG_CANRESTORE:
2327741Sgblack@eecs.umich.edu      //   return canrestore;
2337741Sgblack@eecs.umich.edu      // case MISCREG_CLEANWIN:
2347741Sgblack@eecs.umich.edu      //   return cleanwin;
2357741Sgblack@eecs.umich.edu      // case MISCREG_OTHERWIN:
2367741Sgblack@eecs.umich.edu      //   return otherwin;
2377741Sgblack@eecs.umich.edu      // case MISCREG_WSTATE:
2387741Sgblack@eecs.umich.edu      //   return wstate;
2397741Sgblack@eecs.umich.edu      // case MISCREG_GL:
2407741Sgblack@eecs.umich.edu      //   return gl;
2416335Sgblack@eecs.umich.edu
2426335Sgblack@eecs.umich.edu        /** Hyper privileged registers */
2436335Sgblack@eecs.umich.edu      case MISCREG_HPSTATE:
2446335Sgblack@eecs.umich.edu        return hpstate;
2456335Sgblack@eecs.umich.edu      case MISCREG_HTSTATE:
2466335Sgblack@eecs.umich.edu        return htstate[tl-1];
2476335Sgblack@eecs.umich.edu      case MISCREG_HINTP:
2486335Sgblack@eecs.umich.edu        return hintp;
2496335Sgblack@eecs.umich.edu      case MISCREG_HTBA:
2506335Sgblack@eecs.umich.edu        return htba;
2516335Sgblack@eecs.umich.edu      case MISCREG_STRAND_STS_REG:
2526335Sgblack@eecs.umich.edu        return strandStatusReg;
2536335Sgblack@eecs.umich.edu      case MISCREG_HSTICK_CMPR:
2546335Sgblack@eecs.umich.edu        return hstick_cmpr;
2556335Sgblack@eecs.umich.edu
2566335Sgblack@eecs.umich.edu        /** Floating Point Status Register */
2576335Sgblack@eecs.umich.edu      case MISCREG_FSR:
2586335Sgblack@eecs.umich.edu        DPRINTF(MiscRegs, "FSR read as: %#x\n", fsr);
2596335Sgblack@eecs.umich.edu        return fsr;
2606335Sgblack@eecs.umich.edu
2616335Sgblack@eecs.umich.edu      case MISCREG_MMU_P_CONTEXT:
2626335Sgblack@eecs.umich.edu        return priContext;
2636335Sgblack@eecs.umich.edu      case MISCREG_MMU_S_CONTEXT:
2646335Sgblack@eecs.umich.edu        return secContext;
2656335Sgblack@eecs.umich.edu      case MISCREG_MMU_PART_ID:
2666335Sgblack@eecs.umich.edu        return partId;
2676335Sgblack@eecs.umich.edu      case MISCREG_MMU_LSU_CTRL:
2686335Sgblack@eecs.umich.edu        return lsuCtrlReg;
2696335Sgblack@eecs.umich.edu
2706335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R0:
2716335Sgblack@eecs.umich.edu        return scratchPad[0];
2726335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R1:
2736335Sgblack@eecs.umich.edu        return scratchPad[1];
2746335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R2:
2756335Sgblack@eecs.umich.edu        return scratchPad[2];
2766335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R3:
2776335Sgblack@eecs.umich.edu        return scratchPad[3];
2786335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R4:
2796335Sgblack@eecs.umich.edu        return scratchPad[4];
2806335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R5:
2816335Sgblack@eecs.umich.edu        return scratchPad[5];
2826335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R6:
2836335Sgblack@eecs.umich.edu        return scratchPad[6];
2846335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R7:
2856335Sgblack@eecs.umich.edu        return scratchPad[7];
2866335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_HEAD:
2876335Sgblack@eecs.umich.edu        return cpu_mondo_head;
2886335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_TAIL:
2896335Sgblack@eecs.umich.edu        return cpu_mondo_tail;
2906335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_HEAD:
2916335Sgblack@eecs.umich.edu        return dev_mondo_head;
2926335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_TAIL:
2936335Sgblack@eecs.umich.edu        return dev_mondo_tail;
2946335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_HEAD:
2956335Sgblack@eecs.umich.edu        return res_error_head;
2966335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_TAIL:
2976335Sgblack@eecs.umich.edu        return res_error_tail;
2986335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_HEAD:
2996335Sgblack@eecs.umich.edu        return nres_error_head;
3006335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_TAIL:
3016335Sgblack@eecs.umich.edu        return nres_error_tail;
3026335Sgblack@eecs.umich.edu      default:
3036335Sgblack@eecs.umich.edu        panic("Miscellaneous register %d not implemented\n", miscReg);
3046335Sgblack@eecs.umich.edu    }
3056313Sgblack@eecs.umich.edu}
3066313Sgblack@eecs.umich.edu
3076313Sgblack@eecs.umich.eduMiscReg
3086335Sgblack@eecs.umich.eduISA::readMiscReg(int miscReg, ThreadContext * tc)
3096313Sgblack@eecs.umich.edu{
3106335Sgblack@eecs.umich.edu    switch (miscReg) {
3116335Sgblack@eecs.umich.edu        // tick and stick are aliased to each other in niagra
3126335Sgblack@eecs.umich.edu        // well store the tick data in stick and the interrupt bit in tick
3136335Sgblack@eecs.umich.edu      case MISCREG_STICK:
3146335Sgblack@eecs.umich.edu      case MISCREG_TICK:
3156335Sgblack@eecs.umich.edu      case MISCREG_PRIVTICK:
3166335Sgblack@eecs.umich.edu        // I'm not sure why legion ignores the lowest two bits, but we'll go
3176335Sgblack@eecs.umich.edu        // with it
3186335Sgblack@eecs.umich.edu        // change from curCycle() to instCount() until we're done with legion
3196335Sgblack@eecs.umich.edu        DPRINTF(Timer, "Instruction Count when TICK read: %#X stick=%#X\n",
3206335Sgblack@eecs.umich.edu                tc->getCpuPtr()->instCount(), stick);
3216335Sgblack@eecs.umich.edu        return mbits(tc->getCpuPtr()->instCount() + (int64_t)stick,62,2) |
3226335Sgblack@eecs.umich.edu               mbits(tick,63,63);
3236335Sgblack@eecs.umich.edu      case MISCREG_FPRS:
3246335Sgblack@eecs.umich.edu        // in legion if fp is enabled du and dl are set
3256335Sgblack@eecs.umich.edu        return fprs | 0x3;
3266335Sgblack@eecs.umich.edu      case MISCREG_PCR:
3276335Sgblack@eecs.umich.edu      case MISCREG_PIC:
3286335Sgblack@eecs.umich.edu        panic("Performance Instrumentation not impl\n");
3296335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT_CLR:
3306335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT_SET:
3316335Sgblack@eecs.umich.edu        panic("Can read from softint clr/set\n");
3326335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT:
3336335Sgblack@eecs.umich.edu      case MISCREG_TICK_CMPR:
3346335Sgblack@eecs.umich.edu      case MISCREG_STICK_CMPR:
3356335Sgblack@eecs.umich.edu      case MISCREG_HINTP:
3366335Sgblack@eecs.umich.edu      case MISCREG_HTSTATE:
3376335Sgblack@eecs.umich.edu      case MISCREG_HTBA:
3386335Sgblack@eecs.umich.edu      case MISCREG_HVER:
3396335Sgblack@eecs.umich.edu      case MISCREG_STRAND_STS_REG:
3406335Sgblack@eecs.umich.edu      case MISCREG_HSTICK_CMPR:
3416335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_HEAD:
3426335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_TAIL:
3436335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_HEAD:
3446335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_TAIL:
3456335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_HEAD:
3466335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_TAIL:
3476335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_HEAD:
3486335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_TAIL:
3496335Sgblack@eecs.umich.edu#if FULL_SYSTEM
3506335Sgblack@eecs.umich.edu      case MISCREG_HPSTATE:
3516335Sgblack@eecs.umich.edu        return readFSReg(miscReg, tc);
3526335Sgblack@eecs.umich.edu#else
3536335Sgblack@eecs.umich.edu      case MISCREG_HPSTATE:
3547741Sgblack@eecs.umich.edu        // HPSTATE is special because because sometimes in privilege
3557741Sgblack@eecs.umich.edu        // checks for instructions it will read HPSTATE to make sure
3567741Sgblack@eecs.umich.edu        // the priv. level is ok So, we'll just have to tell it it
3577741Sgblack@eecs.umich.edu        // isn't, instead of panicing.
3586335Sgblack@eecs.umich.edu        return 0;
3596335Sgblack@eecs.umich.edu
3606335Sgblack@eecs.umich.edu      panic("Accessing Fullsystem register %d in SE mode\n", miscReg);
3616335Sgblack@eecs.umich.edu#endif
3626335Sgblack@eecs.umich.edu
3636335Sgblack@eecs.umich.edu    }
3646335Sgblack@eecs.umich.edu    return readMiscRegNoEffect(miscReg);
3656313Sgblack@eecs.umich.edu}
3666313Sgblack@eecs.umich.edu
3676313Sgblack@eecs.umich.eduvoid
3686335Sgblack@eecs.umich.eduISA::setMiscRegNoEffect(int miscReg, MiscReg val)
3696313Sgblack@eecs.umich.edu{
3706335Sgblack@eecs.umich.edu    switch (miscReg) {
3716335Sgblack@eecs.umich.edu//      case MISCREG_Y:
3726335Sgblack@eecs.umich.edu//        y = val;
3736335Sgblack@eecs.umich.edu//        break;
3746335Sgblack@eecs.umich.edu//      case MISCREG_CCR:
3756335Sgblack@eecs.umich.edu//        ccr = val;
3766335Sgblack@eecs.umich.edu//        break;
3776335Sgblack@eecs.umich.edu      case MISCREG_ASI:
3786335Sgblack@eecs.umich.edu        asi = val;
3796335Sgblack@eecs.umich.edu        break;
3806335Sgblack@eecs.umich.edu      case MISCREG_FPRS:
3816335Sgblack@eecs.umich.edu        fprs = val;
3826335Sgblack@eecs.umich.edu        break;
3836335Sgblack@eecs.umich.edu      case MISCREG_TICK:
3846335Sgblack@eecs.umich.edu        tick = val;
3856335Sgblack@eecs.umich.edu        break;
3866335Sgblack@eecs.umich.edu      case MISCREG_PCR:
3876335Sgblack@eecs.umich.edu        panic("PCR not implemented\n");
3886335Sgblack@eecs.umich.edu      case MISCREG_PIC:
3896335Sgblack@eecs.umich.edu        panic("PIC not implemented\n");
3906335Sgblack@eecs.umich.edu      case MISCREG_GSR:
3916335Sgblack@eecs.umich.edu        gsr = val;
3926335Sgblack@eecs.umich.edu        break;
3936335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT:
3946335Sgblack@eecs.umich.edu        softint = val;
3956335Sgblack@eecs.umich.edu        break;
3966335Sgblack@eecs.umich.edu      case MISCREG_TICK_CMPR:
3976335Sgblack@eecs.umich.edu        tick_cmpr = val;
3986335Sgblack@eecs.umich.edu        break;
3996335Sgblack@eecs.umich.edu      case MISCREG_STICK:
4006335Sgblack@eecs.umich.edu        stick = val;
4016335Sgblack@eecs.umich.edu        break;
4026335Sgblack@eecs.umich.edu      case MISCREG_STICK_CMPR:
4036335Sgblack@eecs.umich.edu        stick_cmpr = val;
4046335Sgblack@eecs.umich.edu        break;
4056335Sgblack@eecs.umich.edu
4066335Sgblack@eecs.umich.edu        /** Privilged Registers */
4076335Sgblack@eecs.umich.edu      case MISCREG_TPC:
4086335Sgblack@eecs.umich.edu        tpc[tl-1] = val;
4096335Sgblack@eecs.umich.edu        break;
4106335Sgblack@eecs.umich.edu      case MISCREG_TNPC:
4116335Sgblack@eecs.umich.edu        tnpc[tl-1] = val;
4126335Sgblack@eecs.umich.edu        break;
4136335Sgblack@eecs.umich.edu      case MISCREG_TSTATE:
4146335Sgblack@eecs.umich.edu        tstate[tl-1] = val;
4156335Sgblack@eecs.umich.edu        break;
4166335Sgblack@eecs.umich.edu      case MISCREG_TT:
4176335Sgblack@eecs.umich.edu        tt[tl-1] = val;
4186335Sgblack@eecs.umich.edu        break;
4196335Sgblack@eecs.umich.edu      case MISCREG_PRIVTICK:
4206335Sgblack@eecs.umich.edu        panic("Priviliged access to tick regesiters not implemented\n");
4216335Sgblack@eecs.umich.edu      case MISCREG_TBA:
4226335Sgblack@eecs.umich.edu        // clear lower 7 bits on writes.
4236335Sgblack@eecs.umich.edu        tba = val & ULL(~0x7FFF);
4246335Sgblack@eecs.umich.edu        break;
4256335Sgblack@eecs.umich.edu      case MISCREG_PSTATE:
4266335Sgblack@eecs.umich.edu        pstate = (val & PSTATE_MASK);
4276335Sgblack@eecs.umich.edu        break;
4286335Sgblack@eecs.umich.edu      case MISCREG_TL:
4296335Sgblack@eecs.umich.edu        tl = val;
4306335Sgblack@eecs.umich.edu        break;
4316335Sgblack@eecs.umich.edu      case MISCREG_PIL:
4326335Sgblack@eecs.umich.edu        pil = val;
4336335Sgblack@eecs.umich.edu        break;
4346335Sgblack@eecs.umich.edu      case MISCREG_CWP:
4356335Sgblack@eecs.umich.edu        cwp = val;
4366335Sgblack@eecs.umich.edu        break;
4376335Sgblack@eecs.umich.edu//      case MISCREG_CANSAVE:
4386335Sgblack@eecs.umich.edu//        cansave = val;
4396335Sgblack@eecs.umich.edu//        break;
4406335Sgblack@eecs.umich.edu//      case MISCREG_CANRESTORE:
4416335Sgblack@eecs.umich.edu//        canrestore = val;
4426335Sgblack@eecs.umich.edu//        break;
4436335Sgblack@eecs.umich.edu//      case MISCREG_CLEANWIN:
4446335Sgblack@eecs.umich.edu//        cleanwin = val;
4456335Sgblack@eecs.umich.edu//        break;
4466335Sgblack@eecs.umich.edu//      case MISCREG_OTHERWIN:
4476335Sgblack@eecs.umich.edu//        otherwin = val;
4486335Sgblack@eecs.umich.edu//        break;
4496335Sgblack@eecs.umich.edu//      case MISCREG_WSTATE:
4506335Sgblack@eecs.umich.edu//        wstate = val;
4516335Sgblack@eecs.umich.edu//        break;
4526335Sgblack@eecs.umich.edu      case MISCREG_GL:
4536335Sgblack@eecs.umich.edu        gl = val;
4546335Sgblack@eecs.umich.edu        break;
4556335Sgblack@eecs.umich.edu
4566335Sgblack@eecs.umich.edu        /** Hyper privileged registers */
4576335Sgblack@eecs.umich.edu      case MISCREG_HPSTATE:
4586335Sgblack@eecs.umich.edu        hpstate = val;
4596335Sgblack@eecs.umich.edu        break;
4606335Sgblack@eecs.umich.edu      case MISCREG_HTSTATE:
4616335Sgblack@eecs.umich.edu        htstate[tl-1] = val;
4626335Sgblack@eecs.umich.edu        break;
4636335Sgblack@eecs.umich.edu      case MISCREG_HINTP:
4646335Sgblack@eecs.umich.edu        hintp = val;
4656335Sgblack@eecs.umich.edu      case MISCREG_HTBA:
4666335Sgblack@eecs.umich.edu        htba = val;
4676335Sgblack@eecs.umich.edu        break;
4686335Sgblack@eecs.umich.edu      case MISCREG_STRAND_STS_REG:
4696335Sgblack@eecs.umich.edu        strandStatusReg = val;
4706335Sgblack@eecs.umich.edu        break;
4716335Sgblack@eecs.umich.edu      case MISCREG_HSTICK_CMPR:
4726335Sgblack@eecs.umich.edu        hstick_cmpr = val;
4736335Sgblack@eecs.umich.edu        break;
4746335Sgblack@eecs.umich.edu
4756335Sgblack@eecs.umich.edu        /** Floating Point Status Register */
4766335Sgblack@eecs.umich.edu      case MISCREG_FSR:
4776335Sgblack@eecs.umich.edu        fsr = val;
4786335Sgblack@eecs.umich.edu        DPRINTF(MiscRegs, "FSR written with: %#x\n", fsr);
4796335Sgblack@eecs.umich.edu        break;
4806335Sgblack@eecs.umich.edu
4816335Sgblack@eecs.umich.edu      case MISCREG_MMU_P_CONTEXT:
4826335Sgblack@eecs.umich.edu        priContext = val;
4836335Sgblack@eecs.umich.edu        break;
4846335Sgblack@eecs.umich.edu      case MISCREG_MMU_S_CONTEXT:
4856335Sgblack@eecs.umich.edu        secContext = val;
4866335Sgblack@eecs.umich.edu        break;
4876335Sgblack@eecs.umich.edu      case MISCREG_MMU_PART_ID:
4886335Sgblack@eecs.umich.edu        partId = val;
4896335Sgblack@eecs.umich.edu        break;
4906335Sgblack@eecs.umich.edu      case MISCREG_MMU_LSU_CTRL:
4916335Sgblack@eecs.umich.edu        lsuCtrlReg = val;
4926335Sgblack@eecs.umich.edu        break;
4936335Sgblack@eecs.umich.edu
4946335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R0:
4956335Sgblack@eecs.umich.edu        scratchPad[0] = val;
4966335Sgblack@eecs.umich.edu        break;
4976335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R1:
4986335Sgblack@eecs.umich.edu        scratchPad[1] = val;
4996335Sgblack@eecs.umich.edu        break;
5006335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R2:
5016335Sgblack@eecs.umich.edu        scratchPad[2] = val;
5026335Sgblack@eecs.umich.edu        break;
5036335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R3:
5046335Sgblack@eecs.umich.edu        scratchPad[3] = val;
5056335Sgblack@eecs.umich.edu        break;
5066335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R4:
5076335Sgblack@eecs.umich.edu        scratchPad[4] = val;
5086335Sgblack@eecs.umich.edu        break;
5096335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R5:
5106335Sgblack@eecs.umich.edu        scratchPad[5] = val;
5116335Sgblack@eecs.umich.edu        break;
5126335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R6:
5136335Sgblack@eecs.umich.edu        scratchPad[6] = val;
5146335Sgblack@eecs.umich.edu        break;
5156335Sgblack@eecs.umich.edu      case MISCREG_SCRATCHPAD_R7:
5166335Sgblack@eecs.umich.edu        scratchPad[7] = val;
5176335Sgblack@eecs.umich.edu        break;
5186335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_HEAD:
5196335Sgblack@eecs.umich.edu        cpu_mondo_head = val;
5206335Sgblack@eecs.umich.edu        break;
5216335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_TAIL:
5226335Sgblack@eecs.umich.edu        cpu_mondo_tail = val;
5236335Sgblack@eecs.umich.edu        break;
5246335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_HEAD:
5256335Sgblack@eecs.umich.edu        dev_mondo_head = val;
5266335Sgblack@eecs.umich.edu        break;
5276335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_TAIL:
5286335Sgblack@eecs.umich.edu        dev_mondo_tail = val;
5296335Sgblack@eecs.umich.edu        break;
5306335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_HEAD:
5316335Sgblack@eecs.umich.edu        res_error_head = val;
5326335Sgblack@eecs.umich.edu        break;
5336335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_TAIL:
5346335Sgblack@eecs.umich.edu        res_error_tail = val;
5356335Sgblack@eecs.umich.edu        break;
5366335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_HEAD:
5376335Sgblack@eecs.umich.edu        nres_error_head = val;
5386335Sgblack@eecs.umich.edu        break;
5396335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_TAIL:
5406335Sgblack@eecs.umich.edu        nres_error_tail = val;
5416335Sgblack@eecs.umich.edu        break;
5426335Sgblack@eecs.umich.edu      default:
5436335Sgblack@eecs.umich.edu        panic("Miscellaneous register %d not implemented\n", miscReg);
5446335Sgblack@eecs.umich.edu    }
5456313Sgblack@eecs.umich.edu}
5466313Sgblack@eecs.umich.edu
5476313Sgblack@eecs.umich.eduvoid
5486335Sgblack@eecs.umich.eduISA::setMiscReg(int miscReg, MiscReg val, ThreadContext * tc)
5496313Sgblack@eecs.umich.edu{
5506335Sgblack@eecs.umich.edu    MiscReg new_val = val;
5516335Sgblack@eecs.umich.edu
5526335Sgblack@eecs.umich.edu    switch (miscReg) {
5536335Sgblack@eecs.umich.edu      case MISCREG_STICK:
5546335Sgblack@eecs.umich.edu      case MISCREG_TICK:
5556335Sgblack@eecs.umich.edu        // stick and tick are same thing on niagra
5566335Sgblack@eecs.umich.edu        // use stick for offset and tick for holding intrrupt bit
5576335Sgblack@eecs.umich.edu        stick = mbits(val,62,0) - tc->getCpuPtr()->instCount();
5586335Sgblack@eecs.umich.edu        tick = mbits(val,63,63);
5596335Sgblack@eecs.umich.edu        DPRINTF(Timer, "Writing TICK=%#X\n", val);
5606335Sgblack@eecs.umich.edu        break;
5616335Sgblack@eecs.umich.edu      case MISCREG_FPRS:
5627741Sgblack@eecs.umich.edu        // Configure the fpu based on the fprs
5636335Sgblack@eecs.umich.edu        break;
5646335Sgblack@eecs.umich.edu      case MISCREG_PCR:
5657741Sgblack@eecs.umich.edu        // Set up performance counting based on pcr value
5666335Sgblack@eecs.umich.edu        break;
5676335Sgblack@eecs.umich.edu      case MISCREG_PSTATE:
5686335Sgblack@eecs.umich.edu        pstate = val & PSTATE_MASK;
5696335Sgblack@eecs.umich.edu        return;
5706335Sgblack@eecs.umich.edu      case MISCREG_TL:
5716335Sgblack@eecs.umich.edu        tl = val;
5726335Sgblack@eecs.umich.edu#if FULL_SYSTEM
5736335Sgblack@eecs.umich.edu        if (hpstate & HPSTATE::tlz && tl == 0 && !(hpstate & HPSTATE::hpriv))
5746335Sgblack@eecs.umich.edu            tc->getCpuPtr()->postInterrupt(IT_TRAP_LEVEL_ZERO, 0);
5756335Sgblack@eecs.umich.edu        else
5766335Sgblack@eecs.umich.edu            tc->getCpuPtr()->clearInterrupt(IT_TRAP_LEVEL_ZERO, 0);
5776335Sgblack@eecs.umich.edu#endif
5786335Sgblack@eecs.umich.edu        return;
5796335Sgblack@eecs.umich.edu      case MISCREG_CWP:
5806335Sgblack@eecs.umich.edu        new_val = val >= NWindows ? NWindows - 1 : val;
5816335Sgblack@eecs.umich.edu        if (val >= NWindows)
5826335Sgblack@eecs.umich.edu            new_val = NWindows - 1;
5836337Sgblack@eecs.umich.edu
5846337Sgblack@eecs.umich.edu        installWindow(new_val, CurrentWindowOffset);
5856337Sgblack@eecs.umich.edu        installWindow(new_val - 1, NextWindowOffset);
5866337Sgblack@eecs.umich.edu        installWindow(new_val + 1, PreviousWindowOffset);
5876335Sgblack@eecs.umich.edu        break;
5886335Sgblack@eecs.umich.edu      case MISCREG_GL:
5896337Sgblack@eecs.umich.edu        installGlobals(val, CurrentGlobalsOffset);
5906337Sgblack@eecs.umich.edu        installGlobals(val, NextGlobalsOffset);
5916337Sgblack@eecs.umich.edu        installGlobals(val, PreviousGlobalsOffset);
5926335Sgblack@eecs.umich.edu        break;
5936335Sgblack@eecs.umich.edu      case MISCREG_PIL:
5946335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT:
5956335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT_SET:
5966335Sgblack@eecs.umich.edu      case MISCREG_SOFTINT_CLR:
5976335Sgblack@eecs.umich.edu      case MISCREG_TICK_CMPR:
5986335Sgblack@eecs.umich.edu      case MISCREG_STICK_CMPR:
5996335Sgblack@eecs.umich.edu      case MISCREG_HINTP:
6006335Sgblack@eecs.umich.edu      case MISCREG_HTSTATE:
6016335Sgblack@eecs.umich.edu      case MISCREG_HTBA:
6026335Sgblack@eecs.umich.edu      case MISCREG_HVER:
6036335Sgblack@eecs.umich.edu      case MISCREG_STRAND_STS_REG:
6046335Sgblack@eecs.umich.edu      case MISCREG_HSTICK_CMPR:
6056335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_HEAD:
6066335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_CPU_MONDO_TAIL:
6076335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_HEAD:
6086335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_DEV_MONDO_TAIL:
6096335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_HEAD:
6106335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_RES_ERROR_TAIL:
6116335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_HEAD:
6126335Sgblack@eecs.umich.edu      case MISCREG_QUEUE_NRES_ERROR_TAIL:
6136335Sgblack@eecs.umich.edu#if FULL_SYSTEM
6146335Sgblack@eecs.umich.edu      case MISCREG_HPSTATE:
6156335Sgblack@eecs.umich.edu        setFSReg(miscReg, val, tc);
6166335Sgblack@eecs.umich.edu        return;
6176335Sgblack@eecs.umich.edu#else
6186335Sgblack@eecs.umich.edu      case MISCREG_HPSTATE:
6197741Sgblack@eecs.umich.edu        // HPSTATE is special because normal trap processing saves HPSTATE when
6207741Sgblack@eecs.umich.edu        // it goes into a trap, and restores it when it returns.
6216335Sgblack@eecs.umich.edu        return;
6226335Sgblack@eecs.umich.edu      panic("Accessing Fullsystem register %d to %#x in SE mode\n",
6236335Sgblack@eecs.umich.edu              miscReg, val);
6246335Sgblack@eecs.umich.edu#endif
6256335Sgblack@eecs.umich.edu    }
6266335Sgblack@eecs.umich.edu    setMiscRegNoEffect(miscReg, new_val);
6276335Sgblack@eecs.umich.edu}
6286335Sgblack@eecs.umich.edu
6296335Sgblack@eecs.umich.eduvoid
6306335Sgblack@eecs.umich.eduISA::serialize(EventManager *em, std::ostream &os)
6316335Sgblack@eecs.umich.edu{
6326335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(asi);
6336335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(tick);
6346335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(fprs);
6356335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(gsr);
6366335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(softint);
6376335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(tick_cmpr);
6386335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(stick);
6396335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(stick_cmpr);
6406335Sgblack@eecs.umich.edu    SERIALIZE_ARRAY(tpc,MaxTL);
6416335Sgblack@eecs.umich.edu    SERIALIZE_ARRAY(tnpc,MaxTL);
6426335Sgblack@eecs.umich.edu    SERIALIZE_ARRAY(tstate,MaxTL);
6436335Sgblack@eecs.umich.edu    SERIALIZE_ARRAY(tt,MaxTL);
6446335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(tba);
6456335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(pstate);
6466335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(tl);
6476335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(pil);
6486335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(cwp);
6496335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(gl);
6506335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(hpstate);
6516335Sgblack@eecs.umich.edu    SERIALIZE_ARRAY(htstate,MaxTL);
6526335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(hintp);
6536335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(htba);
6546335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(hstick_cmpr);
6556335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(strandStatusReg);
6566335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(fsr);
6576335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(priContext);
6586335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(secContext);
6596335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(partId);
6606335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(lsuCtrlReg);
6616335Sgblack@eecs.umich.edu    SERIALIZE_ARRAY(scratchPad,8);
6626335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(cpu_mondo_head);
6636335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(cpu_mondo_tail);
6646335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(dev_mondo_head);
6656335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(dev_mondo_tail);
6666335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(res_error_head);
6676335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(res_error_tail);
6686335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(nres_error_head);
6696335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(nres_error_tail);
6706335Sgblack@eecs.umich.edu#if FULL_SYSTEM
6716335Sgblack@eecs.umich.edu    Tick tick_cmp = 0, stick_cmp = 0, hstick_cmp = 0;
6726335Sgblack@eecs.umich.edu    ThreadContext *tc = NULL;
6736335Sgblack@eecs.umich.edu    BaseCPU *cpu = NULL;
6746335Sgblack@eecs.umich.edu    int tc_num = 0;
6756335Sgblack@eecs.umich.edu    bool tick_intr_sched = true;
6766335Sgblack@eecs.umich.edu
6776335Sgblack@eecs.umich.edu    if (tickCompare)
6786335Sgblack@eecs.umich.edu        tc = tickCompare->getTC();
6796335Sgblack@eecs.umich.edu    else if (sTickCompare)
6806335Sgblack@eecs.umich.edu        tc = sTickCompare->getTC();
6816335Sgblack@eecs.umich.edu    else if (hSTickCompare)
6826335Sgblack@eecs.umich.edu        tc = hSTickCompare->getTC();
6836335Sgblack@eecs.umich.edu    else
6846335Sgblack@eecs.umich.edu        tick_intr_sched = false;
6856335Sgblack@eecs.umich.edu
6866335Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(tick_intr_sched);
6876335Sgblack@eecs.umich.edu
6886335Sgblack@eecs.umich.edu    if (tc) {
6896335Sgblack@eecs.umich.edu        cpu = tc->getCpuPtr();
6906335Sgblack@eecs.umich.edu        tc_num = cpu->findContext(tc);
6916335Sgblack@eecs.umich.edu        if (tickCompare && tickCompare->scheduled())
6926335Sgblack@eecs.umich.edu            tick_cmp = tickCompare->when();
6936335Sgblack@eecs.umich.edu        if (sTickCompare && sTickCompare->scheduled())
6946335Sgblack@eecs.umich.edu            stick_cmp = sTickCompare->when();
6956335Sgblack@eecs.umich.edu        if (hSTickCompare && hSTickCompare->scheduled())
6966335Sgblack@eecs.umich.edu            hstick_cmp = hSTickCompare->when();
6976335Sgblack@eecs.umich.edu
6986335Sgblack@eecs.umich.edu        SERIALIZE_OBJPTR(cpu);
6996335Sgblack@eecs.umich.edu        SERIALIZE_SCALAR(tc_num);
7006335Sgblack@eecs.umich.edu        SERIALIZE_SCALAR(tick_cmp);
7016335Sgblack@eecs.umich.edu        SERIALIZE_SCALAR(stick_cmp);
7026335Sgblack@eecs.umich.edu        SERIALIZE_SCALAR(hstick_cmp);
7036335Sgblack@eecs.umich.edu    }
7046335Sgblack@eecs.umich.edu#endif
7056335Sgblack@eecs.umich.edu}
7066335Sgblack@eecs.umich.edu
7076335Sgblack@eecs.umich.eduvoid
7086335Sgblack@eecs.umich.eduISA::unserialize(EventManager *em, Checkpoint *cp, const std::string &section)
7096335Sgblack@eecs.umich.edu{
7106335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(asi);
7116335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(tick);
7126335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(fprs);
7136335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(gsr);
7146335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(softint);
7156335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(tick_cmpr);
7166335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(stick);
7176335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(stick_cmpr);
7186335Sgblack@eecs.umich.edu    UNSERIALIZE_ARRAY(tpc,MaxTL);
7196335Sgblack@eecs.umich.edu    UNSERIALIZE_ARRAY(tnpc,MaxTL);
7206335Sgblack@eecs.umich.edu    UNSERIALIZE_ARRAY(tstate,MaxTL);
7216335Sgblack@eecs.umich.edu    UNSERIALIZE_ARRAY(tt,MaxTL);
7226335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(tba);
7236335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(pstate);
7246335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(tl);
7256335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(pil);
7266335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(cwp);
7276335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(gl);
7286337Sgblack@eecs.umich.edu    reloadRegMap();
7296335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(hpstate);
7306335Sgblack@eecs.umich.edu    UNSERIALIZE_ARRAY(htstate,MaxTL);
7316335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(hintp);
7326335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(htba);
7336335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(hstick_cmpr);
7346335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(strandStatusReg);
7356335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(fsr);
7366335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(priContext);
7376335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(secContext);
7386335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(partId);
7396335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(lsuCtrlReg);
7406335Sgblack@eecs.umich.edu    UNSERIALIZE_ARRAY(scratchPad,8);
7416335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(cpu_mondo_head);
7426335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(cpu_mondo_tail);
7436335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(dev_mondo_head);
7446335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(dev_mondo_tail);
7456335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(res_error_head);
7466335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(res_error_tail);
7476335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(nres_error_head);
7486335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(nres_error_tail);
7496335Sgblack@eecs.umich.edu
7506335Sgblack@eecs.umich.edu#if FULL_SYSTEM
7516335Sgblack@eecs.umich.edu    Tick tick_cmp = 0, stick_cmp = 0, hstick_cmp = 0;
7526335Sgblack@eecs.umich.edu    ThreadContext *tc = NULL;
7536335Sgblack@eecs.umich.edu    BaseCPU *cpu = NULL;
7546335Sgblack@eecs.umich.edu    int tc_num;
7556335Sgblack@eecs.umich.edu    bool tick_intr_sched;
7566335Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(tick_intr_sched);
7576335Sgblack@eecs.umich.edu    if (tick_intr_sched) {
7586335Sgblack@eecs.umich.edu        UNSERIALIZE_OBJPTR(cpu);
7596335Sgblack@eecs.umich.edu        if (cpu) {
7606335Sgblack@eecs.umich.edu            UNSERIALIZE_SCALAR(tc_num);
7616335Sgblack@eecs.umich.edu            UNSERIALIZE_SCALAR(tick_cmp);
7626335Sgblack@eecs.umich.edu            UNSERIALIZE_SCALAR(stick_cmp);
7636335Sgblack@eecs.umich.edu            UNSERIALIZE_SCALAR(hstick_cmp);
7646335Sgblack@eecs.umich.edu            tc = cpu->getContext(tc_num);
7656335Sgblack@eecs.umich.edu
7666335Sgblack@eecs.umich.edu            if (tick_cmp) {
7676335Sgblack@eecs.umich.edu                tickCompare = new TickCompareEvent(this, tc);
7686335Sgblack@eecs.umich.edu                em->schedule(tickCompare, tick_cmp);
7696335Sgblack@eecs.umich.edu            }
7706335Sgblack@eecs.umich.edu            if (stick_cmp)  {
7716335Sgblack@eecs.umich.edu                sTickCompare = new STickCompareEvent(this, tc);
7726335Sgblack@eecs.umich.edu                em->schedule(sTickCompare, stick_cmp);
7736335Sgblack@eecs.umich.edu            }
7746335Sgblack@eecs.umich.edu            if (hstick_cmp)  {
7756335Sgblack@eecs.umich.edu                hSTickCompare = new HSTickCompareEvent(this, tc);
7766335Sgblack@eecs.umich.edu                em->schedule(hSTickCompare, hstick_cmp);
7776335Sgblack@eecs.umich.edu            }
7786335Sgblack@eecs.umich.edu        }
7796335Sgblack@eecs.umich.edu    }
7806335Sgblack@eecs.umich.edu
7816335Sgblack@eecs.umich.edu #endif
7826313Sgblack@eecs.umich.edu}
7836313Sgblack@eecs.umich.edu
7846313Sgblack@eecs.umich.edu}
785