isa_traits.hh revision 2460
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
78namespace AlphaISA
79{
80
81using namespace LittleEndianGuest;
82
83// redirected register map, really only used for the full system case.
84extern const int reg_redir[NumIntRegs];
85
86#if FULL_SYSTEM
87
88#include "arch/alpha/isa_fullsys_traits.hh"
89
90#endif
91
92    StaticInstPtr decodeInst(ExtMachInst);
93
94#if !FULL_SYSTEM
95    static inline void setSyscallReturn(SyscallReturn return_value, RegFile *regs)
96    {
97        // check for error condition.  Alpha syscall convention is to
98        // indicate success/failure in reg a3 (r19) and put the
99        // return value itself in the standard return value reg (v0).
100        if (return_value.successful()) {
101            // no error
102            regs->intRegFile[SyscallSuccessReg] = 0;
103            regs->intRegFile[ReturnValueReg] = return_value.value();
104        } else {
105            // got an error, return details
106            regs->intRegFile[SyscallSuccessReg] = (IntReg) -1;
107            regs->intRegFile[ReturnValueReg] = -return_value.value();
108        }
109    }
110#endif
111};
112
113#endif // __ARCH_ALPHA_ISA_TRAITS_HH__
114