gem5  v22.1.0.0
channel_addr.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, 2021 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __BASE_CHANNEL_ADDR_HH__
39 #define __BASE_CHANNEL_ADDR_HH__
40 
41 #include <ostream>
42 
43 #include "base/addr_range.hh"
44 
45 namespace gem5
46 {
47 
53 {
54  public:
55  using Type = Addr;
56 
63  explicit constexpr ChannelAddr(Type _a) : a(_a) { }
64 
66  explicit constexpr operator Type() const { return a; }
67 
69  constexpr Type value() const { return a; }
70 
71  constexpr ChannelAddr() : a(0) { }
72 
73  ChannelAddr(const AddrRange &range, Addr _a)
74  : a(range.removeIntlvBits(_a)) {}
75 
76  ChannelAddr(const ChannelAddr &) = default;
77  ChannelAddr &operator=(const ChannelAddr &) = default;
78 
79 
80  Addr getPA(const AddrRange &range) const {
81  return range.addIntlvBits(a);
82  }
83 
84  constexpr ChannelAddr operator|(const Type b) const {
85  return ChannelAddr(a | b);
86  }
87  constexpr ChannelAddr operator&(const Type b) const {
88  return ChannelAddr(a & b);
89  }
90 
91  constexpr ChannelAddr operator>>(const int b) const {
92  return ChannelAddr(a >> b);
93  }
94 
95  constexpr ChannelAddr operator<<(const int b) const {
96  return ChannelAddr(a << b);
97  }
98 
99  constexpr ChannelAddr operator^(const int b) const {
100  return ChannelAddr(a ^ b);
101  }
102 
103  constexpr ChannelAddr operator%(const int b) const {
104  return ChannelAddr(a % b);
105  }
106 
107  constexpr ChannelAddr operator*(const Type &b) const {
108  return ChannelAddr(a * b);
109  }
110 
111  constexpr ChannelAddr operator/(const Type &b) const {
112  return ChannelAddr(a / b);
113  }
114 
115  constexpr ChannelAddr operator+(const Type &b) const {
116  return ChannelAddr(a + b);
117  }
118 
119  constexpr ChannelAddr operator-(const Type &b) const {
120  return ChannelAddr(a - b);
121  }
122 
123  constexpr ChannelAddr operator|(const ChannelAddr &b) const {
124  return ChannelAddr(a | b.a);
125  }
126 
127  constexpr ChannelAddr operator&(const ChannelAddr &b) const {
128  return ChannelAddr(a & b.a);
129  }
130 
131  constexpr ChannelAddr operator^(const ChannelAddr &b) const {
132  return ChannelAddr(a ^ b.a);
133  }
134 
135  constexpr ChannelAddr operator+(const ChannelAddr &b) const {
136  return ChannelAddr(a + b.a);
137  }
138 
139  constexpr ChannelAddr operator-(const ChannelAddr &b) const {
140  return ChannelAddr(a - b.a);
141  }
142 
143  constexpr bool operator>(const ChannelAddr &b) const { return a > b.a; }
144  constexpr bool operator>=(const ChannelAddr &b) const { return a >= b.a; }
145  constexpr bool operator<(const ChannelAddr &b) const { return a < b.a; }
146  constexpr bool operator<=(const ChannelAddr &b) const { return a <= b.a; }
147  constexpr bool operator==(const ChannelAddr &b) const { return a == b.a; }
148  constexpr bool operator!=(const ChannelAddr &b) const { return a != b.a; }
149  // end of api_channel_addr
151 
152  private:
155 };
156 
163 {
164  public:
169  constexpr ChannelAddrRange()
171 
173  : _start(start), _end(end) {}
174 
176  ChannelAddrRange(AddrRange ch_range, AddrRange range);
177 
178  constexpr ChannelAddrRange(const ChannelAddrRange &) = default;
179 
180  constexpr ChannelAddr size() const { return _end - _start; }
181 
182  constexpr bool valid() const { return _start < _end; }
183 
184  constexpr ChannelAddr start() const { return _start; }
185  constexpr ChannelAddr end() const { return _end; }
186 
187  constexpr bool contains(ChannelAddr a) const {
188  return a >= _start && a < _end;
189  }
190  // end of api_channel_addr
192 
193  protected:
196 };
197 
201 std::ostream &operator<<(std::ostream &out, const gem5::ChannelAddr &addr);
202 
203 } // namespace gem5
204 
205 namespace std
206 {
207  template<>
208  struct hash<gem5::ChannelAddr>
209  {
211  typedef std::size_t result_type;
212 
214  operator()(argument_type const &a) const noexcept
215  {
216  return std::hash<gem5::ChannelAddr::Type>{}(
217  static_cast<argument_type::Type>(a));
218  }
219  };
220 }
221 
222 #endif // __BASE_CHANNEL_ADDR_HH__
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:82
The ChanneelAddrRange class describes a contiguous range of addresses in a contiguous channel-local a...
Class holding a guest address in a contiguous channel-local address space.
Definition: channel_addr.hh:53
Type a
Member holding the actual value.
Addr addIntlvBits(Addr a) const
This method adds the interleaving bits removed by removeIntlvBits.
Definition: addr_range.hh:556
ChannelAddr(const ChannelAddr &)=default
constexpr ChannelAddr operator<<(const int b) const
Definition: channel_addr.hh:95
constexpr ChannelAddr operator>>(const int b) const
Definition: channel_addr.hh:91
constexpr bool operator<(const ChannelAddr &b) const
constexpr bool operator>(const ChannelAddr &b) const
constexpr ChannelAddr(Type _a)
Explicit constructor assigning a value.
Definition: channel_addr.hh:63
constexpr ChannelAddr operator+(const Type &b) const
constexpr bool operator!=(const ChannelAddr &b) const
constexpr ChannelAddr operator|(const Type b) const
Definition: channel_addr.hh:84
constexpr ChannelAddr()
Definition: channel_addr.hh:71
constexpr ChannelAddr operator^(const int b) const
Definition: channel_addr.hh:99
ChannelAddr & operator=(const ChannelAddr &)=default
constexpr ChannelAddr operator+(const ChannelAddr &b) const
constexpr bool operator>=(const ChannelAddr &b) const
constexpr ChannelAddrRange()
constexpr ChannelAddr operator&(const ChannelAddr &b) const
constexpr ChannelAddrRange(ChannelAddr start, ChannelAddr end)
constexpr ChannelAddr operator%(const int b) const
constexpr bool operator<=(const ChannelAddr &b) const
constexpr ChannelAddr operator|(const ChannelAddr &b) const
constexpr ChannelAddr operator/(const Type &b) const
constexpr ChannelAddr start() const
constexpr bool contains(ChannelAddr a) const
constexpr ChannelAddr size() const
constexpr ChannelAddr operator*(const Type &b) const
constexpr bool valid() const
Addr getPA(const AddrRange &range) const
Definition: channel_addr.hh:80
constexpr bool operator==(const ChannelAddr &b) const
constexpr ChannelAddr operator&(const Type b) const
Definition: channel_addr.hh:87
constexpr ChannelAddr operator-(const ChannelAddr &b) const
constexpr Type value() const
Converting back to the value type.
Definition: channel_addr.hh:69
ChannelAddr(const AddrRange &range, Addr _a)
Definition: channel_addr.hh:73
constexpr ChannelAddr operator^(const ChannelAddr &b) const
constexpr ChannelAddr operator-(const Type &b) const
constexpr ChannelAddrRange(const ChannelAddrRange &)=default
constexpr ChannelAddr end() const
Bitfield< 7 > b
Definition: misc_types.hh:388
Bitfield< 8 > a
Definition: misc_types.hh:66
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
std::ostream & operator<<(std::ostream &os, const ArmSemihosting::InPlaceArg &ipa)
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2826
result_type operator()(argument_type const &a) const noexcept
gem5::ChannelAddr argument_type

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