gem5  v20.1.0.0
channel_addr.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 
50 {
51  public:
52  using Type = Addr;
53 
60  explicit constexpr ChannelAddr(Type _a) : a(_a) { }
61 
63  explicit constexpr operator Type() const { return a; }
64 
66  constexpr Type value() const { return a; }
67 
68  constexpr ChannelAddr() : a(0) { }
69 
70  ChannelAddr(const AddrRange &range, Addr _a)
71  : a(range.removeIntlvBits(_a)) {}
72 
73  ChannelAddr(const ChannelAddr &) = default;
74  ChannelAddr &operator=(const ChannelAddr &) = default;
75 
76 
77  Addr getPA(const AddrRange &range) const {
78  return range.addIntlvBits(a);
79  }
80 
81  constexpr ChannelAddr operator|(const Type b) const {
82  return ChannelAddr(a | b);
83  }
84  constexpr ChannelAddr operator&(const Type b) const {
85  return ChannelAddr(a & b);
86  }
87 
88  constexpr ChannelAddr operator>>(const int b) const {
89  return ChannelAddr(a >> b);
90  }
91 
92  constexpr ChannelAddr operator<<(const int b) const {
93  return ChannelAddr(a << b);
94  }
95 
96  constexpr ChannelAddr operator*(const Type &b) const {
97  return ChannelAddr(a * b);
98  }
99 
100  constexpr ChannelAddr operator/(const Type &b) const {
101  return ChannelAddr(a / b);
102  }
103 
104  constexpr ChannelAddr operator+(const Type &b) const {
105  return ChannelAddr(a + b);
106  }
107 
108  constexpr ChannelAddr operator-(const Type &b) const {
109  return ChannelAddr(a - b);
110  }
111 
112  constexpr ChannelAddr operator|(const ChannelAddr &b) const {
113  return ChannelAddr(a | b.a);
114  }
115 
116  constexpr ChannelAddr operator&(const ChannelAddr &b) const {
117  return ChannelAddr(a & b.a);
118  }
119 
120  constexpr ChannelAddr operator^(const ChannelAddr &b) const {
121  return ChannelAddr(a ^ b.a);
122  }
123 
124  constexpr ChannelAddr operator+(const ChannelAddr &b) const {
125  return ChannelAddr(a + b.a);
126  }
127 
128  constexpr ChannelAddr operator-(const ChannelAddr &b) const {
129  return ChannelAddr(a - b.a);
130  }
131 
132  constexpr bool operator>(const ChannelAddr &b) const { return a > b.a; }
133  constexpr bool operator>=(const ChannelAddr &b) const { return a >= b.a; }
134  constexpr bool operator<(const ChannelAddr &b) const { return a < b.a; }
135  constexpr bool operator<=(const ChannelAddr &b) const { return a <= b.a; }
136  constexpr bool operator==(const ChannelAddr &b) const { return a == b.a; }
137  constexpr bool operator!=(const ChannelAddr &b) const { return a != b.a; }
138  // end of api_channel_addr
140 
141  private:
144 };
145 
151 {
152  public:
157  constexpr ChannelAddrRange()
159 
161  : _start(start), _end(end) {}
162 
164  ChannelAddrRange(AddrRange ch_range, AddrRange range);
165 
166  constexpr ChannelAddrRange(const ChannelAddrRange &) = default;
167 
168  constexpr ChannelAddr size() const { return _end - _start + 1; }
169 
170  constexpr bool valid() const { return _start <= _end; }
171 
172  constexpr ChannelAddr start() const { return _start; }
173  constexpr ChannelAddr end() const { return _end; }
174 
175  constexpr bool contains(ChannelAddr a) const {
176  return a >= _start && a <= _end;
177  }
178  // end of api_channel_addr
180 
181  protected:
184 };
185 
186 namespace std
187 {
188  template<>
189  struct hash<ChannelAddr>
190  {
192  typedef std::size_t result_type;
193 
195  operator()(argument_type const &a) const noexcept {
196  return std::hash<ChannelAddr::Type>{}(
197  static_cast<argument_type::Type>(a));
198  }
199  };
200 }
201 
205 std::ostream &operator<<(std::ostream &out, const ChannelAddr &addr);
206 
207 #endif // __BASE_CHANNEL_ADDR_HH__
ChannelAddr::getPA
Addr getPA(const AddrRange &range) const
Definition: channel_addr.hh:77
ChannelAddrRange::start
constexpr ChannelAddr start() const
Definition: channel_addr.hh:172
ChannelAddr::Type
Addr Type
Definition: channel_addr.hh:52
ChannelAddr::operator-
constexpr ChannelAddr operator-(const Type &b) const
Definition: channel_addr.hh:108
ChannelAddr::operator!=
constexpr bool operator!=(const ChannelAddr &b) const
Definition: channel_addr.hh:137
ChannelAddr::operator>>
constexpr ChannelAddr operator>>(const int b) const
Definition: channel_addr.hh:88
ChannelAddr::operator<=
constexpr bool operator<=(const ChannelAddr &b) const
Definition: channel_addr.hh:135
ChannelAddrRange::contains
constexpr bool contains(ChannelAddr a) const
Definition: channel_addr.hh:175
ChannelAddr::ChannelAddr
constexpr ChannelAddr(Type _a)
Explicit constructor assigning a value.
Definition: channel_addr.hh:60
ChannelAddr::operator<<
constexpr ChannelAddr operator<<(const int b) const
Definition: channel_addr.hh:92
ChannelAddr::operator&
constexpr ChannelAddr operator&(const Type b) const
Definition: channel_addr.hh:84
std::hash< ChannelAddr >::operator()
result_type operator()(argument_type const &a) const noexcept
Definition: channel_addr.hh:195
ChannelAddrRange
The ChanneelAddrRange class describes a contiguous range of addresses in a contiguous channel-local a...
Definition: channel_addr.hh:150
ChannelAddrRange::end
constexpr ChannelAddr end() const
Definition: channel_addr.hh:173
ChannelAddr::operator=
ChannelAddr & operator=(const ChannelAddr &)=default
ChannelAddr::operator>
constexpr bool operator>(const ChannelAddr &b) const
Definition: channel_addr.hh:132
ChannelAddrRange::valid
constexpr bool valid() const
Definition: channel_addr.hh:170
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
ChannelAddr::operator*
constexpr ChannelAddr operator*(const Type &b) const
Definition: channel_addr.hh:96
ChannelAddr::a
Type a
Member holding the actual value.
Definition: channel_addr.hh:143
ChannelAddr
Class holding a guest address in a contiguous channel-local address space.
Definition: channel_addr.hh:49
ChannelAddrRange::ChannelAddrRange
constexpr ChannelAddrRange()
Definition: channel_addr.hh:157
ChannelAddr::operator+
constexpr ChannelAddr operator+(const ChannelAddr &b) const
Definition: channel_addr.hh:124
ChannelAddr::operator==
constexpr bool operator==(const ChannelAddr &b) const
Definition: channel_addr.hh:136
ChannelAddr::operator|
constexpr ChannelAddr operator|(const ChannelAddr &b) const
Definition: channel_addr.hh:112
AddrRange::addIntlvBits
Addr addIntlvBits(Addr a) const
This method adds the interleaving bits removed by removeIntlvBits.
Definition: addr_range.hh:512
ChannelAddr::operator^
constexpr ChannelAddr operator^(const ChannelAddr &b) const
Definition: channel_addr.hh:120
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ChannelAddrRange::size
constexpr ChannelAddr size() const
Definition: channel_addr.hh:168
addr_range.hh
ChannelAddr::operator/
constexpr ChannelAddr operator/(const Type &b) const
Definition: channel_addr.hh:100
operator<<
std::ostream & operator<<(std::ostream &out, const ChannelAddr &addr)
Definition: channel_addr.cc:58
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
ChannelAddr::operator<
constexpr bool operator<(const ChannelAddr &b) const
Definition: channel_addr.hh:134
std::hash< ChannelAddr >::result_type
std::size_t result_type
Definition: channel_addr.hh:192
addr
ip6_addr_t addr
Definition: inet.hh:423
ChannelAddr::ChannelAddr
ChannelAddr(const AddrRange &range, Addr _a)
Definition: channel_addr.hh:70
ChannelAddr::operator+
constexpr ChannelAddr operator+(const Type &b) const
Definition: channel_addr.hh:104
ChannelAddr::operator&
constexpr ChannelAddr operator&(const ChannelAddr &b) const
Definition: channel_addr.hh:116
ChannelAddr::value
constexpr Type value() const
Converting back to the value type.
Definition: channel_addr.hh:66
ChannelAddr::operator|
constexpr ChannelAddr operator|(const Type b) const
Definition: channel_addr.hh:81
ChannelAddr::ChannelAddr
constexpr ChannelAddr()
Definition: channel_addr.hh:68
ChannelAddrRange::ChannelAddrRange
constexpr ChannelAddrRange(ChannelAddr start, ChannelAddr end)
Definition: channel_addr.hh:160
ChannelAddrRange::_start
ChannelAddr _start
Definition: channel_addr.hh:182
ChannelAddr::operator>=
constexpr bool operator>=(const ChannelAddr &b) const
Definition: channel_addr.hh:133
ChannelAddrRange::_end
ChannelAddr _end
Definition: channel_addr.hh:183
ChannelAddr::operator-
constexpr ChannelAddr operator-(const ChannelAddr &b) const
Definition: channel_addr.hh:128
std::hash< ChannelAddr >::argument_type
ChannelAddr argument_type
Definition: channel_addr.hh:191

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