14776SN/A/*
26365Sgblack@eecs.umich.edu * Copyright (c) 2006 The Regents of The University of Michigan
34776SN/A * All rights reserved.
44776SN/A *
54776SN/A * Redistribution and use in source and binary forms, with or without
64776SN/A * modification, are permitted provided that the following conditions are
74776SN/A * met: redistributions of source code must retain the above copyright
84776SN/A * notice, this list of conditions and the following disclaimer;
94776SN/A * redistributions in binary form must reproduce the above copyright
104776SN/A * notice, this list of conditions and the following disclaimer in the
114776SN/A * documentation and/or other materials provided with the distribution;
124776SN/A * neither the name of the copyright holders nor the names of its
134776SN/A * contributors may be used to endorse or promote products derived from
144776SN/A * this software without specific prior written permission.
154776SN/A *
164776SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174776SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184776SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194776SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204776SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214776SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224776SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234776SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244776SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254776SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264776SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274776SN/A *
286365Sgblack@eecs.umich.edu * Authors: Gabe Black
294776SN/A */
304776SN/A
3111793Sbrandon.potter@amd.com#include "arch/sparc/nativetrace.hh"
3211793Sbrandon.potter@amd.com
336365Sgblack@eecs.umich.edu#include "arch/sparc/isa_traits.hh"
346365Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh"
354776SN/A#include "cpu/thread_context.hh"
366365Sgblack@eecs.umich.edu#include "params/SparcNativeTrace.hh"
377678Sgblack@eecs.umich.edu#include "sim/byteswap.hh"
384776SN/A
394776SN/Anamespace Trace {
404776SN/A
416388Sgblack@eecs.umich.edustatic const char *intRegNames[SparcISA::NumIntArchRegs] = {
427741Sgblack@eecs.umich.edu    // Global registers
436365Sgblack@eecs.umich.edu    "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
447741Sgblack@eecs.umich.edu    // Output registers
456365Sgblack@eecs.umich.edu    "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7",
467741Sgblack@eecs.umich.edu    // Local registers
476365Sgblack@eecs.umich.edu    "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
487741Sgblack@eecs.umich.edu    // Input registers
496365Sgblack@eecs.umich.edu    "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
506365Sgblack@eecs.umich.edu};
516365Sgblack@eecs.umich.edu
526365Sgblack@eecs.umich.eduvoid
536365Sgblack@eecs.umich.eduTrace::SparcNativeTrace::check(NativeTraceRecord *record)
544776SN/A{
556365Sgblack@eecs.umich.edu    ThreadContext *tc = record->getThread();
565523SN/A
576365Sgblack@eecs.umich.edu    uint64_t regVal, realRegVal;
586365Sgblack@eecs.umich.edu
596365Sgblack@eecs.umich.edu    // Integer registers
606365Sgblack@eecs.umich.edu
616365Sgblack@eecs.umich.edu    // I doubt a real SPARC will describe more integer registers than this.
626365Sgblack@eecs.umich.edu    assert(SparcISA::NumIntArchRegs == 32);
636388Sgblack@eecs.umich.edu    const char **regName = intRegNames;
646365Sgblack@eecs.umich.edu    for (int i = 0; i < SparcISA::NumIntArchRegs; i++) {
656365Sgblack@eecs.umich.edu        regVal = tc->readIntReg(i);
666365Sgblack@eecs.umich.edu        read(&realRegVal, sizeof(realRegVal));
676365Sgblack@eecs.umich.edu        realRegVal = SparcISA::gtoh(realRegVal);
686365Sgblack@eecs.umich.edu        checkReg(*(regName++), regVal, realRegVal);
694776SN/A    }
706365Sgblack@eecs.umich.edu
717720Sgblack@eecs.umich.edu    SparcISA::PCState pc = tc->pcState();
726365Sgblack@eecs.umich.edu    // PC
736365Sgblack@eecs.umich.edu    read(&realRegVal, sizeof(realRegVal));
746365Sgblack@eecs.umich.edu    realRegVal = SparcISA::gtoh(realRegVal);
757720Sgblack@eecs.umich.edu    regVal = pc.npc();
766365Sgblack@eecs.umich.edu    checkReg("pc", regVal, realRegVal);
776365Sgblack@eecs.umich.edu
786365Sgblack@eecs.umich.edu    // NPC
796365Sgblack@eecs.umich.edu    read(&realRegVal, sizeof(realRegVal));
806365Sgblack@eecs.umich.edu    realRegVal = SparcISA::gtoh(realRegVal);
817720Sgblack@eecs.umich.edu    pc.nnpc();
826365Sgblack@eecs.umich.edu    checkReg("npc", regVal, realRegVal);
836365Sgblack@eecs.umich.edu
846365Sgblack@eecs.umich.edu    // CCR
856365Sgblack@eecs.umich.edu    read(&realRegVal, sizeof(realRegVal));
866365Sgblack@eecs.umich.edu    realRegVal = SparcISA::gtoh(realRegVal);
876365Sgblack@eecs.umich.edu    regVal = tc->readIntReg(SparcISA::NumIntArchRegs + 2);
886365Sgblack@eecs.umich.edu    checkReg("ccr", regVal, realRegVal);
894776SN/A}
904776SN/A
917811Ssteve.reinhardt@amd.com} // namespace Trace
924776SN/A
934776SN/A////////////////////////////////////////////////////////////////////////
944776SN/A//
954776SN/A//  ExeTracer Simulation Object
964776SN/A//
976365Sgblack@eecs.umich.eduTrace::SparcNativeTrace *
986365Sgblack@eecs.umich.eduSparcNativeTraceParams::create()
994776SN/A{
1006365Sgblack@eecs.umich.edu    return new Trace::SparcNativeTrace(this);
1014776SN/A};
102