utility.hh revision 7741
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"
372501SN/A#include "base/misc.hh"
383278Sgblack@eecs.umich.edu#include "base/bitfield.hh"
397720Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
403272Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
417678Sgblack@eecs.umich.edu#include "sim/fault.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{
607741Sgblack@eecs.umich.edu    return !((tc->readMiscRegNoEffect(MISCREG_PSTATE) & (1 << 2)) ||
617741Sgblack@eecs.umich.edu             (tc->readMiscRegNoEffect(MISCREG_HPSTATE) & (1 << 2)));
627741Sgblack@eecs.umich.edu}
633577Sgblack@eecs.umich.edu
647741Sgblack@eecs.umich.edu/**
657741Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers.
667741Sgblack@eecs.umich.edu * @param tc The thread context.
677741Sgblack@eecs.umich.edu */
687741Sgblack@eecs.umich.edutemplate <class TC>
697741Sgblack@eecs.umich.eduvoid zeroRegisters(TC *tc);
702501SN/A
717741Sgblack@eecs.umich.eduvoid initCPU(ThreadContext *tc, int cpuId);
724194Ssaidi@eecs.umich.edu
737741Sgblack@eecs.umich.eduinline void
747741Sgblack@eecs.umich.edustartupCPU(ThreadContext *tc, int cpuId)
757741Sgblack@eecs.umich.edu{
764194Ssaidi@eecs.umich.edu#if FULL_SYSTEM
777741Sgblack@eecs.umich.edu    // Other CPUs will get activated by IPIs
787741Sgblack@eecs.umich.edu    if (cpuId == 0)
797741Sgblack@eecs.umich.edu        tc->activate(0);
804194Ssaidi@eecs.umich.edu#else
817741Sgblack@eecs.umich.edu    tc->activate(0);
824194Ssaidi@eecs.umich.edu#endif
837741Sgblack@eecs.umich.edu}
843528Sgblack@eecs.umich.edu
857741Sgblack@eecs.umich.eduvoid copyRegs(ThreadContext *src, ThreadContext *dest);
866329Sgblack@eecs.umich.edu
877741Sgblack@eecs.umich.eduvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
886329Sgblack@eecs.umich.edu
897741Sgblack@eecs.umich.eduvoid skipFunction(ThreadContext *tc);
907693SAli.Saidi@ARM.com
917741Sgblack@eecs.umich.eduinline void
927741Sgblack@eecs.umich.eduadvancePC(PCState &pc, const StaticInstPtr inst)
937741Sgblack@eecs.umich.edu{
947741Sgblack@eecs.umich.edu    inst->advancePC(pc);
957741Sgblack@eecs.umich.edu}
967720Sgblack@eecs.umich.edu
972501SN/A} // namespace SparcISA
982501SN/A
992501SN/A#endif
100