diff options
Diffstat (limited to 'utils/hwstub/hwstub_protocol.h')
-rw-r--r-- | utils/hwstub/hwstub_protocol.h | 113 |
1 files changed, 79 insertions, 34 deletions
diff --git a/utils/hwstub/hwstub_protocol.h b/utils/hwstub/hwstub_protocol.h index 2c11025b1e..02c065cbe0 100644 --- a/utils/hwstub/hwstub_protocol.h +++ b/utils/hwstub/hwstub_protocol.h | |||
@@ -21,46 +21,46 @@ | |||
21 | #ifndef __HWSTUB_PROTOCOL__ | 21 | #ifndef __HWSTUB_PROTOCOL__ |
22 | #define __HWSTUB_PROTOCOL__ | 22 | #define __HWSTUB_PROTOCOL__ |
23 | 23 | ||
24 | #define HWSTUB_CLASS 0xff | 24 | /** |
25 | #define HWSTUB_SUBCLASS 0xac | 25 | * HWStub protocol version |
26 | #define HWSTUB_PROTOCOL 0x1d | 26 | */ |
27 | 27 | ||
28 | #define HWSTUB_VERSION_MAJOR 3 | 28 | #define HWSTUB_VERSION_MAJOR 4 |
29 | #define HWSTUB_VERSION_MINOR 0 | 29 | #define HWSTUB_VERSION_MINOR 0 |
30 | #define HWSTUB_VERSION_REV 1 | 30 | #define HWSTUB_VERSION_REV 0 |
31 | 31 | ||
32 | #define HWSTUB_VERSION__(maj,min,rev) #maj"."#min"."#rev | 32 | #define HWSTUB_VERSION__(maj,min,rev) #maj"."#min"."#rev |
33 | #define HWSTUB_VERSION_(maj,min,rev) HWSTUB_VERSION__(maj,min,rev) | 33 | #define HWSTUB_VERSION_(maj,min,rev) HWSTUB_VERSION__(maj,min,rev) |
34 | #define HWSTUB_VERSION HWSTUB_VERSION_(HWSTUB_VERSION_MAJOR,HWSTUB_VERSION_MINOR,HWSTUB_VERSION_REV) | 34 | #define HWSTUB_VERSION HWSTUB_VERSION_(HWSTUB_VERSION_MAJOR,HWSTUB_VERSION_MINOR,HWSTUB_VERSION_REV) |
35 | 35 | ||
36 | /** | ||
37 | * A device can use any VID:PID but in case hwstub is in full control of the | ||
38 | * device, the preferred VID:PID is the following. | ||
39 | */ | ||
40 | |||
36 | #define HWSTUB_USB_VID 0xfee1 | 41 | #define HWSTUB_USB_VID 0xfee1 |
37 | #define HWSTUB_USB_PID 0xdead | 42 | #define HWSTUB_USB_PID 0xdead |
38 | 43 | ||
39 | /** | 44 | /** |
40 | * Control commands | 45 | * The device class should be per interface and the hwstub interface must use |
41 | * | 46 | * the following class, subclass and protocol. |
42 | * These commands are sent to the device, using the standard bRequest field | ||
43 | * of the SETUP packet. This is to take advantage of both wIndex and wValue | ||
44 | * although it would have been more correct to send them to the interface. | ||
45 | */ | 47 | */ |
46 | 48 | ||
47 | /* list of commands */ | 49 | #define HWSTUB_CLASS 0xff |
48 | #define HWSTUB_GET_LOG 0 /* optional */ | 50 | #define HWSTUB_SUBCLASS 0x57 |
49 | #define HWSTUB_RW_MEM 1 /* optional */ | 51 | #define HWSTUB_PROTOCOL 0x0b |
50 | #define HWSTUB_CALL 2 /* optional */ | ||
51 | #define HWSTUB_JUMP 3 /* optional */ | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Descriptors can be retrieve using configuration descriptor or individually | 54 | * Descriptors can be retrieved using configuration descriptor or individually |
55 | * using the standard GetDescriptor request on the interface. | 55 | * using the standard GetDescriptor request on the interface. |
56 | */ | 56 | */ |
57 | 57 | ||
58 | /* list of possible information */ | 58 | #define HWSTUB_DT_VERSION 0x41 /* mandatory */ |
59 | #define HWSTUB_DT_VERSION 0x41 /* mandatory */ | 59 | #define HWSTUB_DT_LAYOUT 0x42 /* mandatory */ |
60 | #define HWSTUB_DT_LAYOUT 0x42 /* mandatory */ | 60 | #define HWSTUB_DT_TARGET 0x43 /* mandatory */ |
61 | #define HWSTUB_DT_TARGET 0x43 /* mandatory */ | 61 | #define HWSTUB_DT_STMP 0x44 /* optional */ |
62 | #define HWSTUB_DT_STMP 0x44 /* optional */ | 62 | #define HWSTUB_DT_PP 0x45 /* optional */ |
63 | #define HWSTUB_DT_PP 0x45 /* optional */ | 63 | #define HWSTUB_DT_DEVICE 0x46 /* optional */ |
64 | 64 | ||
65 | struct hwstub_version_desc_t | 65 | struct hwstub_version_desc_t |
66 | { | 66 | { |
@@ -120,25 +120,70 @@ struct hwstub_target_desc_t | |||
120 | char bName[58]; | 120 | char bName[58]; |
121 | } __attribute__((packed)); | 121 | } __attribute__((packed)); |
122 | 122 | ||
123 | struct hwstub_device_desc_t | ||
124 | { | ||
125 | uint8_t bLength; | ||
126 | uint8_t bDescriptorType; | ||
127 | /* Give the bRequest value for */ | ||
128 | } __attribute__((packed)); | ||
129 | |||
130 | /** | ||
131 | * Control commands | ||
132 | * | ||
133 | * These commands are sent to the interface, using the standard bRequest field | ||
134 | * of the SETUP packet. The wIndex contains the interface number. The wValue | ||
135 | * contains an ID which is used for requests requiring several transfers. | ||
136 | */ | ||
137 | |||
138 | #define HWSTUB_GET_LOG 0x40 | ||
139 | #define HWSTUB_READ 0x41 | ||
140 | #define HWSTUB_READ2 0x42 | ||
141 | #define HWSTUB_WRITE 0x43 | ||
142 | #define HWSTUB_EXEC 0x44 | ||
143 | |||
123 | /** | 144 | /** |
124 | * HWSTUB_GET_LOG: | 145 | * HWSTUB_GET_LOG: |
125 | * The log is returned as part of the control transfer. | 146 | * The log is returned as part of the control transfer. |
126 | */ | 147 | */ |
127 | 148 | ||
128 | /** | 149 | /** |
129 | * HWSTUB_RW_MEM: | 150 | * HWSTUB_READ and HWSTUB_READ2: |
130 | * The 32-bit address is split into two parts. | 151 | * Read a range of memory. The request works in two steps: first the host |
131 | * The low 16-bit are stored in wValue and the upper | 152 | * sends HWSTUB_READ with the parameters (address, length) and then |
132 | * 16-bit are stored in wIndex. Depending on the transfer direction, | 153 | * a HWSTUB_READ2 to retrieve the buffer. Both requests must use the same |
133 | * the transfer is either a read or a write. | 154 | * ID in wValue, otherwise the second request will be STALLed. |
134 | * The read/write on the device are guaranteed to be 16-bit/32-bit when | 155 | */ |
135 | * possible, making it suitable to read/write registers. */ | 156 | |
157 | struct hwstub_read_req_t | ||
158 | { | ||
159 | uint32_t dAddress; | ||
160 | } __attribute__((packed)); | ||
161 | |||
162 | /** | ||
163 | * HWSTUB_WRITE | ||
164 | * Write a range of memory. The payload starts with the following header, everything | ||
165 | * which follows is data. | ||
166 | */ | ||
167 | struct hwstub_write_req_t | ||
168 | { | ||
169 | uint32_t dAddress; | ||
170 | } __attribute__((packed)); | ||
136 | 171 | ||
137 | /** | 172 | /** |
138 | * HWSTUB_{CALL,JUMP}: | 173 | * HWSTUB_EXEC: |
139 | * The 32-bit address is split into two parts. | 174 | * Execute code at an address. Several options are available regarding ARM vs Thumb, |
140 | * The low 16-bit are stored in wValue and the upper | 175 | * jump vs call. |
141 | * 16-bit are stored in wIndex. Depending on the transfer direction, | 176 | */ |
142 | * the transfer is either a read or a write. */ | 177 | |
178 | #define HWSTUB_EXEC_ARM (0 << 0) /* target code is ARM */ | ||
179 | #define HWSTUB_EXEC_THUMB (1 << 0) /* target code is Thumb */ | ||
180 | #define HWSTUB_EXEC_JUMP (0 << 1) /* branch, code will never turn */ | ||
181 | #define HWSTUB_EXEC_CALL (1 << 1) /* call and expect return */ | ||
182 | |||
183 | struct hwstub_exec_req_t | ||
184 | { | ||
185 | uint32_t dAddress; | ||
186 | uint16_t bmFlags; | ||
187 | }; | ||
143 | 188 | ||
144 | #endif /* __HWSTUB_PROTOCOL__ */ | 189 | #endif /* __HWSTUB_PROTOCOL__ */ |