diff options
Diffstat (limited to 'utils/hwstub/hwstub_protocol.h')
-rw-r--r-- | utils/hwstub/hwstub_protocol.h | 120 |
1 files changed, 48 insertions, 72 deletions
diff --git a/utils/hwstub/hwstub_protocol.h b/utils/hwstub/hwstub_protocol.h index dc4c52fb04..4feab87f00 100644 --- a/utils/hwstub/hwstub_protocol.h +++ b/utils/hwstub/hwstub_protocol.h | |||
@@ -21,13 +21,13 @@ | |||
21 | #ifndef __HWSTUB_PROTOCOL__ | 21 | #ifndef __HWSTUB_PROTOCOL__ |
22 | #define __HWSTUB_PROTOCOL__ | 22 | #define __HWSTUB_PROTOCOL__ |
23 | 23 | ||
24 | #define HWSTUB_CLASS 0xfe | 24 | #define HWSTUB_CLASS 0xff |
25 | #define HWSTUB_SUBCLASS 0xac | 25 | #define HWSTUB_SUBCLASS 0xac |
26 | #define HWSTUB_PROTOCOL 0x1d | 26 | #define HWSTUB_PROTOCOL 0x1d |
27 | 27 | ||
28 | #define HWSTUB_VERSION_MAJOR 2 | 28 | #define HWSTUB_VERSION_MAJOR 3 |
29 | #define HWSTUB_VERSION_MINOR 11 | 29 | #define HWSTUB_VERSION_MINOR 0 |
30 | #define HWSTUB_VERSION_REV 2 | 30 | #define HWSTUB_VERSION_REV 0 |
31 | 31 | ||
32 | #define HWSTUB_USB_VID 0xfee1 | 32 | #define HWSTUB_USB_VID 0xfee1 |
33 | #define HWSTUB_USB_PID 0xdead | 33 | #define HWSTUB_USB_PID 0xdead |
@@ -41,81 +41,77 @@ | |||
41 | */ | 41 | */ |
42 | 42 | ||
43 | /* list of commands */ | 43 | /* list of commands */ |
44 | #define HWSTUB_GET_INFO 0 /* mandatory */ | 44 | #define HWSTUB_GET_LOG 0 /* optional */ |
45 | #define HWSTUB_GET_LOG 1 /* optional */ | 45 | #define HWSTUB_RW_MEM 1 /* optional */ |
46 | #define HWSTUB_RW_MEM 2 /* optional */ | 46 | #define HWSTUB_CALL 2 /* optional */ |
47 | #define HWSTUB_CALL 3 /* optional */ | 47 | #define HWSTUB_JUMP 3 /* optional */ |
48 | #define HWSTUB_JUMP 4 /* optional */ | ||
49 | #define HWSTUB_EXIT 5 /* optional */ | ||
50 | #define HWSTUB_ATEXIT 6 /* optional */ | ||
51 | 48 | ||
52 | /** | 49 | /** |
53 | * HWSTUB_GET_INFO: get some information about an aspect of the device. | 50 | * Descriptors can be retrieve using configuration descriptor or individually |
54 | * The wIndex field of the SETUP specifies which information to get. */ | 51 | * using the standard GetDescriptor request on the interface. |
52 | */ | ||
55 | 53 | ||
56 | /* list of possible information */ | 54 | /* list of possible information */ |
57 | #define HWSTUB_INFO_VERSION 0 /* mandatory */ | 55 | #define HWSTUB_DT_VERSION 0x41 /* mandatory */ |
58 | #define HWSTUB_INFO_LAYOUT 1 /* mandatory */ | 56 | #define HWSTUB_DT_LAYOUT 0x42 /* mandatory */ |
59 | #define HWSTUB_INFO_STMP 2 /* optional */ | 57 | #define HWSTUB_DT_TARGET 0x43 /* mandatory */ |
60 | #define HWSTUB_INFO_FEATURES 3 /* mandatory */ | 58 | #define HWSTUB_DT_STMP 0x44 /* optional */ |
61 | #define HWSTUB_INFO_TARGET 4 /* mandatory */ | ||
62 | 59 | ||
63 | struct usb_resp_info_version_t | 60 | struct hwstub_version_desc_t |
64 | { | 61 | { |
65 | uint8_t major; | 62 | uint8_t bLength; |
66 | uint8_t minor; | 63 | uint8_t bDescriptorType; |
67 | uint8_t revision; | 64 | /* full version information */ |
65 | uint8_t bMajor; | ||
66 | uint8_t bMinor; | ||
67 | uint8_t bRevision; | ||
68 | } __attribute__((packed)); | 68 | } __attribute__((packed)); |
69 | 69 | ||
70 | struct usb_resp_info_layout_t | 70 | struct hwstub_layout_desc_t |
71 | { | 71 | { |
72 | uint8_t bLength; | ||
73 | uint8_t bDescriptorType; | ||
72 | /* describe the range of memory used by the running code */ | 74 | /* describe the range of memory used by the running code */ |
73 | uint32_t oc_code_start; | 75 | uint32_t dCodeStart; |
74 | uint32_t oc_code_size; | 76 | uint32_t dCodeSize; |
75 | /* describe the range of memory used by the stack */ | 77 | /* describe the range of memory used by the stack */ |
76 | uint32_t oc_stack_start; | 78 | uint32_t dStackStart; |
77 | uint32_t oc_stack_size; | 79 | uint32_t dStackSize; |
78 | /* describe the range of memory available as a buffer */ | 80 | /* describe the range of memory available as a buffer */ |
79 | uint32_t oc_buffer_start; | 81 | uint32_t dBufferStart; |
80 | uint32_t oc_buffer_size; | 82 | uint32_t dBufferSize; |
81 | } __attribute__((packed)); | 83 | } __attribute__((packed)); |
82 | 84 | ||
83 | struct usb_resp_info_stmp_t | 85 | struct hwstub_stmp_desc_t |
84 | { | 86 | { |
85 | uint16_t chipid; /* 0x3780 for STMP3780 for example */ | 87 | uint8_t bLength; |
86 | uint8_t rev; /* 0=TA1 on STMP3780 for example */ | 88 | uint8_t bDescriptorType; |
87 | uint8_t is_supported; /* 1 if the chip is supported */ | 89 | /* Chip ID and revision */ |
90 | uint16_t wChipID; /* 0x3780 for STMP3780 for example */ | ||
91 | uint8_t bRevision; /* 0=TA1 on STMP3780 for example */ | ||
92 | uint8_t bPackage; /* 0=169BGA for example */ | ||
88 | } __attribute__((packed)); | 93 | } __attribute__((packed)); |
89 | 94 | ||
90 | /* list of possible features */ | ||
91 | #define HWSTUB_FEATURE_LOG (1 << 0) | ||
92 | #define HWSTUB_FEATURE_MEM (1 << 1) | ||
93 | #define HWSTUB_FEATURE_CALL (1 << 2) | ||
94 | #define HWSTUB_FEATURE_JUMP (1 << 3) | ||
95 | #define HWSTUB_FEATURE_EXIT (1 << 4) | ||
96 | |||
97 | struct usb_resp_info_features_t | ||
98 | { | ||
99 | uint32_t feature_mask; | ||
100 | }; | ||
101 | |||
102 | #define HWSTUB_TARGET_UNK ('U' | 'N' << 8 | 'K' << 16 | ' ' << 24) | 95 | #define HWSTUB_TARGET_UNK ('U' | 'N' << 8 | 'K' << 16 | ' ' << 24) |
103 | #define HWSTUB_TARGET_STMP ('S' | 'T' << 8 | 'M' << 16 | 'P' << 24) | 96 | #define HWSTUB_TARGET_STMP ('S' | 'T' << 8 | 'M' << 16 | 'P' << 24) |
104 | #define HWSTUB_TARGET_RK27 ('R' | 'K' << 8 | '2' << 16 | '7' << 24) | 97 | #define HWSTUB_TARGET_RK27 ('R' | 'K' << 8 | '2' << 16 | '7' << 24) |
105 | 98 | ||
106 | struct usb_resp_info_target_t | 99 | struct hwstub_target_desc_t |
107 | { | 100 | { |
108 | uint32_t id; | 101 | uint8_t bLength; |
109 | char name[60]; | 102 | uint8_t bDescriptorType; |
110 | }; | 103 | /* Target ID and name */ |
104 | uint32_t dID; | ||
105 | char bName[58]; | ||
106 | } __attribute__((packed)); | ||
111 | 107 | ||
112 | /** | 108 | /** |
113 | * HWSTUB_GET_LOG: only if has HWSTUB_FEATURE_LOG. | 109 | * HWSTUB_GET_LOG: |
114 | * The log is returned as part of the control transfer. | 110 | * The log is returned as part of the control transfer. |
115 | */ | 111 | */ |
116 | 112 | ||
117 | /** | 113 | /** |
118 | * HWSTUB_RW_MEM: only if has HWSTUB_FEATURE_MEM. | 114 | * HWSTUB_RW_MEM: |
119 | * The 32-bit address is split into two parts. | 115 | * The 32-bit address is split into two parts. |
120 | * The low 16-bit are stored in wValue and the upper | 116 | * The low 16-bit are stored in wValue and the upper |
121 | * 16-bit are stored in wIndex. Depending on the transfer direction, | 117 | * 16-bit are stored in wIndex. Depending on the transfer direction, |
@@ -124,30 +120,10 @@ struct usb_resp_info_target_t | |||
124 | * possible, making it suitable to read/write registers. */ | 120 | * possible, making it suitable to read/write registers. */ |
125 | 121 | ||
126 | /** | 122 | /** |
127 | * HWSTUB_x: only if has HWSTUB_FEATURE_x where x=CALL or JUMP. | 123 | * HWSTUB_{CALL,JUMP}: |
128 | * The 32-bit address is split into two parts. | 124 | * The 32-bit address is split into two parts. |
129 | * The low 16-bit are stored in wValue and the upper | 125 | * The low 16-bit are stored in wValue and the upper |
130 | * 16-bit are stored in wIndex. Depending on the transfer direction, | 126 | * 16-bit are stored in wIndex. Depending on the transfer direction, |
131 | * the transfer is either a read or a write. */ | 127 | * the transfer is either a read or a write. */ |
132 | 128 | ||
133 | /** | ||
134 | * HWSTUB_EXIT: only if has HWSTUB_FEATURE_EXIT. | ||
135 | * Stop hwstub now, performing the atexit action. Default exit action | ||
136 | * is target dependent. */ | ||
137 | |||
138 | /** | ||
139 | * HWSTUB_ATEXIT: only if has HWSTUB_FEATURE_EXIT. | ||
140 | * Sets the action to perform at exit. Exit happens by sending HWSTUB_EXIT | ||
141 | * or on USB disconnection. The following actions are available: | ||
142 | * - nop: don't do anything, wait for next connection | ||
143 | * - reboot: reboot the device | ||
144 | * - off: power off | ||
145 | * NOTE the power off action might have to wait for USB disconnection as some | ||
146 | * targets cannot power off while plugged. | ||
147 | * NOTE appart from nop which is mandatory, all other methods can be | ||
148 | * unavailable and thus the atexit command can fail. */ | ||
149 | #define HWSTUB_ATEXIT_REBOOT 0 | ||
150 | #define HWSTUB_ATEXIT_OFF 1 | ||
151 | #define HWSTUB_ATEXIT_NOP 2 | ||
152 | |||
153 | #endif /* __HWSTUB_PROTOCOL__ */ | 129 | #endif /* __HWSTUB_PROTOCOL__ */ |