gem5  v20.1.0.0
syscall_return.hh
Go to the documentation of this file.
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 __SIM_SYSCALLRETURN_HH__
30 #define __SIM_SYSCALLRETURN_HH__
31 
32 #include <inttypes.h>
33 
53 {
54  public:
55 
64  SyscallReturn(int64_t v) : _value(v), _count(1) {}
65 
68 
71  SyscallReturn(int64_t v1, int64_t v2) :
72  _value(v1), _value2(v2), _count(2)
73  {}
74 
76  static SyscallReturn
78  {
79  SyscallReturn s(0);
80  s.retryFlag = true;
81  return s;
82  }
83 
85 
87  bool
88  successful() const
89  {
90  return (_value >= 0 || _value <= -4096);
91  }
92 
94  bool needsRetry() const { return retryFlag; }
95 
97  bool suppressed() const { return _count == 0; }
98 
100  int count() const { return _count; }
101 
103  int64_t
104  returnValue() const
105  {
106  assert(successful());
107  return _value;
108  }
109 
111  int
112  errnoValue() const
113  {
114  assert(!successful());
115  return -_value;
116  }
117 
119  int64_t encodedValue() const { return _value; }
120  int64_t value2() const { return _value2; }
121 
122  private:
123  int64_t _value, _value2;
124  int _count;
125 
126  bool retryFlag = false;
127 };
128 
129 #endif
SyscallReturn::_count
int _count
Definition: syscall_return.hh:124
SyscallReturn::value2
int64_t value2() const
Definition: syscall_return.hh:120
SyscallReturn::retryFlag
bool retryFlag
Definition: syscall_return.hh:126
SyscallReturn::returnValue
int64_t returnValue() const
The return value.
Definition: syscall_return.hh:104
SyscallReturn::suppressed
bool suppressed() const
Should returning this value be suppressed?
Definition: syscall_return.hh:97
SyscallReturn::_value
int64_t _value
Definition: syscall_return.hh:123
SyscallReturn::errnoValue
int errnoValue() const
The errno value.
Definition: syscall_return.hh:112
SyscallReturn::needsRetry
bool needsRetry() const
Does the syscall need to be retried?
Definition: syscall_return.hh:94
SyscallReturn::SyscallReturn
SyscallReturn()
A SyscallReturn constructed with no value means don't return anything.
Definition: syscall_return.hh:67
SyscallReturn
This class represents the return value from an emulated system call, including any errno setting.
Definition: syscall_return.hh:52
SyscallReturn::~SyscallReturn
~SyscallReturn()
Definition: syscall_return.hh:84
SyscallReturn::SyscallReturn
SyscallReturn(int64_t v1, int64_t v2)
A SyscallReturn constructed with two values means put the second value in additional return registers...
Definition: syscall_return.hh:71
SyscallReturn::encodedValue
int64_t encodedValue() const
The encoded value (as described above)
Definition: syscall_return.hh:119
SyscallReturn::count
int count() const
How many values did the syscall attempt to return?
Definition: syscall_return.hh:100
SyscallReturn::_value2
int64_t _value2
Definition: syscall_return.hh:123
SyscallReturn::retry
static SyscallReturn retry()
Pseudo-constructor to create an instance with the retry flag set.
Definition: syscall_return.hh:77
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
ArmISA::v
Bitfield< 28 > v
Definition: miscregs_types.hh:51
SyscallReturn::successful
bool successful() const
Was the system call successful?
Definition: syscall_return.hh:88
SyscallReturn::SyscallReturn
SyscallReturn(int64_t v)
For simplicity, allow the object to be initialized with a single signed integer using the same positi...
Definition: syscall_return.hh:64

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17