port_proxy.hh (8853:0216ed80991b) | port_proxy.hh (8861:56d011130987) |
---|---|
1/* 2 * Copyright (c) 2011-2012 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 --- 74 unchanged lines hidden (view full) --- 83 */ 84class PortProxy 85{ 86 private: 87 88 /** The actual physical port used by this proxy. */ 89 Port &_port; 90 | 1/* 2 * Copyright (c) 2011-2012 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 --- 74 unchanged lines hidden (view full) --- 83 */ 84class PortProxy 85{ 86 private: 87 88 /** The actual physical port used by this proxy. */ 89 Port &_port; 90 |
91 void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd); | 91 void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd) const; |
92 93 public: 94 PortProxy(Port &port) : _port(port) { } 95 virtual ~PortProxy() { } 96 97 /** 98 * Read size bytes memory at address and store in p. 99 */ | 92 93 public: 94 PortProxy(Port &port) : _port(port) { } 95 virtual ~PortProxy() { } 96 97 /** 98 * Read size bytes memory at address and store in p. 99 */ |
100 virtual void readBlob(Addr addr, uint8_t* p, int size) | 100 virtual void readBlob(Addr addr, uint8_t* p, int size) const |
101 { blobHelper(addr, p, size, MemCmd::ReadReq); } 102 103 /** 104 * Write size bytes from p to address. 105 */ | 101 { blobHelper(addr, p, size, MemCmd::ReadReq); } 102 103 /** 104 * Write size bytes from p to address. 105 */ |
106 virtual void writeBlob(Addr addr, uint8_t* p, int size) | 106 virtual void writeBlob(Addr addr, uint8_t* p, int size) const |
107 { blobHelper(addr, p, size, MemCmd::WriteReq); } 108 109 /** 110 * Fill size bytes starting at addr with byte value val. 111 */ | 107 { blobHelper(addr, p, size, MemCmd::WriteReq); } 108 109 /** 110 * Fill size bytes starting at addr with byte value val. 111 */ |
112 virtual void memsetBlob(Addr addr, uint8_t v, int size); | 112 virtual void memsetBlob(Addr addr, uint8_t v, int size) const; |
113 114 /** 115 * Read sizeof(T) bytes from address and return as object T. 116 */ 117 template <typename T> | 113 114 /** 115 * Read sizeof(T) bytes from address and return as object T. 116 */ 117 template <typename T> |
118 T read(Addr address); | 118 T read(Addr address) const; |
119 120 /** 121 * Write object T to address. Writes sizeof(T) bytes. 122 */ 123 template <typename T> | 119 120 /** 121 * Write object T to address. Writes sizeof(T) bytes. 122 */ 123 template <typename T> |
124 void write(Addr address, T data); | 124 void write(Addr address, T data) const; |
125 126#if THE_ISA != NO_ISA 127 /** 128 * Read sizeof(T) bytes from address and return as object T. 129 * Performs Guest to Host endianness transform. 130 */ 131 template <typename T> | 125 126#if THE_ISA != NO_ISA 127 /** 128 * Read sizeof(T) bytes from address and return as object T. 129 * Performs Guest to Host endianness transform. 130 */ 131 template <typename T> |
132 T readGtoH(Addr address); | 132 T readGtoH(Addr address) const; |
133 134 /** 135 * Write object T to address. Writes sizeof(T) bytes. 136 * Performs Host to Guest endianness transform. 137 */ 138 template <typename T> | 133 134 /** 135 * Write object T to address. Writes sizeof(T) bytes. 136 * Performs Host to Guest endianness transform. 137 */ 138 template <typename T> |
139 void writeHtoG(Addr address, T data); | 139 void writeHtoG(Addr address, T data) const; |
140#endif 141}; 142 143 144template <typename T> 145T | 140#endif 141}; 142 143 144template <typename T> 145T |
146PortProxy::read(Addr address) | 146PortProxy::read(Addr address) const |
147{ 148 T data; 149 readBlob(address, (uint8_t*)&data, sizeof(T)); 150 return data; 151} 152 153template <typename T> 154void | 147{ 148 T data; 149 readBlob(address, (uint8_t*)&data, sizeof(T)); 150 return data; 151} 152 153template <typename T> 154void |
155PortProxy::write(Addr address, T data) | 155PortProxy::write(Addr address, T data) const |
156{ 157 writeBlob(address, (uint8_t*)&data, sizeof(T)); 158} 159 160#if THE_ISA != NO_ISA 161template <typename T> 162T | 156{ 157 writeBlob(address, (uint8_t*)&data, sizeof(T)); 158} 159 160#if THE_ISA != NO_ISA 161template <typename T> 162T |
163PortProxy::readGtoH(Addr address) | 163PortProxy::readGtoH(Addr address) const |
164{ 165 T data; 166 readBlob(address, (uint8_t*)&data, sizeof(T)); 167 return TheISA::gtoh(data); 168} 169 170template <typename T> 171void | 164{ 165 T data; 166 readBlob(address, (uint8_t*)&data, sizeof(T)); 167 return TheISA::gtoh(data); 168} 169 170template <typename T> 171void |
172PortProxy::writeHtoG(Addr address, T data) | 172PortProxy::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__ | 173{ 174 data = TheISA::htog(data); 175 writeBlob(address, (uint8_t*)&data, sizeof(T)); 176} 177#endif 178 179#endif // __MEM_PORT_PROXY_HH__ |