utility.hh revision 7678
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" 393272Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 407678Sgblack@eecs.umich.edu#include "sim/fault.hh" 412501SN/A 422501SN/Anamespace SparcISA 432501SN/A{ 444826Ssaidi@eecs.umich.edu uint64_t getArgument(ThreadContext *tc, int number, bool fp); 454826Ssaidi@eecs.umich.edu 463577Sgblack@eecs.umich.edu static inline bool 473577Sgblack@eecs.umich.edu inUserMode(ThreadContext *tc) 483577Sgblack@eecs.umich.edu { 496283Sgblack@eecs.umich.edu return !((tc->readMiscRegNoEffect(MISCREG_PSTATE) & (1 << 2)) || 506283Sgblack@eecs.umich.edu (tc->readMiscRegNoEffect(MISCREG_HPSTATE) & (1 << 2))); 513577Sgblack@eecs.umich.edu } 523577Sgblack@eecs.umich.edu 532501SN/A /** 542501SN/A * Function to insure ISA semantics about 0 registers. 552680Sktlim@umich.edu * @param tc The thread context. 562501SN/A */ 572680Sktlim@umich.edu template <class TC> 582680Sktlim@umich.edu void zeroRegisters(TC *tc); 592501SN/A 607678Sgblack@eecs.umich.edu void initCPU(ThreadContext *tc, int cpuId); 614194Ssaidi@eecs.umich.edu 627572Sgblack@eecs.umich.edu inline void 637572Sgblack@eecs.umich.edu startupCPU(ThreadContext *tc, int cpuId) 644194Ssaidi@eecs.umich.edu { 654194Ssaidi@eecs.umich.edu#if FULL_SYSTEM 664194Ssaidi@eecs.umich.edu // Other CPUs will get activated by IPIs 674194Ssaidi@eecs.umich.edu if (cpuId == 0) 684194Ssaidi@eecs.umich.edu tc->activate(0); 694194Ssaidi@eecs.umich.edu#else 704194Ssaidi@eecs.umich.edu tc->activate(0); 714194Ssaidi@eecs.umich.edu#endif 723528Sgblack@eecs.umich.edu } 733528Sgblack@eecs.umich.edu 746329Sgblack@eecs.umich.edu void copyRegs(ThreadContext *src, ThreadContext *dest); 756329Sgblack@eecs.umich.edu 766329Sgblack@eecs.umich.edu void copyMiscRegs(ThreadContext *src, ThreadContext *dest); 776329Sgblack@eecs.umich.edu 782501SN/A} // namespace SparcISA 792501SN/A 802501SN/A#endif 81