isa_traits.hh revision 2512
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#ifndef __ARCH_ALPHA_ISA_TRAITS_HH__ 30#define __ARCH_ALPHA_ISA_TRAITS_HH__ 31 32namespace LittleEndianGuest {} 33 34#include "arch/alpha/types.hh" 35#include "arch/alpha/constants.hh" 36#include "arch/alpha/regfile.hh" 37#include "config/full_system.hh" 38#include "sim/host.hh" 39 40class StaticInstPtr; 41 42#if !FULL_SYSTEM 43class SyscallReturn { 44 public: 45 template <class T> 46 SyscallReturn(T v, bool s) 47 { 48 retval = (uint64_t)v; 49 success = s; 50 } 51 52 template <class T> 53 SyscallReturn(T v) 54 { 55 success = (v >= 0); 56 retval = (uint64_t)v; 57 } 58 59 ~SyscallReturn() {} 60 61 SyscallReturn& operator=(const SyscallReturn& s) { 62 retval = s.retval; 63 success = s.success; 64 return *this; 65 } 66 67 bool successful() { return success; } 68 uint64_t value() { return retval; } 69 70 71 private: 72 uint64_t retval; 73 bool success; 74}; 75 76#endif 77 78#if FULL_SYSTEM 79#include "arch/alpha/isa_fullsys_traits.hh" 80#endif 81 82 83namespace AlphaISA 84{ 85 86using namespace LittleEndianGuest; 87 88// redirected register map, really only used for the full system case. 89extern const int reg_redir[NumIntRegs]; 90 91 StaticInstPtr decodeInst(ExtMachInst); 92 93#if !FULL_SYSTEM 94 static inline void setSyscallReturn(SyscallReturn return_value, RegFile *regs) 95 { 96 // check for error condition. Alpha syscall convention is to 97 // indicate success/failure in reg a3 (r19) and put the 98 // return value itself in the standard return value reg (v0). 99 if (return_value.successful()) { 100 // no error 101 regs->intRegFile[SyscallSuccessReg] = 0; 102 regs->intRegFile[ReturnValueReg] = return_value.value(); 103 } else { 104 // got an error, return details 105 regs->intRegFile[SyscallSuccessReg] = (IntReg) -1; 106 regs->intRegFile[ReturnValueReg] = -return_value.value(); 107 } 108 } 109#endif 110}; 111 112#endif // __ARCH_ALPHA_ISA_TRAITS_HH__ 113