gem5  v22.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 
34 namespace gem5
35 {
36 
56 {
57  public:
58 
67  SyscallReturn(int64_t v) : _value(v), _count(1) {}
68 
71 
74  SyscallReturn(int64_t v1, int64_t v2) :
75  _value(v1), _value2(v2), _count(2)
76  {}
77 
79  static SyscallReturn
81  {
82  SyscallReturn s(0);
83  s.retryFlag = true;
84  return s;
85  }
86 
88 
90  bool
91  successful() const
92  {
93  return (_value >= 0 || _value <= -4096);
94  }
95 
97  bool needsRetry() const { return retryFlag; }
98 
100  bool suppressed() const { return _count == 0; }
101 
103  int count() const { return _count; }
104 
106  int64_t
107  returnValue() const
108  {
109  assert(successful());
110  return _value;
111  }
112 
114  int
115  errnoValue() const
116  {
117  assert(!successful());
118  return -_value;
119  }
120 
122  int64_t encodedValue() const { return _value; }
123  int64_t value2() const { return _value2; }
124 
125  private:
126  int64_t _value, _value2;
127  int _count;
128 
129  bool retryFlag = false;
130 };
131 
132 } // namespace gem5
133 
134 #endif
This class represents the return value from an emulated system call, including any errno setting.
bool suppressed() const
Should returning this value be suppressed?
SyscallReturn(int64_t v)
For simplicity, allow the object to be initialized with a single signed integer using the same positi...
static SyscallReturn retry()
Pseudo-constructor to create an instance with the retry flag set.
int64_t encodedValue() const
The encoded value (as described above)
bool needsRetry() const
Does the syscall need to be retried?
int64_t returnValue() const
The return value.
int count() const
How many values did the syscall attempt to return?
int64_t value2() const
SyscallReturn()
A SyscallReturn constructed with no value means don't return anything.
SyscallReturn(int64_t v1, int64_t v2)
A SyscallReturn constructed with two values means put the second value in additional return registers...
bool successful() const
Was the system call successful?
int errnoValue() const
The errno value.
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 0 > v
Definition: pagetable.hh:65
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

Generated on Wed Dec 21 2022 10:22:40 for gem5 by doxygen 1.9.1