utility.hh revision 3484
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" 372972Sgblack@eecs.umich.edu#include "arch/alpha/isa_traits.hh" 382460SN/A#include "arch/alpha/regfile.hh" 392440SN/A#include "base/misc.hh" 403120Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 412440SN/A 422440SN/Anamespace AlphaISA 432440SN/A{ 442440SN/A 452440SN/A static inline ExtMachInst 463484Sktlim@umich.edu makeExtMI(MachInst inst, Addr pc) { 472440SN/A#if FULL_SYSTEM 482440SN/A ExtMachInst ext_inst = inst; 493484Sktlim@umich.edu if (pc && 0x1) 503484Sktlim@umich.edu return ext_inst|=(static_cast<ExtMachInst>(pc & 0x1) << 32); 512440SN/A else 522440SN/A return ext_inst; 532440SN/A#else 542440SN/A return ExtMachInst(inst); 552440SN/A#endif 562440SN/A } 572440SN/A 582467SN/A inline bool isCallerSaveIntegerRegister(unsigned int reg) { 592440SN/A panic("register classification not implemented"); 602440SN/A return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27); 612440SN/A } 622440SN/A 632467SN/A inline bool isCalleeSaveIntegerRegister(unsigned int reg) { 642440SN/A panic("register classification not implemented"); 652440SN/A return (reg >= 9 && reg <= 15); 662440SN/A } 672440SN/A 682467SN/A inline bool isCallerSaveFloatRegister(unsigned int reg) { 692440SN/A panic("register classification not implemented"); 702440SN/A return false; 712440SN/A } 722440SN/A 732467SN/A inline bool isCalleeSaveFloatRegister(unsigned int reg) { 742440SN/A panic("register classification not implemented"); 752440SN/A return false; 762440SN/A } 772440SN/A 782467SN/A inline Addr alignAddress(const Addr &addr, 792440SN/A unsigned int nbytes) { 802440SN/A return (addr & ~(nbytes - 1)); 812440SN/A } 822440SN/A 832440SN/A // Instruction address compression hooks 842467SN/A inline Addr realPCToFetchPC(const Addr &addr) { 852440SN/A return addr; 862440SN/A } 872440SN/A 882467SN/A inline Addr fetchPCToRealPC(const Addr &addr) { 892440SN/A return addr; 902440SN/A } 912440SN/A 922440SN/A // the size of "fetched" instructions (not necessarily the size 932440SN/A // of real instructions for PISA) 942467SN/A inline size_t fetchInstSize() { 952440SN/A return sizeof(MachInst); 962440SN/A } 972440SN/A 982467SN/A inline MachInst makeRegisterCopy(int dest, int src) { 992440SN/A panic("makeRegisterCopy not implemented"); 1002440SN/A return 0; 1012440SN/A } 1022440SN/A 1032440SN/A // Machine operations 1042440SN/A 1052440SN/A void saveMachineReg(AnyReg &savereg, const RegFile ®_file, 1062440SN/A int regnum); 1072440SN/A 1082440SN/A void restoreMachineReg(RegFile ®s, const AnyReg ®, 1092440SN/A int regnum); 1102440SN/A 1112440SN/A /** 1122440SN/A * Function to insure ISA semantics about 0 registers. 1132680Sktlim@umich.edu * @param tc The thread context. 1142440SN/A */ 1152680Sktlim@umich.edu template <class TC> 1162680Sktlim@umich.edu void zeroRegisters(TC *tc); 1172440SN/A 1182440SN/A#if FULL_SYSTEM 1192440SN/A // Alpha IPR register accessors 1202467SN/A inline bool PcPAL(Addr addr) { return addr & 0x1; } 1212440SN/A 1222440SN/A //////////////////////////////////////////////////////////////////////// 1232440SN/A // 1242440SN/A // Translation stuff 1252440SN/A // 1262440SN/A 1272467SN/A inline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; } 1282440SN/A 1292440SN/A // User Virtual 1302467SN/A inline bool IsUSeg(Addr a) { return USegBase <= a && a <= USegEnd; } 1312440SN/A 1322440SN/A // Kernel Direct Mapped 1332467SN/A inline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; } 1342467SN/A inline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; } 1352440SN/A 1362440SN/A // Kernel Virtual 1372467SN/A inline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; } 1382440SN/A 1392467SN/A inline Addr 1402440SN/A TruncPage(Addr addr) 1412440SN/A { return addr & ~(PageBytes - 1); } 1422440SN/A 1432467SN/A inline Addr 1442440SN/A RoundPage(Addr addr) 1452440SN/A { return (addr + PageBytes - 1) & ~(PageBytes - 1); } 1462440SN/A 1472680Sktlim@umich.edu void initCPU(ThreadContext *tc, int cpuId); 1482680Sktlim@umich.edu void initIPRs(ThreadContext *tc, int cpuId); 1492440SN/A 1502440SN/A /** 1512440SN/A * Function to check for and process any interrupts. 1522680Sktlim@umich.edu * @param tc The thread context. 1532440SN/A */ 1542680Sktlim@umich.edu template <class TC> 1552680Sktlim@umich.edu void processInterrupts(TC *tc); 1562440SN/A#endif 1572440SN/A 1582440SN/A} // namespace AlphaISA 1592440SN/A 1602440SN/A#endif 161