isa_traits.hh (2632:1bb2f91485ea) isa_traits.hh (2665:a124942bacb8)
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.
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
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->setIntReg(SyscallSuccessReg, 0);
102 regs->setIntReg(ReturnValueReg, return_value.value());
103 } else {
104 // got an error, return details
105 regs->setIntReg(SyscallSuccessReg, (IntReg)-1);
106 regs->setIntReg(ReturnValueReg, -return_value.value());
107 }
108 }
109#endif
110};
111
112#endif // __ARCH_ALPHA_ISA_TRAITS_HH__
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__