summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/include
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/include')
-rw-r--r--utils/hwstub/include/hwstub.hpp18
-rw-r--r--utils/hwstub/include/hwstub_net.hpp2
-rw-r--r--utils/hwstub/include/hwstub_protocol.h32
-rw-r--r--utils/hwstub/include/hwstub_usb.hpp4
-rw-r--r--utils/hwstub/include/hwstub_virtual.hpp2
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
NET_ERROR, /** Network error */
TIMEOUT, /** Operation timed out */
OVERFLW, /** Operation stopped to prevent buffer overflow */
+ UNIMPLEMENTED, /** Operation has not been implemented */
+ UNSUPPORTED, /** Operation is not supported by device/protocol */
};
/** Return a string explaining the error */
@@ -266,6 +268,15 @@ public:
* according to the buffer size and call read_dev() and write_dev() */
error read(uint32_t addr, void *buf, size_t& sz, bool atomic);
error write(uint32_t addr, const void *buf, size_t& sz, bool atomic);
+ /** Execute a general cop operation: if out_data is not null, data is appended to header,
+ * if in_data is not null, a read operation follows to retrieve some data.
+ * The in_data parameters is updated to reflect the number of transfered bytes */
+ error cop_op(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size);
+ /** Execute a coprocessor read operation */
+ error read32_cop(uint8_t args[HWSTUB_COP_ARGS], uint32_t& value);
+ /** Execute a coprocessor write operation */
+ error write32_cop(uint8_t args[HWSTUB_COP_ARGS], uint32_t value);
/** Get device buffer size: any read() or write() greater than this size
* will be split into several transaction to avoid overflowing device
* buffer. */
@@ -303,6 +314,11 @@ protected:
virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz) = 0;
virtual error get_dev_log(void *buf, size_t& buf_sz) = 0;
virtual error exec_dev(uint32_t addr, uint16_t flags) = 0;
+ /* cop operation: if out_data is not null, data is appended to header, if
+ * in_data is not null, a READ2 operation follows to retrieve some data
+ * The in_data parameters is updated to reflect the number of transfered bytes*/
+ virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size) = 0;
std::shared_ptr<device> m_dev; /* pointer to device */
std::atomic<int> m_refcnt; /* reference count */
@@ -338,6 +354,8 @@ protected:
virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz);
virtual error get_dev_log(void *buf, size_t& buf_sz);
virtual error exec_dev(uint32_t addr, uint16_t flags);
+ virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size);
virtual error status() const;
virtual size_t get_buffer_size();
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:
virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz);
virtual error get_dev_log(void *buf, size_t& buf_sz);
virtual error exec_dev(uint32_t addr, uint16_t flags);
+ virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size);
virtual error status() const;
virtual size_t get_buffer_size();
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 @@
*/
#define HWSTUB_VERSION_MAJOR 4
-#define HWSTUB_VERSION_MINOR 2
+#define HWSTUB_VERSION_MINOR 3
#define HWSTUB_VERSION__(maj, min) #maj"."#min
#define HWSTUB_VERSION_(maj, min) HWSTUB_VERSION__(maj, min)
@@ -169,6 +169,7 @@ struct hwstub_net_hdr_t
#define HWSTUB_EXEC 0x44
#define HWSTUB_READ2_ATOMIC 0x45
#define HWSTUB_WRITE_ATOMIC 0x46
+#define HWSTUB_COPROCESSOR_OP 0x47
/* the following commands and the ACK/NACK mechanism are net only */
#define HWSERVER_ACK(n) (0x100|(n))
@@ -252,6 +253,35 @@ struct hwstub_exec_req_t
} __attribute__((packed));
/**
+ * HWSTUB_COPROCESSOR_OP
+ * Execute a coprocessor operation. The operation is describe in the header of
+ * the structure. There are currently two supported operations:
+ * - read: following the HWSTUB_COPROCESSOR_OP, the host can retrieve the data
+ * by sending a HWSTUB_READ2 request (just like a regular read) of
+ * the appropriate size
+ * - write: the header is followed by the data to write.
+ * If the request has two parts (second being READ2) then both requests must use
+ * the same ID in wValue, otherwise the second request will be STALLed.
+ * If a particular operation is not supported, it must be STALLed by the device.
+ */
+
+#define HWSTUB_COP_READ 0 /* read operation */
+#define HWSTUB_COP_WRITE 1 /* write operation */
+/* for MIPS */
+#define HWSTUB_COP_MIPS_COP 0 /* coprocessor number */
+#define HWSTUB_COP_MIPS_REG 1 /* coprocessor register */
+#define HWSTUB_COP_MIPS_SEL 2 /* coprocessor select */
+
+#define HWSTUB_COP_ARGS 7 /* maximum number of arguments */
+
+struct hwstub_cop_req_t
+{
+ uint8_t bOp; /* operation to execute */
+ uint8_t bArgs[HWSTUB_COP_ARGS]; /* arguments to the operation */
+ /* followed by data for WRITE operation */
+};
+
+/**
* HWSERVER_HELLO:
* Say hello to the server, give protocol version and get server version.
* 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:
virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz);
virtual error get_dev_log(void *buf, size_t& buf_sz);
virtual error exec_dev(uint32_t addr, uint16_t flags);
+ virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size);
virtual error status() const;
virtual size_t get_buffer_size();
/* Probe a device to check if it is an hwstub device and return the interface
@@ -162,6 +164,8 @@ protected:
virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz);
virtual error get_dev_log(void *buf, size_t& buf_sz);
virtual error exec_dev(uint32_t addr, uint16_t flags);
+ virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size);
virtual error status() const;
virtual size_t get_buffer_size();
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:
virtual error get_dev_desc(uint16_t desc, void *buf, size_t& buf_sz);
virtual error get_dev_log(void *buf, size_t& buf_sz);
virtual error exec_dev(uint32_t addr, uint16_t flags);
+ virtual error cop_dev(uint8_t op, uint8_t args[HWSTUB_COP_ARGS], const void *out_data,
+ size_t out_size, void *in_data, size_t *in_size);
virtual error status() const;
virtual size_t get_buffer_size();