utility.hh revision 7707
111723Sar4jc@virginia.edu/* 211723Sar4jc@virginia.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan 311723Sar4jc@virginia.edu * All rights reserved. 411723Sar4jc@virginia.edu * 511723Sar4jc@virginia.edu * Redistribution and use in source and binary forms, with or without 611723Sar4jc@virginia.edu * modification, are permitted provided that the following conditions are 711723Sar4jc@virginia.edu * met: redistributions of source code must retain the above copyright 811723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer; 911723Sar4jc@virginia.edu * redistributions in binary form must reproduce the above copyright 1011723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer in the 1111723Sar4jc@virginia.edu * documentation and/or other materials provided with the distribution; 1211723Sar4jc@virginia.edu * neither the name of the copyright holders nor the names of its 1311723Sar4jc@virginia.edu * contributors may be used to endorse or promote products derived from 1411723Sar4jc@virginia.edu * this software without specific prior written permission. 1511723Sar4jc@virginia.edu * 1611723Sar4jc@virginia.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1711723Sar4jc@virginia.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1811723Sar4jc@virginia.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1911723Sar4jc@virginia.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2011723Sar4jc@virginia.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2111723Sar4jc@virginia.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2211723Sar4jc@virginia.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2311723Sar4jc@virginia.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2411723Sar4jc@virginia.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2511723Sar4jc@virginia.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2611723Sar4jc@virginia.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2711723Sar4jc@virginia.edu * 2811723Sar4jc@virginia.edu * Authors: Nathan Binkert 2911723Sar4jc@virginia.edu * Steve Reinhardt 3011723Sar4jc@virginia.edu */ 3111723Sar4jc@virginia.edu 3211723Sar4jc@virginia.edu#ifndef __ARCH_ALPHA_UTILITY_HH__ 3311723Sar4jc@virginia.edu#define __ARCH_ALPHA_UTILITY_HH__ 3411723Sar4jc@virginia.edu 3511723Sar4jc@virginia.edu#include "arch/alpha/types.hh" 3611723Sar4jc@virginia.edu#include "arch/alpha/isa_traits.hh" 3711723Sar4jc@virginia.edu#include "arch/alpha/registers.hh" 3811723Sar4jc@virginia.edu#include "base/misc.hh" 3911723Sar4jc@virginia.edu#include "config/full_system.hh" 4011723Sar4jc@virginia.edu#include "cpu/thread_context.hh" 4111723Sar4jc@virginia.edu 4211723Sar4jc@virginia.edunamespace AlphaISA { 4311723Sar4jc@virginia.edu 4411723Sar4jc@virginia.eduuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp); 4511723Sar4jc@virginia.edu 4611723Sar4jc@virginia.eduinline bool 4711723Sar4jc@virginia.eduinUserMode(ThreadContext *tc) 4811723Sar4jc@virginia.edu{ 4911723Sar4jc@virginia.edu return (tc->readMiscRegNoEffect(IPR_DTB_CM) & 0x18) != 0; 5011723Sar4jc@virginia.edu} 5111723Sar4jc@virginia.edu 5211723Sar4jc@virginia.edu/** 5311723Sar4jc@virginia.edu * Function to insure ISA semantics about 0 registers. 5411723Sar4jc@virginia.edu * @param tc The thread context. 55 */ 56template <class TC> 57void zeroRegisters(TC *tc); 58 59// Alpha IPR register accessors 60inline bool PcPAL(Addr addr) { return addr & 0x3; } 61inline void startupCPU(ThreadContext *tc, int cpuId) { tc->activate(0); } 62 63//////////////////////////////////////////////////////////////////////// 64// 65// Translation stuff 66// 67 68inline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; } 69 70// User Virtual 71inline bool IsUSeg(Addr a) { return USegBase <= a && a <= USegEnd; } 72 73// Kernel Direct Mapped 74inline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; } 75inline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; } 76 77// Kernel Virtual 78inline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; } 79 80inline Addr 81TruncPage(Addr addr) 82{ return addr & ~(PageBytes - 1); } 83 84inline Addr 85RoundPage(Addr addr) 86{ return (addr + PageBytes - 1) & ~(PageBytes - 1); } 87 88void initIPRs(ThreadContext *tc, int cpuId); 89#if FULL_SYSTEM 90void initCPU(ThreadContext *tc, int cpuId); 91#endif 92 93void copyRegs(ThreadContext *src, ThreadContext *dest); 94 95void copyMiscRegs(ThreadContext *src, ThreadContext *dest); 96 97void skipFunction(ThreadContext *tc); 98} // namespace AlphaISA 99 100#endif // __ARCH_ALPHA_UTILITY_HH__ 101