diff options
Diffstat (limited to 'utils/hwstub/include')
-rw-r--r-- | utils/hwstub/include/hwstub.hpp | 18 | ||||
-rw-r--r-- | utils/hwstub/include/hwstub_net.hpp | 2 | ||||
-rw-r--r-- | utils/hwstub/include/hwstub_protocol.h | 32 | ||||
-rw-r--r-- | utils/hwstub/include/hwstub_usb.hpp | 4 | ||||
-rw-r--r-- | utils/hwstub/include/hwstub_virtual.hpp | 2 |
5 files changed, 57 insertions, 1 deletions
diff --git a/utils/hwstub/include/hwstub.hpp b/utils/hwstub/include/hwstub.hpp index deac976240..e403857200 100644 --- a/utils/hwstub/include/hwstub.hpp +++ b/utils/hwstub/include/hwstub.hpp | |||
@@ -62,6 +62,8 @@ enum class error | |||
62 | NET_ERROR, /** Network error */ | 62 | NET_ERROR, /** Network error */ |
63 | TIMEOUT, /** Operation timed out */ | 63 | TIMEOUT, /** Operation timed out */ |
64 | OVERFLW, /** Operation stopped to prevent buffer overflow */ | 64 | OVERFLW, /** Operation stopped to prevent buffer overflow */ |
65 | UNIMPLEMENTED, /** Operation has not been implemented */ | ||
66 | UNSUPPORTED, /** Operation is not supported by device/protocol */ | ||
65 | }; | 67 | }; |
66 | 68 | ||
67 | /** Return a string explaining the error */ | 69 | /** Return a string explaining the error */ |
@@ -266,6 +268,15 @@ public: | |||
266 | * according to the buffer size and call read_dev() and write_dev() */ | 268 | * according to the buffer size and call read_dev() and write_dev() */ |
267 | error read(uint32_t addr, void *buf, size_t& sz, bool atomic); | 269 | error read(uint32_t addr, void *buf, size_t& sz, bool atomic); |
268 | error write(uint32_t addr, const void *buf, size_t& sz, bool atomic); | 270 | error write(uint32_t addr, const void *buf, size_t& sz, bool atomic); |
271 | /** Execute a general cop operation: if out_data is not null, data is appended to header, | ||
272 | * if in_data is not null, a read operation follows to retrieve some data. | ||
273 | * The in_data parameters is updated to reflect the number of transfered bytes */ | ||
274 | error cop_op(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
275 | size_t out_size, void *in_data, size_t *in_size); | ||
276 | /** Execute a coprocessor read operation */ | ||
277 | error read32_cop(uint8_t args[HWSTUB_COP_ARGS], uint32_t& value); | ||
278 | /** Execute a coprocessor write operation */ | ||
279 | error write32_cop(uint8_t args[HWSTUB_COP_ARGS], uint32_t value); | ||
269 | /** Get device buffer size: any read() or write() greater than this size | 280 | /** Get device buffer size: any read() or write() greater than this size |
270 | * will be split into several transaction to avoid overflowing device | 281 | * will be split into several transaction to avoid overflowing device |
271 | * buffer. */ | 282 | * buffer. */ |
@@ -303,6 +314,11 @@ protected: | |||
303 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz) = 0; | 314 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz) = 0; |
304 | virtual error get_dev_log(void *buf, size_t& buf_sz) = 0; | 315 | virtual error get_dev_log(void *buf, size_t& buf_sz) = 0; |
305 | virtual error exec_dev(uint32_t addr, uint16_t flags) = 0; | 316 | virtual error exec_dev(uint32_t addr, uint16_t flags) = 0; |
317 | /* cop operation: if out_data is not null, data is appended to header, if | ||
318 | * in_data is not null, a READ2 operation follows to retrieve some data | ||
319 | * The in_data parameters is updated to reflect the number of transfered bytes*/ | ||
320 | virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
321 | size_t out_size, void *in_data, size_t *in_size) = 0; | ||
306 | 322 | ||
307 | std::shared_ptr<device> m_dev; /* pointer to device */ | 323 | std::shared_ptr<device> m_dev; /* pointer to device */ |
308 | std::atomic<int> m_refcnt; /* reference count */ | 324 | std::atomic<int> m_refcnt; /* reference count */ |
@@ -338,6 +354,8 @@ protected: | |||
338 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); | 354 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); |
339 | virtual error get_dev_log(void *buf, size_t& buf_sz); | 355 | virtual error get_dev_log(void *buf, size_t& buf_sz); |
340 | virtual error exec_dev(uint32_t addr, uint16_t flags); | 356 | virtual error exec_dev(uint32_t addr, uint16_t flags); |
357 | virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
358 | size_t out_size, void *in_data, size_t *in_size); | ||
341 | virtual error status() const; | 359 | virtual error status() const; |
342 | virtual size_t get_buffer_size(); | 360 | virtual size_t get_buffer_size(); |
343 | 361 | ||
diff --git a/utils/hwstub/include/hwstub_net.hpp b/utils/hwstub/include/hwstub_net.hpp index 2cf6e07ccb..ae0e09e920 100644 --- a/utils/hwstub/include/hwstub_net.hpp +++ b/utils/hwstub/include/hwstub_net.hpp | |||
@@ -184,6 +184,8 @@ protected: | |||
184 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); | 184 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); |
185 | virtual error get_dev_log(void *buf, size_t& buf_sz); | 185 | virtual error get_dev_log(void *buf, size_t& buf_sz); |
186 | virtual error exec_dev(uint32_t addr, uint16_t flags); | 186 | virtual error exec_dev(uint32_t addr, uint16_t flags); |
187 | virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
188 | size_t out_size, void *in_data, size_t *in_size); | ||
187 | virtual error status() const; | 189 | virtual error status() const; |
188 | virtual size_t get_buffer_size(); | 190 | virtual size_t get_buffer_size(); |
189 | 191 | ||
diff --git a/utils/hwstub/include/hwstub_protocol.h b/utils/hwstub/include/hwstub_protocol.h index f767e50571..ed26ee78e4 100644 --- a/utils/hwstub/include/hwstub_protocol.h +++ b/utils/hwstub/include/hwstub_protocol.h | |||
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #define HWSTUB_VERSION_MAJOR 4 | 35 | #define HWSTUB_VERSION_MAJOR 4 |
36 | #define HWSTUB_VERSION_MINOR 2 | 36 | #define HWSTUB_VERSION_MINOR 3 |
37 | 37 | ||
38 | #define HWSTUB_VERSION__(maj, min) #maj"."#min | 38 | #define HWSTUB_VERSION__(maj, min) #maj"."#min |
39 | #define HWSTUB_VERSION_(maj, min) HWSTUB_VERSION__(maj, min) | 39 | #define HWSTUB_VERSION_(maj, min) HWSTUB_VERSION__(maj, min) |
@@ -169,6 +169,7 @@ struct hwstub_net_hdr_t | |||
169 | #define HWSTUB_EXEC 0x44 | 169 | #define HWSTUB_EXEC 0x44 |
170 | #define HWSTUB_READ2_ATOMIC 0x45 | 170 | #define HWSTUB_READ2_ATOMIC 0x45 |
171 | #define HWSTUB_WRITE_ATOMIC 0x46 | 171 | #define HWSTUB_WRITE_ATOMIC 0x46 |
172 | #define HWSTUB_COPROCESSOR_OP 0x47 | ||
172 | 173 | ||
173 | /* the following commands and the ACK/NACK mechanism are net only */ | 174 | /* the following commands and the ACK/NACK mechanism are net only */ |
174 | #define HWSERVER_ACK(n) (0x100|(n)) | 175 | #define HWSERVER_ACK(n) (0x100|(n)) |
@@ -252,6 +253,35 @@ struct hwstub_exec_req_t | |||
252 | } __attribute__((packed)); | 253 | } __attribute__((packed)); |
253 | 254 | ||
254 | /** | 255 | /** |
256 | * HWSTUB_COPROCESSOR_OP | ||
257 | * Execute a coprocessor operation. The operation is describe in the header of | ||
258 | * the structure. There are currently two supported operations: | ||
259 | * - read: following the HWSTUB_COPROCESSOR_OP, the host can retrieve the data | ||
260 | * by sending a HWSTUB_READ2 request (just like a regular read) of | ||
261 | * the appropriate size | ||
262 | * - write: the header is followed by the data to write. | ||
263 | * If the request has two parts (second being READ2) then both requests must use | ||
264 | * the same ID in wValue, otherwise the second request will be STALLed. | ||
265 | * If a particular operation is not supported, it must be STALLed by the device. | ||
266 | */ | ||
267 | |||
268 | #define HWSTUB_COP_READ 0 /* read operation */ | ||
269 | #define HWSTUB_COP_WRITE 1 /* write operation */ | ||
270 | /* for MIPS */ | ||
271 | #define HWSTUB_COP_MIPS_COP 0 /* coprocessor number */ | ||
272 | #define HWSTUB_COP_MIPS_REG 1 /* coprocessor register */ | ||
273 | #define HWSTUB_COP_MIPS_SEL 2 /* coprocessor select */ | ||
274 | |||
275 | #define HWSTUB_COP_ARGS 7 /* maximum number of arguments */ | ||
276 | |||
277 | struct hwstub_cop_req_t | ||
278 | { | ||
279 | uint8_t bOp; /* operation to execute */ | ||
280 | uint8_t bArgs[HWSTUB_COP_ARGS]; /* arguments to the operation */ | ||
281 | /* followed by data for WRITE operation */ | ||
282 | }; | ||
283 | |||
284 | /** | ||
255 | * HWSERVER_HELLO: | 285 | * HWSERVER_HELLO: |
256 | * Say hello to the server, give protocol version and get server version. | 286 | * Say hello to the server, give protocol version and get server version. |
257 | * Send: args[0] = major << 8 | minor, no data | 287 | * Send: args[0] = major << 8 | minor, no data |
diff --git a/utils/hwstub/include/hwstub_usb.hpp b/utils/hwstub/include/hwstub_usb.hpp index 6a9d4d8798..15a0fcaaec 100644 --- a/utils/hwstub/include/hwstub_usb.hpp +++ b/utils/hwstub/include/hwstub_usb.hpp | |||
@@ -132,6 +132,8 @@ protected: | |||
132 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); | 132 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); |
133 | virtual error get_dev_log(void *buf, size_t& buf_sz); | 133 | virtual error get_dev_log(void *buf, size_t& buf_sz); |
134 | virtual error exec_dev(uint32_t addr, uint16_t flags); | 134 | virtual error exec_dev(uint32_t addr, uint16_t flags); |
135 | virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
136 | size_t out_size, void *in_data, size_t *in_size); | ||
135 | virtual error status() const; | 137 | virtual error status() const; |
136 | virtual size_t get_buffer_size(); | 138 | virtual size_t get_buffer_size(); |
137 | /* Probe a device to check if it is an hwstub device and return the interface | 139 | /* Probe a device to check if it is an hwstub device and return the interface |
@@ -162,6 +164,8 @@ protected: | |||
162 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); | 164 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); |
163 | virtual error get_dev_log(void *buf, size_t& buf_sz); | 165 | virtual error get_dev_log(void *buf, size_t& buf_sz); |
164 | virtual error exec_dev(uint32_t addr, uint16_t flags); | 166 | virtual error exec_dev(uint32_t addr, uint16_t flags); |
167 | virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
168 | size_t out_size, void *in_data, size_t *in_size); | ||
165 | virtual error status() const; | 169 | virtual error status() const; |
166 | virtual size_t get_buffer_size(); | 170 | virtual size_t get_buffer_size(); |
167 | error probe(); | 171 | error probe(); |
diff --git a/utils/hwstub/include/hwstub_virtual.hpp b/utils/hwstub/include/hwstub_virtual.hpp index d35f98e0ec..1e35378840 100644 --- a/utils/hwstub/include/hwstub_virtual.hpp +++ b/utils/hwstub/include/hwstub_virtual.hpp | |||
@@ -147,6 +147,8 @@ protected: | |||
147 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); | 147 | virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz); |
148 | virtual error get_dev_log(void *buf, size_t& buf_sz); | 148 | virtual error get_dev_log(void *buf, size_t& buf_sz); |
149 | virtual error exec_dev(uint32_t addr, uint16_t flags); | 149 | virtual error exec_dev(uint32_t addr, uint16_t flags); |
150 | virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data, | ||
151 | size_t out_size, void *in_data, size_t *in_size); | ||
150 | virtual error status() const; | 152 | virtual error status() const; |
151 | virtual size_t get_buffer_size(); | 153 | virtual size_t get_buffer_size(); |
152 | 154 | ||