gem5  v21.1.0.2
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__
gem5::operator<<
std::ostream & operator<<(std::ostream &os, const ArmSemihosting::InPlaceArg &ipa)
Definition: semihosting.cc:1045
gem5::ChannelAddr::operator=
ChannelAddr & operator=(const ChannelAddr &)=default
gem5::ChannelAddr::value
constexpr Type value() const
Converting back to the value type.
Definition: channel_addr.hh:69
gem5::AddrRange::addIntlvBits
Addr addIntlvBits(Addr a) const
This method adds the interleaving bits removed by removeIntlvBits.
Definition: addr_range.hh:521
gem5::ChannelAddr::operator^
constexpr ChannelAddr operator^(const int b) const
Definition: channel_addr.hh:99
std::hash< gem5::ChannelAddr >::argument_type
gem5::ChannelAddr argument_type
Definition: channel_addr.hh:210
gem5::ChannelAddrRange::_start
ChannelAddr _start
Definition: channel_addr.hh:194
std::hash< gem5::ChannelAddr >::operator()
result_type operator()(argument_type const &a) const noexcept
Definition: channel_addr.hh:214
gem5::ChannelAddrRange::ChannelAddrRange
constexpr ChannelAddrRange()
Definition: channel_addr.hh:169
gem5::ChannelAddr::operator+
constexpr ChannelAddr operator+(const ChannelAddr &b) const
Definition: channel_addr.hh:135
gem5::ChannelAddr::operator<
constexpr bool operator<(const ChannelAddr &b) const
Definition: channel_addr.hh:145
gem5::ArmISA::a
Bitfield< 8 > a
Definition: misc_types.hh:65
gem5::ChannelAddr::operator<<
constexpr ChannelAddr operator<<(const int b) const
Definition: channel_addr.hh:95
gem5::ChannelAddr::operator>>
constexpr ChannelAddr operator>>(const int b) const
Definition: channel_addr.hh:91
gem5::ChannelAddr::operator+
constexpr ChannelAddr operator+(const Type &b) const
Definition: channel_addr.hh:115
std::hash< gem5::ChannelAddr >::result_type
std::size_t result_type
Definition: channel_addr.hh:211
gem5::ChannelAddrRange::size
constexpr ChannelAddr size() const
Definition: channel_addr.hh:180
gem5::ChannelAddrRange::end
constexpr ChannelAddr end() const
Definition: channel_addr.hh:185
gem5::ChannelAddr::operator<=
constexpr bool operator<=(const ChannelAddr &b) const
Definition: channel_addr.hh:146
gem5::ChannelAddr::ChannelAddr
constexpr ChannelAddr()
Definition: channel_addr.hh:71
gem5::ChannelAddr::getPA
Addr getPA(const AddrRange &range) const
Definition: channel_addr.hh:80
gem5::ChannelAddr::operator*
constexpr ChannelAddr operator*(const Type &b) const
Definition: channel_addr.hh:107
gem5::ChannelAddrRange::ChannelAddrRange
constexpr ChannelAddrRange(ChannelAddr start, ChannelAddr end)
Definition: channel_addr.hh:172
gem5::ChannelAddr::operator&
constexpr ChannelAddr operator&(const ChannelAddr &b) const
Definition: channel_addr.hh:127
gem5::ChannelAddr::operator>
constexpr bool operator>(const ChannelAddr &b) const
Definition: channel_addr.hh:143
gem5::ChannelAddrRange::valid
constexpr bool valid() const
Definition: channel_addr.hh:182
gem5::ChannelAddr::operator/
constexpr ChannelAddr operator/(const Type &b) const
Definition: channel_addr.hh:111
gem5::ChannelAddr::Type
Addr Type
Definition: channel_addr.hh:55
gem5::ChannelAddr::ChannelAddr
ChannelAddr(const AddrRange &range, Addr _a)
Definition: channel_addr.hh:73
gem5::ArmISA::b
Bitfield< 7 > b
Definition: misc_types.hh:381
gem5::ChannelAddrRange::_end
ChannelAddr _end
Definition: channel_addr.hh:195
gem5::ChannelAddrRange
The ChanneelAddrRange class describes a contiguous range of addresses in a contiguous channel-local a...
Definition: channel_addr.hh:162
gem5::ChannelAddr::operator==
constexpr bool operator==(const ChannelAddr &b) const
Definition: channel_addr.hh:147
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ChannelAddrRange::start
constexpr ChannelAddr start() const
Definition: channel_addr.hh:184
addr_range.hh
gem5::ChannelAddr::operator!=
constexpr bool operator!=(const ChannelAddr &b) const
Definition: channel_addr.hh:148
gem5::ChannelAddr::operator|
constexpr ChannelAddr operator|(const Type b) const
Definition: channel_addr.hh:84
std
Overload hash function for BasicBlockRange type.
Definition: types.hh:111
gem5::ChannelAddr
Class holding a guest address in a contiguous channel-local address space.
Definition: channel_addr.hh:52
gem5::ChannelAddr::operator^
constexpr ChannelAddr operator^(const ChannelAddr &b) const
Definition: channel_addr.hh:131
gem5::ChannelAddr::operator>=
constexpr bool operator>=(const ChannelAddr &b) const
Definition: channel_addr.hh:144
gem5::ChannelAddr::operator%
constexpr ChannelAddr operator%(const int b) const
Definition: channel_addr.hh:103
gem5::ChannelAddr::operator&
constexpr ChannelAddr operator&(const Type b) const
Definition: channel_addr.hh:87
gem5::ChannelAddr::operator-
constexpr ChannelAddr operator-(const ChannelAddr &b) const
Definition: channel_addr.hh:139
gem5::ChannelAddrRange::contains
constexpr bool contains(ChannelAddr a) const
Definition: channel_addr.hh:187
gem5::ChannelAddr::ChannelAddr
constexpr ChannelAddr(Type _a)
Explicit constructor assigning a value.
Definition: channel_addr.hh:63
gem5::AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:71
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ChannelAddr::operator|
constexpr ChannelAddr operator|(const ChannelAddr &b) const
Definition: channel_addr.hh:123
gem5::ChannelAddr::a
Type a
Member holding the actual value.
Definition: channel_addr.hh:154
gem5::ChannelAddr::operator-
constexpr ChannelAddr operator-(const Type &b) const
Definition: channel_addr.hh:119
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:24:53 for gem5 by doxygen 1.8.17