port_proxy.hh (14008:e36048ba1c2c) port_proxy.hh (14009:a4b36ce75361)
1/*
2 * Copyright (c) 2011-2013, 2018 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

--- 86 unchanged lines hidden (view full) ---

95
96
97 /** Fixed functionality for use in base classes. */
98
99 /**
100 * Read size bytes memory at physical address and store in p.
101 */
102 void readBlobPhys(Addr addr, Request::Flags flags,
1/*
2 * Copyright (c) 2011-2013, 2018 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

--- 86 unchanged lines hidden (view full) ---

95
96
97 /** Fixed functionality for use in base classes. */
98
99 /**
100 * Read size bytes memory at physical address and store in p.
101 */
102 void readBlobPhys(Addr addr, Request::Flags flags,
103 uint8_t* p, int size) const;
103 void *p, int size) const;
104
105 /**
106 * Write size bytes from p to physical address.
107 */
108 void writeBlobPhys(Addr addr, Request::Flags flags,
104
105 /**
106 * Write size bytes from p to physical address.
107 */
108 void writeBlobPhys(Addr addr, Request::Flags flags,
109 const uint8_t* p, int size) const;
109 const void *p, int size) const;
110
111 /**
112 * Fill size bytes starting at physical addr with byte value val.
113 */
114 void memsetBlobPhys(Addr addr, Request::Flags flags,
115 uint8_t v, int size) const;
116
117
118
119 /** Methods to override in base classes */
120
121 /**
122 * Read size bytes memory at address and store in p.
123 * Returns true on success and false on failure.
124 */
125 virtual bool
110
111 /**
112 * Fill size bytes starting at physical addr with byte value val.
113 */
114 void memsetBlobPhys(Addr addr, Request::Flags flags,
115 uint8_t v, int size) const;
116
117
118
119 /** Methods to override in base classes */
120
121 /**
122 * Read size bytes memory at address and store in p.
123 * Returns true on success and false on failure.
124 */
125 virtual bool
126 tryReadBlob(Addr addr, uint8_t *p, int size) const
126 tryReadBlob(Addr addr, void *p, int size) const
127 {
128 readBlobPhys(addr, 0, p, size);
129 return true;
130 }
131
132 /**
133 * Write size bytes from p to address.
134 * Returns true on success and false on failure.
135 */
136 virtual bool
127 {
128 readBlobPhys(addr, 0, p, size);
129 return true;
130 }
131
132 /**
133 * Write size bytes from p to address.
134 * Returns true on success and false on failure.
135 */
136 virtual bool
137 tryWriteBlob(Addr addr, const uint8_t *p, int size) const
137 tryWriteBlob(Addr addr, const void *p, int size) const
138 {
139 writeBlobPhys(addr, 0, p, size);
140 return true;
141 }
142
143 /**
144 * Fill size bytes starting at addr with byte value val.
145 * Returns true on success and false on failure.

--- 8 unchanged lines hidden (view full) ---

154
155
156 /** Higher level interfaces based on the above. */
157
158 /**
159 * Same as tryReadBlob, but insists on success.
160 */
161 void
138 {
139 writeBlobPhys(addr, 0, p, size);
140 return true;
141 }
142
143 /**
144 * Fill size bytes starting at addr with byte value val.
145 * Returns true on success and false on failure.

--- 8 unchanged lines hidden (view full) ---

154
155
156 /** Higher level interfaces based on the above. */
157
158 /**
159 * Same as tryReadBlob, but insists on success.
160 */
161 void
162 readBlob(Addr addr, uint8_t* p, int size) const
162 readBlob(Addr addr, void *p, int size) const
163 {
164 if (!tryReadBlob(addr, p, size))
165 fatal("readBlob(%#x, ...) failed", addr);
166 }
167
168 /**
169 * Same as tryWriteBlob, but insists on success.
170 */
171 void
163 {
164 if (!tryReadBlob(addr, p, size))
165 fatal("readBlob(%#x, ...) failed", addr);
166 }
167
168 /**
169 * Same as tryWriteBlob, but insists on success.
170 */
171 void
172 writeBlob(Addr addr, const uint8_t* p, int size) const
172 writeBlob(Addr addr, const void *p, int size) const
173 {
174 if (!tryWriteBlob(addr, p, size))
175 fatal("writeBlob(%#x, ...) failed", addr);
176 }
177
178 /**
179 * Same as tryMemsetBlob, but insists on success.
180 */

--- 64 unchanged lines hidden (view full) ---

245};
246
247
248template <typename T>
249T
250PortProxy::read(Addr address) const
251{
252 T data;
173 {
174 if (!tryWriteBlob(addr, p, size))
175 fatal("writeBlob(%#x, ...) failed", addr);
176 }
177
178 /**
179 * Same as tryMemsetBlob, but insists on success.
180 */

--- 64 unchanged lines hidden (view full) ---

245};
246
247
248template <typename T>
249T
250PortProxy::read(Addr address) const
251{
252 T data;
253 readBlob(address, (uint8_t*)&data, sizeof(T));
253 readBlob(address, &data, sizeof(T));
254 return data;
255}
256
257template <typename T>
258void
259PortProxy::write(Addr address, T data) const
260{
254 return data;
255}
256
257template <typename T>
258void
259PortProxy::write(Addr address, T data) const
260{
261 writeBlob(address, (uint8_t*)&data, sizeof(T));
261 writeBlob(address, &data, sizeof(T));
262}
263
264template <typename T>
265T
266PortProxy::read(Addr address, ByteOrder byte_order) const
267{
268 T data;
262}
263
264template <typename T>
265T
266PortProxy::read(Addr address, ByteOrder byte_order) const
267{
268 T data;
269 readBlob(address, (uint8_t*)&data, sizeof(T));
269 readBlob(address, &data, sizeof(T));
270 return gtoh(data, byte_order);
271}
272
273template <typename T>
274void
275PortProxy::write(Addr address, T data, ByteOrder byte_order) const
276{
277 data = htog(data, byte_order);
270 return gtoh(data, byte_order);
271}
272
273template <typename T>
274void
275PortProxy::write(Addr address, T data, ByteOrder byte_order) const
276{
277 data = htog(data, byte_order);
278 writeBlob(address, (uint8_t*)&data, sizeof(T));
278 writeBlob(address, &data, sizeof(T));
279}
280
281#endif // __MEM_PORT_PROXY_HH__
279}
280
281#endif // __MEM_PORT_PROXY_HH__