isa_traits.hh revision 2665
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 * Authors: Steve Reinhardt 29 * Gabe Black 30 */ 31 32#ifndef __ARCH_ALPHA_ISA_TRAITS_HH__ 33#define __ARCH_ALPHA_ISA_TRAITS_HH__ 34 35namespace LittleEndianGuest {} 36 37#include "arch/alpha/types.hh" 38#include "arch/alpha/constants.hh" 39#include "arch/alpha/regfile.hh" 40#include "config/full_system.hh" 41#include "sim/host.hh" 42 43class StaticInstPtr; 44 45#if !FULL_SYSTEM 46class SyscallReturn { 47 public: 48 template <class T> 49 SyscallReturn(T v, bool s) 50 { 51 retval = (uint64_t)v; 52 success = s; 53 } 54 55 template <class T> 56 SyscallReturn(T v) 57 { 58 success = (v >= 0); 59 retval = (uint64_t)v; 60 } 61 62 ~SyscallReturn() {} 63 64 SyscallReturn& operator=(const SyscallReturn& s) { 65 retval = s.retval; 66 success = s.success; 67 return *this; 68 } 69 70 bool successful() { return success; } 71 uint64_t value() { return retval; } 72 73 74 private: 75 uint64_t retval; 76 bool success; 77}; 78 79#endif 80 81#if FULL_SYSTEM 82#include "arch/alpha/isa_fullsys_traits.hh" 83#endif 84 85 86namespace AlphaISA 87{ 88 89using namespace LittleEndianGuest; 90 91// redirected register map, really only used for the full system case. 92extern const int reg_redir[NumIntRegs]; 93 94 StaticInstPtr decodeInst(ExtMachInst); 95 96#if !FULL_SYSTEM 97 static inline void setSyscallReturn(SyscallReturn return_value, RegFile *regs) 98 { 99 // check for error condition. Alpha syscall convention is to 100 // indicate success/failure in reg a3 (r19) and put the 101 // return value itself in the standard return value reg (v0). 102 if (return_value.successful()) { 103 // no error 104 regs->setIntReg(SyscallSuccessReg, 0); 105 regs->setIntReg(ReturnValueReg, return_value.value()); 106 } else { 107 // got an error, return details 108 regs->setIntReg(SyscallSuccessReg, (IntReg)-1); 109 regs->setIntReg(ReturnValueReg, -return_value.value()); 110 } 111 } 112#endif 113}; 114 115#endif // __ARCH_ALPHA_ISA_TRAITS_HH__ 116