port_proxy.hh (14007:36f842f523c6) | port_proxy.hh (14008:e36048ba1c2c) |
---|---|
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 --- 78 unchanged lines hidden (view full) --- 87 const unsigned int _cacheLineSize; 88 89 public: 90 PortProxy(MasterPort &port, unsigned int cacheLineSize) : 91 _port(port), _cacheLineSize(cacheLineSize) 92 {} 93 virtual ~PortProxy() { } 94 | 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 --- 78 unchanged lines hidden (view full) --- 87 const unsigned int _cacheLineSize; 88 89 public: 90 PortProxy(MasterPort &port, unsigned int cacheLineSize) : 91 _port(port), _cacheLineSize(cacheLineSize) 92 {} 93 virtual ~PortProxy() { } 94 |
95 96 97 /** Fixed functionality for use in base classes. */ 98 |
|
95 /** | 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; 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; 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 /** |
|
96 * Read size bytes memory at address and store in p. | 122 * Read size bytes memory at address and store in p. |
123 * Returns true on success and false on failure. |
|
97 */ | 124 */ |
98 virtual void 99 readBlob(Addr addr, uint8_t* p, int size) const | 125 virtual bool 126 tryReadBlob(Addr addr, uint8_t *p, int size) const |
100 { 101 readBlobPhys(addr, 0, p, size); | 127 { 128 readBlobPhys(addr, 0, p, size); |
129 return true; |
|
102 } 103 104 /** 105 * Write size bytes from p to address. | 130 } 131 132 /** 133 * Write size bytes from p to address. |
134 * Returns true on success and false on failure. |
|
106 */ | 135 */ |
107 virtual void 108 writeBlob(Addr addr, const uint8_t* p, int size) const | 136 virtual bool 137 tryWriteBlob(Addr addr, const uint8_t *p, int size) const |
109 { 110 writeBlobPhys(addr, 0, p, size); | 138 { 139 writeBlobPhys(addr, 0, p, size); |
140 return true; |
|
111 } 112 113 /** 114 * Fill size bytes starting at addr with byte value val. | 141 } 142 143 /** 144 * Fill size bytes starting at addr with byte value val. |
145 * Returns true on success and false on failure. |
|
115 */ | 146 */ |
116 virtual void 117 memsetBlob(Addr addr, uint8_t v, int size) const | 147 virtual bool 148 tryMemsetBlob(Addr addr, uint8_t val, int size) const |
118 { | 149 { |
119 memsetBlobPhys(addr, 0, v, size); | 150 memsetBlobPhys(addr, 0, val, size); 151 return true; |
120 } 121 | 152 } 153 |
154 155 156 /** Higher level interfaces based on the above. */ 157 |
|
122 /** | 158 /** |
123 * Read size bytes memory at physical address and store in p. | 159 * Same as tryReadBlob, but insists on success. |
124 */ | 160 */ |
125 void readBlobPhys(Addr addr, Request::Flags flags, 126 uint8_t* p, int size) const; | 161 void 162 readBlob(Addr addr, uint8_t* p, int size) const 163 { 164 if (!tryReadBlob(addr, p, size)) 165 fatal("readBlob(%#x, ...) failed", addr); 166 } |
127 128 /** | 167 168 /** |
129 * Write size bytes from p to physical address. | 169 * Same as tryWriteBlob, but insists on success. |
130 */ | 170 */ |
131 void writeBlobPhys(Addr addr, Request::Flags flags, 132 const uint8_t* p, int size) const; | 171 void 172 writeBlob(Addr addr, const uint8_t* p, int size) const 173 { 174 if (!tryWriteBlob(addr, p, size)) 175 fatal("writeBlob(%#x, ...) failed", addr); 176 } |
133 134 /** | 177 178 /** |
135 * Fill size bytes starting at physical addr with byte value val. | 179 * Same as tryMemsetBlob, but insists on success. |
136 */ | 180 */ |
137 void memsetBlobPhys(Addr addr, Request::Flags flags, 138 uint8_t v, int size) const; | 181 void 182 memsetBlob(Addr addr, uint8_t v, int size) const 183 { 184 if (!tryMemsetBlob(addr, v, size)) 185 fatal("memsetBlob(%#x, ...) failed", addr); 186 } |
139 140 /** 141 * Read sizeof(T) bytes from address and return as object T. 142 */ 143 template <typename T> 144 T read(Addr address) const; 145 146 /** --- 10 unchanged lines hidden (view full) --- 157 T read(Addr address, ByteOrder guest_byte_order) const; 158 159 /** 160 * Write object T to address. Writes sizeof(T) bytes. 161 * Performs endianness conversion from host to the selected guest order. 162 */ 163 template <typename T> 164 void write(Addr address, T data, ByteOrder guest_byte_order) const; | 187 188 /** 189 * Read sizeof(T) bytes from address and return as object T. 190 */ 191 template <typename T> 192 T read(Addr address) const; 193 194 /** --- 10 unchanged lines hidden (view full) --- 205 T read(Addr address, ByteOrder guest_byte_order) const; 206 207 /** 208 * Write object T to address. Writes sizeof(T) bytes. 209 * Performs endianness conversion from host to the selected guest order. 210 */ 211 template <typename T> 212 void write(Addr address, T data, ByteOrder guest_byte_order) const; |
213 214 /** 215 * Write the string str into guest memory at address addr. 216 * Returns true on success and false on failure. 217 */ 218 bool tryWriteString(Addr addr, const char *str) const; 219 220 /** 221 * Same as tryWriteString, but insists on success. 222 */ 223 void 224 writeString(Addr addr, const char *str) const 225 { 226 if (!tryWriteString(addr, str)) 227 fatal("writeString(%#x, ...) failed", addr); 228 } 229 230 /** 231 * Reads the string at guest address addr into the std::string str. 232 * Returns true on success and false on failure. 233 */ 234 bool tryReadString(std::string &str, Addr addr) const; 235 236 /** 237 * Same as tryReadString, but insists on success. 238 */ 239 void 240 readString(std::string &str, Addr addr) const 241 { 242 if (!tryReadString(str, addr)) 243 fatal("readString(%#x, ...) failed", addr); 244 } |
|
165}; 166 167 168template <typename T> 169T 170PortProxy::read(Addr address) const 171{ 172 T data; --- 29 unchanged lines hidden --- | 245}; 246 247 248template <typename T> 249T 250PortProxy::read(Addr address) const 251{ 252 T data; --- 29 unchanged lines hidden --- |