utility.hh revision 8829
16313Sgblack@eecs.umich.edu/*
212529Sgiacomo.travaglini@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
37093Sgblack@eecs.umich.edu * All rights reserved.
47093Sgblack@eecs.umich.edu *
57093Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67093Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77093Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97093Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117093Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127093Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137093Sgblack@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
316313Sgblack@eecs.umich.edu#ifndef __ARCH_SPARC_UTILITY_HH__
326313Sgblack@eecs.umich.edu#define __ARCH_SPARC_UTILITY_HH__
336313Sgblack@eecs.umich.edu
346313Sgblack@eecs.umich.edu#include "arch/sparc/isa_traits.hh"
356313Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh"
366313Sgblack@eecs.umich.edu#include "arch/sparc/tlb.hh"
376313Sgblack@eecs.umich.edu#include "base/bitfield.hh"
386313Sgblack@eecs.umich.edu#include "base/misc.hh"
396313Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
406313Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
416313Sgblack@eecs.umich.edu#include "sim/fault_fwd.hh"
426313Sgblack@eecs.umich.edu#include "sim/full_system.hh"
436313Sgblack@eecs.umich.edu
447404SAli.Saidi@ARM.comnamespace SparcISA
456313Sgblack@eecs.umich.edu{
4610461SAndreas.Sandberg@ARM.com
4712479SCurtis.Dunham@arm.cominline PCState
486333Sgblack@eecs.umich.edubuildRetPC(const PCState &curPC, const PCState &callPC)
4910037SARM gem5 Developers{
507404SAli.Saidi@ARM.com    PCState ret = callPC;
516313Sgblack@eecs.umich.edu    ret.uEnd();
5212109SRekai.GonzalezAlberquilla@arm.com    ret.pc(curPC.npc());
538232Snate@binkert.org    return ret;
5412109SRekai.GonzalezAlberquilla@arm.com}
559384SAndreas.Sandberg@arm.com
5611165SRekai.GonzalezAlberquilla@arm.comuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
576313Sgblack@eecs.umich.edu
589384SAndreas.Sandberg@arm.comstatic inline bool
5910461SAndreas.Sandberg@ARM.cominUserMode(ThreadContext *tc)
606333Sgblack@eecs.umich.edu{
616313Sgblack@eecs.umich.edu    PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
626313Sgblack@eecs.umich.edu    HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
636313Sgblack@eecs.umich.edu    return !(pstate.priv || hpstate.hpriv);
646313Sgblack@eecs.umich.edu}
656313Sgblack@eecs.umich.edu
669384SAndreas.Sandberg@arm.com/**
676313Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers.
686313Sgblack@eecs.umich.edu * @param tc The thread context.
6910037SARM gem5 Developers */
7010037SARM gem5 Developerstemplate <class TC>
7110037SARM gem5 Developersvoid zeroRegisters(TC *tc);
7211165SRekai.GonzalezAlberquilla@arm.com
7311165SRekai.GonzalezAlberquilla@arm.comvoid initCPU(ThreadContext *tc, int cpuId);
7412109SRekai.GonzalezAlberquilla@arm.com
7511165SRekai.GonzalezAlberquilla@arm.cominline void
7610461SAndreas.Sandberg@ARM.comstartupCPU(ThreadContext *tc, int cpuId)
7710461SAndreas.Sandberg@ARM.com{
7810461SAndreas.Sandberg@ARM.com    // Other CPUs will get activated by IPIs
7910461SAndreas.Sandberg@ARM.com    if (cpuId == 0 || !FullSystem)
8010461SAndreas.Sandberg@ARM.com        tc->activate(0);
8110461SAndreas.Sandberg@ARM.com}
8210844Sandreas.sandberg@arm.com
8310844Sandreas.sandberg@arm.comvoid copyRegs(ThreadContext *src, ThreadContext *dest);
8410844Sandreas.sandberg@arm.com
8510037SARM gem5 Developersvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
8611771SCurtis.Dunham@arm.com
8710037SARM gem5 Developersvoid skipFunction(ThreadContext *tc);
8810037SARM gem5 Developers
8910037SARM gem5 Developersinline void
9010037SARM gem5 DevelopersadvancePC(PCState &pc, const StaticInstPtr inst)
9110037SARM gem5 Developers{
9210037SARM gem5 Developers    inst->advancePC(pc);
9312714Sgiacomo.travaglini@arm.com}
9412714Sgiacomo.travaglini@arm.com
9512714Sgiacomo.travaglini@arm.cominline uint64_t
9612714Sgiacomo.travaglini@arm.comgetExecutingAsid(ThreadContext *tc)
9712714Sgiacomo.travaglini@arm.com{
9812714Sgiacomo.travaglini@arm.com    return tc->readMiscRegNoEffect(MISCREG_MMU_P_CONTEXT);
9912478SCurtis.Dunham@arm.com}
10010037SARM gem5 Developers
10112477SCurtis.Dunham@arm.com} // namespace SparcISA
10212477SCurtis.Dunham@arm.com
10312478SCurtis.Dunham@arm.com#endif
10412478SCurtis.Dunham@arm.com