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"
3812334Sgabeblack@google.com#include "base/logging.hh"
397720Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
403272Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
418767Sgblack@eecs.umich.edu#include "sim/full_system.hh"
422501SN/A
432501SN/Anamespace SparcISA
442501SN/A{
457720Sgblack@eecs.umich.edu
467741Sgblack@eecs.umich.eduinline PCState
477741Sgblack@eecs.umich.edubuildRetPC(const PCState &curPC, const PCState &callPC)
487741Sgblack@eecs.umich.edu{
497741Sgblack@eecs.umich.edu    PCState ret = callPC;
507741Sgblack@eecs.umich.edu    ret.uEnd();
517741Sgblack@eecs.umich.edu    ret.pc(curPC.npc());
527741Sgblack@eecs.umich.edu    return ret;
537741Sgblack@eecs.umich.edu}
547720Sgblack@eecs.umich.edu
557741Sgblack@eecs.umich.eduuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
564826Ssaidi@eecs.umich.edu
577741Sgblack@eecs.umich.edustatic inline bool
587741Sgblack@eecs.umich.eduinUserMode(ThreadContext *tc)
597741Sgblack@eecs.umich.edu{
608829Sgblack@eecs.umich.edu    PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
618829Sgblack@eecs.umich.edu    HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
628829Sgblack@eecs.umich.edu    return !(pstate.priv || hpstate.hpriv);
637741Sgblack@eecs.umich.edu}
643577Sgblack@eecs.umich.edu
657741Sgblack@eecs.umich.edu/**
667741Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers.
677741Sgblack@eecs.umich.edu * @param tc The thread context.
687741Sgblack@eecs.umich.edu */
697741Sgblack@eecs.umich.edutemplate <class TC>
707741Sgblack@eecs.umich.eduvoid zeroRegisters(TC *tc);
712501SN/A
727741Sgblack@eecs.umich.eduvoid initCPU(ThreadContext *tc, int cpuId);
734194Ssaidi@eecs.umich.edu
747741Sgblack@eecs.umich.eduinline void
757741Sgblack@eecs.umich.edustartupCPU(ThreadContext *tc, int cpuId)
767741Sgblack@eecs.umich.edu{
777741Sgblack@eecs.umich.edu    // Other CPUs will get activated by IPIs
788767Sgblack@eecs.umich.edu    if (cpuId == 0 || !FullSystem)
7910407Smitch.hayenga@arm.com        tc->activate();
807741Sgblack@eecs.umich.edu}
813528Sgblack@eecs.umich.edu
827741Sgblack@eecs.umich.eduvoid copyRegs(ThreadContext *src, ThreadContext *dest);
836329Sgblack@eecs.umich.edu
847741Sgblack@eecs.umich.eduvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
856329Sgblack@eecs.umich.edu
867741Sgblack@eecs.umich.eduvoid skipFunction(ThreadContext *tc);
877693SAli.Saidi@ARM.com
887741Sgblack@eecs.umich.eduinline void
8910417Sandreas.hansson@arm.comadvancePC(PCState &pc, const StaticInstPtr &inst)
907741Sgblack@eecs.umich.edu{
917741Sgblack@eecs.umich.edu    inst->advancePC(pc);
927741Sgblack@eecs.umich.edu}
937720Sgblack@eecs.umich.edu
948300Schander.sudanthi@arm.cominline uint64_t
958300Schander.sudanthi@arm.comgetExecutingAsid(ThreadContext *tc)
968300Schander.sudanthi@arm.com{
978300Schander.sudanthi@arm.com    return tc->readMiscRegNoEffect(MISCREG_MMU_P_CONTEXT);
988300Schander.sudanthi@arm.com}
998300Schander.sudanthi@arm.com
1002501SN/A} // namespace SparcISA
1012501SN/A
1022501SN/A#endif
103