utility.hh revision 10417
12501SN/A/*
22501SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32501SN/A * All rights reserved.
42501SN/A *
52501SN/A * Redistribution and use in source and binary forms, with or without
62501SN/A * modification, are permitted provided that the following conditions are
72501SN/A * met: redistributions of source code must retain the above copyright
82501SN/A * notice, this list of conditions and the following disclaimer;
92501SN/A * redistributions in binary form must reproduce the above copyright
102501SN/A * notice, this list of conditions and the following disclaimer in the
112501SN/A * documentation and/or other materials provided with the distribution;
122501SN/A * neither the name of the copyright holders nor the names of its
132501SN/A * contributors may be used to endorse or promote products derived from
142501SN/A * this software without specific prior written permission.
152501SN/A *
162501SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172501SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182501SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192501SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202501SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212501SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222501SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232501SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242501SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252501SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262501SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292501SN/A */
302501SN/A
312501SN/A#ifndef __ARCH_SPARC_UTILITY_HH__
322501SN/A#define __ARCH_SPARC_UTILITY_HH__
332501SN/A
342501SN/A#include "arch/sparc/isa_traits.hh"
356335Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh"
363603Ssaidi@eecs.umich.edu#include "arch/sparc/tlb.hh"
378229Snate@binkert.org#include "base/bitfield.hh"
382501SN/A#include "base/misc.hh"
397720Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
403272Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
417878Sgblack@eecs.umich.edu#include "sim/fault_fwd.hh"
428767Sgblack@eecs.umich.edu#include "sim/full_system.hh"
432501SN/A
442501SN/Anamespace SparcISA
452501SN/A{
467720Sgblack@eecs.umich.edu
477741Sgblack@eecs.umich.eduinline PCState
487741Sgblack@eecs.umich.edubuildRetPC(const PCState &curPC, const PCState &callPC)
497741Sgblack@eecs.umich.edu{
507741Sgblack@eecs.umich.edu    PCState ret = callPC;
517741Sgblack@eecs.umich.edu    ret.uEnd();
527741Sgblack@eecs.umich.edu    ret.pc(curPC.npc());
537741Sgblack@eecs.umich.edu    return ret;
547741Sgblack@eecs.umich.edu}
557720Sgblack@eecs.umich.edu
567741Sgblack@eecs.umich.eduuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
574826Ssaidi@eecs.umich.edu
587741Sgblack@eecs.umich.edustatic inline bool
597741Sgblack@eecs.umich.eduinUserMode(ThreadContext *tc)
607741Sgblack@eecs.umich.edu{
618829Sgblack@eecs.umich.edu    PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
628829Sgblack@eecs.umich.edu    HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
638829Sgblack@eecs.umich.edu    return !(pstate.priv || hpstate.hpriv);
647741Sgblack@eecs.umich.edu}
653577Sgblack@eecs.umich.edu
667741Sgblack@eecs.umich.edu/**
677741Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers.
687741Sgblack@eecs.umich.edu * @param tc The thread context.
697741Sgblack@eecs.umich.edu */
707741Sgblack@eecs.umich.edutemplate <class TC>
717741Sgblack@eecs.umich.eduvoid zeroRegisters(TC *tc);
722501SN/A
737741Sgblack@eecs.umich.eduvoid initCPU(ThreadContext *tc, int cpuId);
744194Ssaidi@eecs.umich.edu
757741Sgblack@eecs.umich.eduinline void
767741Sgblack@eecs.umich.edustartupCPU(ThreadContext *tc, int cpuId)
777741Sgblack@eecs.umich.edu{
787741Sgblack@eecs.umich.edu    // Other CPUs will get activated by IPIs
798767Sgblack@eecs.umich.edu    if (cpuId == 0 || !FullSystem)
8010407Smitch.hayenga@arm.com        tc->activate();
817741Sgblack@eecs.umich.edu}
823528Sgblack@eecs.umich.edu
837741Sgblack@eecs.umich.eduvoid copyRegs(ThreadContext *src, ThreadContext *dest);
846329Sgblack@eecs.umich.edu
857741Sgblack@eecs.umich.eduvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
866329Sgblack@eecs.umich.edu
877741Sgblack@eecs.umich.eduvoid skipFunction(ThreadContext *tc);
887693SAli.Saidi@ARM.com
897741Sgblack@eecs.umich.eduinline void
9010417Sandreas.hansson@arm.comadvancePC(PCState &pc, const StaticInstPtr &inst)
917741Sgblack@eecs.umich.edu{
927741Sgblack@eecs.umich.edu    inst->advancePC(pc);
937741Sgblack@eecs.umich.edu}
947720Sgblack@eecs.umich.edu
958300Schander.sudanthi@arm.cominline uint64_t
968300Schander.sudanthi@arm.comgetExecutingAsid(ThreadContext *tc)
978300Schander.sudanthi@arm.com{
988300Schander.sudanthi@arm.com    return tc->readMiscRegNoEffect(MISCREG_MMU_P_CONTEXT);
998300Schander.sudanthi@arm.com}
1008300Schander.sudanthi@arm.com
1012501SN/A} // namespace SparcISA
1022501SN/A
1032501SN/A#endif
104