utility.hh revision 2665
12440SN/A/* 22440SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32440SN/A * All rights reserved. 42440SN/A * 52440SN/A * Redistribution and use in source and binary forms, with or without 62440SN/A * modification, are permitted provided that the following conditions are 72440SN/A * met: redistributions of source code must retain the above copyright 82440SN/A * notice, this list of conditions and the following disclaimer; 92440SN/A * redistributions in binary form must reproduce the above copyright 102440SN/A * notice, this list of conditions and the following disclaimer in the 112440SN/A * documentation and/or other materials provided with the distribution; 122440SN/A * neither the name of the copyright holders nor the names of its 132440SN/A * contributors may be used to endorse or promote products derived from 142440SN/A * this software without specific prior written permission. 152440SN/A * 162440SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172440SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182440SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192440SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202440SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212440SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222440SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232440SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242440SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252440SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262440SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 292665Ssaidi@eecs.umich.edu * Steve Reinhardt 302440SN/A */ 312440SN/A 322440SN/A#ifndef __ARCH_ALPHA_UTILITY_HH__ 332440SN/A#define __ARCH_ALPHA_UTILITY_HH__ 342440SN/A 352440SN/A#include "config/full_system.hh" 362440SN/A#include "arch/alpha/types.hh" 372440SN/A#include "arch/alpha/constants.hh" 382460SN/A#include "arch/alpha/regfile.hh" 392440SN/A#include "base/misc.hh" 402440SN/A 412440SN/Anamespace AlphaISA 422440SN/A{ 432440SN/A 442440SN/A static inline ExtMachInst 452440SN/A makeExtMI(MachInst inst, const uint64_t &pc) { 462440SN/A#if FULL_SYSTEM 472440SN/A ExtMachInst ext_inst = inst; 482440SN/A if (pc && 0x1) 492440SN/A return ext_inst|=(static_cast<ExtMachInst>(pc & 0x1) << 32); 502440SN/A else 512440SN/A return ext_inst; 522440SN/A#else 532440SN/A return ExtMachInst(inst); 542440SN/A#endif 552440SN/A } 562440SN/A 572467SN/A inline bool isCallerSaveIntegerRegister(unsigned int reg) { 582440SN/A panic("register classification not implemented"); 592440SN/A return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27); 602440SN/A } 612440SN/A 622467SN/A inline bool isCalleeSaveIntegerRegister(unsigned int reg) { 632440SN/A panic("register classification not implemented"); 642440SN/A return (reg >= 9 && reg <= 15); 652440SN/A } 662440SN/A 672467SN/A inline bool isCallerSaveFloatRegister(unsigned int reg) { 682440SN/A panic("register classification not implemented"); 692440SN/A return false; 702440SN/A } 712440SN/A 722467SN/A inline bool isCalleeSaveFloatRegister(unsigned int reg) { 732440SN/A panic("register classification not implemented"); 742440SN/A return false; 752440SN/A } 762440SN/A 772467SN/A inline Addr alignAddress(const Addr &addr, 782440SN/A unsigned int nbytes) { 792440SN/A return (addr & ~(nbytes - 1)); 802440SN/A } 812440SN/A 822440SN/A // Instruction address compression hooks 832467SN/A inline Addr realPCToFetchPC(const Addr &addr) { 842440SN/A return addr; 852440SN/A } 862440SN/A 872467SN/A inline Addr fetchPCToRealPC(const Addr &addr) { 882440SN/A return addr; 892440SN/A } 902440SN/A 912440SN/A // the size of "fetched" instructions (not necessarily the size 922440SN/A // of real instructions for PISA) 932467SN/A inline size_t fetchInstSize() { 942440SN/A return sizeof(MachInst); 952440SN/A } 962440SN/A 972467SN/A inline MachInst makeRegisterCopy(int dest, int src) { 982440SN/A panic("makeRegisterCopy not implemented"); 992440SN/A return 0; 1002440SN/A } 1012440SN/A 1022440SN/A // Machine operations 1032440SN/A 1042440SN/A void saveMachineReg(AnyReg &savereg, const RegFile ®_file, 1052440SN/A int regnum); 1062440SN/A 1072440SN/A void restoreMachineReg(RegFile ®s, const AnyReg ®, 1082440SN/A int regnum); 1092440SN/A 1102440SN/A /** 1112440SN/A * Function to insure ISA semantics about 0 registers. 1122440SN/A * @param xc The execution context. 1132440SN/A */ 1142440SN/A template <class XC> 1152440SN/A void zeroRegisters(XC *xc); 1162440SN/A 1172440SN/A#if FULL_SYSTEM 1182440SN/A // Alpha IPR register accessors 1192467SN/A inline bool PcPAL(Addr addr) { return addr & 0x1; } 1202440SN/A 1212440SN/A //////////////////////////////////////////////////////////////////////// 1222440SN/A // 1232440SN/A // Translation stuff 1242440SN/A // 1252440SN/A 1262467SN/A inline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; } 1272440SN/A 1282440SN/A // User Virtual 1292467SN/A inline bool IsUSeg(Addr a) { return USegBase <= a && a <= USegEnd; } 1302440SN/A 1312440SN/A // Kernel Direct Mapped 1322467SN/A inline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; } 1332467SN/A inline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; } 1342440SN/A 1352440SN/A // Kernel Virtual 1362467SN/A inline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; } 1372440SN/A 1382467SN/A inline Addr 1392440SN/A TruncPage(Addr addr) 1402440SN/A { return addr & ~(PageBytes - 1); } 1412440SN/A 1422467SN/A inline Addr 1432440SN/A RoundPage(Addr addr) 1442440SN/A { return (addr + PageBytes - 1) & ~(PageBytes - 1); } 1452440SN/A 1462440SN/A void initCPU(ExecContext *xc, int cpuId); 1472440SN/A void initIPRs(ExecContext *xc, int cpuId); 1482440SN/A 1492440SN/A /** 1502440SN/A * Function to check for and process any interrupts. 1512440SN/A * @param xc The execution context. 1522440SN/A */ 1532440SN/A template <class XC> 1542440SN/A void processInterrupts(XC *xc); 1552440SN/A#endif 1562440SN/A 1572440SN/A} // namespace AlphaISA 1582440SN/A 1592440SN/A#endif 160