summaryrefslogtreecommitdiff
path: root/utils/hwstub/hwstub_protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/hwstub_protocol.h')
-rw-r--r--utils/hwstub/hwstub_protocol.h129
1 files changed, 129 insertions, 0 deletions
diff --git a/utils/hwstub/hwstub_protocol.h b/utils/hwstub/hwstub_protocol.h
new file mode 100644
index 0000000000..41be3957e8
--- /dev/null
+++ b/utils/hwstub/hwstub_protocol.h
@@ -0,0 +1,129 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __HWSTUB_PROTOCOL__
22#define __HWSTUB_PROTOCOL__
23
24#define HWSTUB_CLASS 0xfe
25#define HWSTUB_SUBCLASS 0xac
26#define HWSTUB_PROTOCOL 0x1d
27
28#define HWSTUB_VERSION_MAJOR 2
29#define HWSTUB_VERSION_MINOR 9
30#define HWSTUB_VERSION_REV 2
31
32#define HWSTUB_USB_VID 0xfee1
33#define HWSTUB_USB_PID 0xdead
34
35/**
36 * Control commands
37 *
38 * These commands are sent to the device, using the standard bRequest field
39 * of the SETUP packet. This is to take advantage of both wIndex and wValue
40 * although it would have been more correct to send them to the interface.
41 */
42
43/* list of commands */
44#define HWSTUB_GET_INFO 0 /* mandatory */
45#define HWSTUB_GET_LOG 1 /* optional */
46#define HWSTUB_RW_MEM 2 /* optional */
47#define HWSTUB_CALL 3 /* optional */
48#define HWSTUB_JUMP 4 /* optional */
49#define HWSTUB_AES_OTP 5 /* optional */
50
51/**
52 * HWSTUB_GET_INFO: get some information about an aspect of the device.
53 * The wIndex field of the SETUP specifies which information to get. */
54
55/* list of possible information */
56#define HWSTUB_INFO_VERSION 0
57#define HWSTUB_INFO_LAYOUT 1
58#define HWSTUB_INFO_STMP 2
59#define HWSTUB_INFO_FEATURES 3
60
61struct usb_resp_info_version_t
62{
63 uint8_t major;
64 uint8_t minor;
65 uint8_t revision;
66} __attribute__((packed));
67
68struct usb_resp_info_layout_t
69{
70 /* describe the range of memory used by the running code */
71 uint32_t oc_code_start;
72 uint32_t oc_code_size;
73 /* describe the range of memory used by the stack */
74 uint32_t oc_stack_start;
75 uint32_t oc_stack_size;
76 /* describe the range of memory available as a buffer */
77 uint32_t oc_buffer_start;
78 uint32_t oc_buffer_size;
79} __attribute__((packed));
80
81struct usb_resp_info_stmp_t
82{
83 uint16_t chipid; /* 0x3780 for STMP3780 for example */
84 uint8_t rev; /* 0=TA1 on STMP3780 for example */
85 uint8_t is_supported; /* 1 if the chip is supported */
86} __attribute__((packed));
87
88/* list of possible features */
89#define HWSTUB_FEATURE_LOG (1 << 0)
90#define HWSTUB_FEATURE_MEM (1 << 1)
91#define HWSTUB_FEATURE_CALL (1 << 2)
92#define HWSTUB_FEATURE_JUMP (1 << 2)
93#define HWSTUB_FEATURE_AES_OTP (1 << 3)
94
95struct usb_resp_info_features_t
96{
97 uint32_t feature_mask;
98};
99
100/**
101 * HWSTUB_GET_LOG: only if has HWSTUB_FEATURE_LOG.
102 * The log is returned as part of the control transfer.
103 */
104
105/**
106 * HWSTUB_RW_MEM: only if has HWSTUB_FEATURE_MEM.
107 * The 32-bit address is split into two parts.
108 * The low 16-bit are stored in wValue and the upper
109 * 16-bit are stored in wIndex. Depending on the transfer direction,
110 * the transfer is either a read or a write.
111 * The read/write on the device are guaranteed to be 16-bit/32-bit when
112 * possible, making it suitable to read/write registers. */
113
114/**
115 * HWSTUB_x: only if has HWSTUB_FEATURE_x where x=CALL or JUMP.
116 * The 32-bit address is split into two parts.
117 * The low 16-bit are stored in wValue and the upper
118 * 16-bit are stored in wIndex. Depending on the transfer direction,
119 * the transfer is either a read or a write. */
120
121/**
122 * HWSTUB_AES_OTP: only if has HWSTUB_FEATURE_AES_OTP.
123 * The control transfer contains the data to be en/decrypted and the data
124 * is sent back on the interrupt endpoint. The first 16-bytes of the data
125 * are interpreted as the IV. The output format is the same.
126 * The wValue field contains the parameters of the process. */
127#define HWSTUB_AES_OTP_ENCRYPT (1 << 0)
128
129#endif /* __HWSTUB_PROTOCOL__ */