gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
port_proxy.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2013 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  * Authors: Andreas Hansson
38  */
39 
59 #ifndef __MEM_PORT_PROXY_HH__
60 #define __MEM_PORT_PROXY_HH__
61 
62 #include "config/the_isa.hh"
63 #if THE_ISA != NULL_ISA
64  #include "arch/isa_traits.hh"
65 #endif
66 
67 #include "mem/port.hh"
68 #include "sim/byteswap.hh"
69 
84 class PortProxy
85 {
86  private:
87 
90 
92  const unsigned int _cacheLineSize;
93 
94  public:
95  PortProxy(MasterPort &port, unsigned int cacheLineSize) :
96  _port(port), _cacheLineSize(cacheLineSize) { }
97  virtual ~PortProxy() { }
98 
102  virtual void readBlob(Addr addr, uint8_t* p, int size) const;
103 
107  virtual void writeBlob(Addr addr, const uint8_t* p, int size) const;
108 
112  virtual void memsetBlob(Addr addr, uint8_t v, int size) const;
113 
117  template <typename T>
118  T read(Addr address) const;
119 
123  template <typename T>
124  void write(Addr address, T data) const;
125 
126 #if THE_ISA != NULL_ISA
127 
131  template <typename T>
132  T readGtoH(Addr address) const;
133 
138  template <typename T>
139  void writeHtoG(Addr address, T data) const;
140 #endif
141 };
142 
143 
144 template <typename T>
145 T
146 PortProxy::read(Addr address) const
147 {
148  T data;
149  readBlob(address, (uint8_t*)&data, sizeof(T));
150  return data;
151 }
152 
153 template <typename T>
154 void
155 PortProxy::write(Addr address, T data) const
156 {
157  writeBlob(address, (uint8_t*)&data, sizeof(T));
158 }
159 
160 #if THE_ISA != NULL_ISA
161 template <typename T>
162 T
163 PortProxy::readGtoH(Addr address) const
164 {
165  T data;
166  readBlob(address, (uint8_t*)&data, sizeof(T));
167  return TheISA::gtoh(data);
168 }
169 
170 template <typename T>
171 void
172 PortProxy::writeHtoG(Addr address, T data) const
173 {
174  data = TheISA::htog(data);
175  writeBlob(address, (uint8_t*)&data, sizeof(T));
176 }
177 #endif
178 
179 #endif // __MEM_PORT_PROXY_HH__
MasterPort & _port
The actual physical port used by this proxy.
Definition: port_proxy.hh:89
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
T htog(T value)
Definition: byteswap.hh:177
Bitfield< 28 > v
Definition: miscregs.hh:1366
const unsigned int _cacheLineSize
Granularity of any transactions issued through this proxy.
Definition: port_proxy.hh:92
void write(Addr address, T data) const
Write object T to address.
Definition: port_proxy.hh:155
ip6_addr_t addr
Definition: inet.hh:335
Port Object Declaration.
PortProxy(MasterPort &port, unsigned int cacheLineSize)
Definition: port_proxy.hh:95
T gtoh(T value)
Definition: byteswap.hh:179
const char data[]
Definition: circlebuf.cc:43
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:146
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
virtual void readBlob(Addr addr, uint8_t *p, int size) const
Read size bytes memory at address and store in p.
Definition: port_proxy.cc:45
This object is a proxy for a structural port, to be used for debug accesses.
Definition: port_proxy.hh:84
int size()
Definition: pagetable.hh:146
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const
Write size bytes from p to address.
Definition: port_proxy.cc:58
virtual ~PortProxy()
Definition: port_proxy.hh:97
virtual void memsetBlob(Addr addr, uint8_t v, int size) const
Fill size bytes starting at addr with byte value val.
Definition: port_proxy.cc:71
Bitfield< 0 > p

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6