diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-12 19:46:04 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-12 19:46:04 +0200 |
commit | 11da9d23fe323ce452fcd04a10a0ddf78eaa63ea (patch) | |
tree | 7ab4d162b2a944214bb01d498d5a0400dec031a0 /utils/hwstub/hwemul_protocol.h | |
parent | 3f4eeb850e91fd026a99f2b17bd7e0837f112bb5 (diff) | |
download | rockbox-11da9d23fe323ce452fcd04a10a0ddf78eaa63ea.tar.gz rockbox-11da9d23fe323ce452fcd04a10a0ddf78eaa63ea.zip |
imxtools: move hwemul to its own directory
The hwemul is only partly imx specific: the stub is stmp specific
but could be ported to other targets, the computer side and the
protocol are mostly stmp independent (or should be).
Change-Id: If88febffe591b0de86ea11cb740455ba20ddc401
Diffstat (limited to 'utils/hwstub/hwemul_protocol.h')
-rw-r--r-- | utils/hwstub/hwemul_protocol.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/utils/hwstub/hwemul_protocol.h b/utils/hwstub/hwemul_protocol.h new file mode 100644 index 0000000000..f11fd91352 --- /dev/null +++ b/utils/hwstub/hwemul_protocol.h | |||
@@ -0,0 +1,127 @@ | |||
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 __HWEMUL_PROTOCOL__ | ||
22 | #define __HWEMUL_PROTOCOL__ | ||
23 | |||
24 | #define HWEMUL_CLASS 0xfe | ||
25 | #define HWEMUL_SUBCLASS 0xac | ||
26 | #define HWEMUL_PROTOCOL 0x1d | ||
27 | |||
28 | #define HWEMUL_VERSION_MAJOR 2 | ||
29 | #define HWEMUL_VERSION_MINOR 8 | ||
30 | #define HWEMUL_VERSION_REV 2 | ||
31 | |||
32 | #define HWEMUL_USB_VID 0xfee1 | ||
33 | #define HWEMUL_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 HWEMUL_GET_INFO 0 /* mandatory */ | ||
45 | #define HWEMUL_GET_LOG 1 /* optional */ | ||
46 | #define HWEMUL_RW_MEM 2 /* optional */ | ||
47 | #define HWEMUL_CALL 3 /* optional */ | ||
48 | #define HWEMUL_JUMP 4 /* optional */ | ||
49 | #define HWEMUL_AES_OTP 5 /* optional */ | ||
50 | |||
51 | /** | ||
52 | * HWEMUL_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 HWEMUL_INFO_VERSION 0 | ||
57 | #define HWEMUL_INFO_LAYOUT 1 | ||
58 | #define HWEMUL_INFO_STMP 2 | ||
59 | #define HWEMUL_INFO_FEATURES 3 | ||
60 | |||
61 | struct usb_resp_info_version_t | ||
62 | { | ||
63 | uint8_t major; | ||
64 | uint8_t minor; | ||
65 | uint8_t revision; | ||
66 | } __attribute__((packed)); | ||
67 | |||
68 | struct 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 | |||
81 | struct 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 HWEMUL_FEATURE_LOG (1 << 0) | ||
90 | #define HWEMUL_FEATURE_MEM (1 << 1) | ||
91 | #define HWEMUL_FEATURE_CALL (1 << 2) | ||
92 | #define HWEMUL_FEATURE_JUMP (1 << 2) | ||
93 | #define HWEMUL_FEATURE_AES_OTP (1 << 3) | ||
94 | |||
95 | struct usb_resp_info_features_t | ||
96 | { | ||
97 | uint32_t feature_mask; | ||
98 | }; | ||
99 | |||
100 | /** | ||
101 | * HWEMUL_GET_LOG: only if has HWEMUL_FEATURE_LOG. | ||
102 | * The log is returned as part of the control transfer. | ||
103 | */ | ||
104 | |||
105 | /** | ||
106 | * HWEMUL_RW_MEM: only if has HWEMUL_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 | |||
112 | /** | ||
113 | * HWEMUL_x: only if has HWEMUL_FEATURE_x where x=CALL or JUMP. | ||
114 | * The 32-bit address is split into two parts. | ||
115 | * The low 16-bit are stored in wValue and the upper | ||
116 | * 16-bit are stored in wIndex. Depending on the transfer direction, | ||
117 | * the transfer is either a read or a write. */ | ||
118 | |||
119 | /** | ||
120 | * HWEMUL_AES_OTP: only if has HWEMUL_FEATURE_AES_OTP. | ||
121 | * The control transfer contains the data to be en/decrypted and the data | ||
122 | * is sent back on the interrupt endpoint. The first 16-bytes of the data | ||
123 | * are interpreted as the IV. The output format is the same. | ||
124 | * The wValue field contains the parameters of the process. */ | ||
125 | #define HWEMUL_AES_OTP_ENCRYPT (1 << 0) | ||
126 | |||
127 | #endif /* __HWEMUL_PROTOCOL__ */ | ||