utility.hh revision 7741
12221SN/A/* 22221SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32221SN/A * All rights reserved. 42221SN/A * 52221SN/A * Redistribution and use in source and binary forms, with or without 62221SN/A * modification, are permitted provided that the following conditions are 72221SN/A * met: redistributions of source code must retain the above copyright 82221SN/A * notice, this list of conditions and the following disclaimer; 92221SN/A * redistributions in binary form must reproduce the above copyright 102221SN/A * notice, this list of conditions and the following disclaimer in the 112221SN/A * documentation and/or other materials provided with the distribution; 122221SN/A * neither the name of the copyright holders nor the names of its 132221SN/A * contributors may be used to endorse or promote products derived from 142221SN/A * this software without specific prior written permission. 152221SN/A * 162221SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172221SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182221SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192221SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202221SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212221SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222221SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232221SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242221SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252221SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262221SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu */ 302221SN/A 312221SN/A#ifndef __ARCH_SPARC_UTILITY_HH__ 323415Sgblack@eecs.umich.edu#define __ARCH_SPARC_UTILITY_HH__ 333415Sgblack@eecs.umich.edu 342223SN/A#include "arch/sparc/isa_traits.hh" 353415Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh" 363578Sgblack@eecs.umich.edu#include "arch/sparc/tlb.hh" 373415Sgblack@eecs.umich.edu#include "base/misc.hh" 383415Sgblack@eecs.umich.edu#include "base/bitfield.hh" 393523Sgblack@eecs.umich.edu#include "cpu/static_inst.hh" 403415Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 412680Sktlim@umich.edu#include "sim/fault.hh" 422800Ssaidi@eecs.umich.edu 433523Sgblack@eecs.umich.edunamespace SparcISA 443415Sgblack@eecs.umich.edu{ 452800Ssaidi@eecs.umich.edu 462800Ssaidi@eecs.umich.eduinline PCState 472221SN/AbuildRetPC(const PCState &curPC, const PCState &callPC) 483415Sgblack@eecs.umich.edu{ 493415Sgblack@eecs.umich.edu PCState ret = callPC; 502223SN/A ret.uEnd(); 512221SN/A ret.pc(curPC.npc()); 522221SN/A return ret; 533573Sgblack@eecs.umich.edu} 543576Sgblack@eecs.umich.edu 553576Sgblack@eecs.umich.eduuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp); 562221SN/A 573573Sgblack@eecs.umich.edustatic inline bool 583576Sgblack@eecs.umich.eduinUserMode(ThreadContext *tc) 593576Sgblack@eecs.umich.edu{ 602221SN/A return !((tc->readMiscRegNoEffect(MISCREG_PSTATE) & (1 << 2)) || 613573Sgblack@eecs.umich.edu (tc->readMiscRegNoEffect(MISCREG_HPSTATE) & (1 << 2))); 623576Sgblack@eecs.umich.edu} 633576Sgblack@eecs.umich.edu 642221SN/A/** 653573Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers. 663576Sgblack@eecs.umich.edu * @param tc The thread context. 673576Sgblack@eecs.umich.edu */ 682221SN/Atemplate <class TC> 693573Sgblack@eecs.umich.eduvoid zeroRegisters(TC *tc); 703576Sgblack@eecs.umich.edu 713576Sgblack@eecs.umich.eduvoid initCPU(ThreadContext *tc, int cpuId); 722221SN/A 733573Sgblack@eecs.umich.eduinline void 743576Sgblack@eecs.umich.edustartupCPU(ThreadContext *tc, int cpuId) 753576Sgblack@eecs.umich.edu{ 762221SN/A#if FULL_SYSTEM 773573Sgblack@eecs.umich.edu // Other CPUs will get activated by IPIs 783576Sgblack@eecs.umich.edu if (cpuId == 0) 793576Sgblack@eecs.umich.edu tc->activate(0); 803576Sgblack@eecs.umich.edu#else 813576Sgblack@eecs.umich.edu tc->activate(0); 823576Sgblack@eecs.umich.edu#endif 833576Sgblack@eecs.umich.edu} 843576Sgblack@eecs.umich.edu 852221SN/Avoid copyRegs(ThreadContext *src, ThreadContext *dest); 863573Sgblack@eecs.umich.edu 873576Sgblack@eecs.umich.eduvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest); 883576Sgblack@eecs.umich.edu 892221SN/Avoid skipFunction(ThreadContext *tc); 903573Sgblack@eecs.umich.edu 913576Sgblack@eecs.umich.eduinline void 923576Sgblack@eecs.umich.eduadvancePC(PCState &pc, const StaticInstPtr inst) 932221SN/A{ 943573Sgblack@eecs.umich.edu inst->advancePC(pc); 953576Sgblack@eecs.umich.edu} 963576Sgblack@eecs.umich.edu 973576Sgblack@eecs.umich.edu} // namespace SparcISA 983576Sgblack@eecs.umich.edu 993576Sgblack@eecs.umich.edu#endif 1003576Sgblack@eecs.umich.edu