comparison fluid-mnf/calplus/ram_load.h @ 311:9cecc930d78f

fluid-mnf: original source from TI, defenestrated line endings and rearranged directory structure, but no *.[ch] source file content changes yet
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 29 Feb 2020 05:36:07 +0000
parents
children
comparison
equal deleted inserted replaced
310:ae39d76d5b7a 311:9cecc930d78f
1 /* %Z% nom : %M% SID: %I% date : %G% */
2 /* Filename: %M% */
3 /* Version: %I% */
4 /******************************************************************************
5 * WIRELESS COMMUNICATION SYSTEM DEVELOPMENT
6 *
7 * (C) 2002 Texas Instruments France. All rights reserved
8 *
9 * Author : Francois AMAND
10 *
11 *
12 * Important Note
13 * --------------
14 *
15 * This S/W is a preliminary version. It contains information on a product
16 * under development and is issued for evaluation purposes only. Features
17 * characteristics, data and other information are subject to change.
18 *
19 * The S/W is furnished under Non Disclosure Agreement and may be used or
20 * copied only in accordance with the terms of the agreement. It is an offence
21 * to copy the software in any way except as specifically set out in the
22 * agreement. No part of this document may be reproduced or transmitted in any
23 * form or by any means, electronic or mechanical, including photocopying and
24 * recording, for any purpose without the express written permission of Texas
25 * Instruments Inc.
26 *
27 ******************************************************************************
28 *
29 * FILE NAME: ram_load.c
30 *
31 *
32 * PURPOSE: Describe the RAM loader state machine used during boot procedure
33 * in order to download a FLASH programmer into the Internal RAM if
34 * CALYPSOPLUS chip.
35 *
36 *
37 *
38 * FILE REFERENCES:
39 *
40 * Name IO Description
41 * ------------- -- ---------------------------------------------
42 *
43 *
44 *
45 * EXTERNAL VARIABLES:
46 *
47 * Source:
48 *
49 * Name Type IO Description
50 * ------------------- --------------- -- ----------------------------
51 *
52 *
53 * EXTERNAL REFERENCES:
54 *
55 * Name Description
56 * ------------------ -------------------------------------------------------
57 *
58 *
59 *
60 * ABNORMAL TERMINATION CONDITIONS, ERROR AND WARNING MESSAGES:
61 *
62 *
63 *
64 * ASSUMPTION, CONSTRAINTS, RESTRICTIONS:
65 *
66 *
67 *
68 * NOTES:
69 *
70 *
71 *
72 * REQUIREMENTS/FUNCTIONAL SPECIFICATION REFERENCES:
73 *
74 *
75 *
76 *
77 * DEVELOPMENT HISTORY:
78 *
79 * Date Name(s) Version Description
80 * ---------- -------------- ------- --------------------------------------
81 * 31-May-02 Francois AMAND V1.0.0 Import from CALYPSO
82 *
83 * ALGORITHM: Use the RAM loader state machine defined in CALPLUS208 specifica-
84 * tion.
85 *
86 *
87 *****************************************************************************/
88
89
90 #ifndef _RAM_LOADER_H_
91 #define _RAM_LOADER_H_
92
93 /*
94 * Include files
95 */
96 #include "standard.h"
97 #include "secure_types.h"
98
99 #define C_MAX_PLATFORM_DATA 64192
100
101 /*
102 * Main buffer size
103 */
104 // Include manufacture certificate + platform data + manufacturer certificate signature
105 #define C_MAX_BUFFER_SIZE (sizeof(T_MANUFACTURER_CERTIFICATE) + C_MAX_PLATFORM_DATA + C_MANUF_SIG_SIZE * C_WORD32LGB)
106
107 /*
108 * Serial interface choice
109 */
110 enum {
111 #ifdef _SERIAL_IRDA_
112 C_SERIAL_ID_MODEM = 0,
113 C_SERIAL_ID_IRDA = 1
114 #else
115 C_SERIAL_ID_MODEM = 0
116 #endif
117 };
118
119
120 /*
121 * RAM loader state
122 */
123 typedef enum {
124 C_RESET_STATE = 0,
125 C_SIGNALLING_STATE = 1,
126 C_AWAIT_PARAMETER_STATE = 2,
127 C_COMMAND_PHASE_STATE = 3
128 } T_RAM_LOADER_PC_STATE;
129
130
131 /*
132 * RAM loader event
133 */
134 typedef enum {
135 C_NO_EVENT = 0,
136
137 C_USER_DOWNLOAD_REQUEST = 1,
138 C_USER_ABORT_REQUEST = 2,
139
140 C_SIGNALLING_TIMEOUT = 3,
141 C_WATCHDOG_TIMEOUT = 4,
142
143 C_SIGNALLING_RESPONSE = 5,
144 C_PARAMETER_ACK_RESPONSE = 6,
145 C_PARAMETER_NACK_RESPONSE = 7,
146 C_WRITE_ACK_RESPONSE = 8,
147 C_WRITE_NACK_RESPONSE = 9,
148 C_CERTIFICATE_ACK_RESPONSE = 10
149 } T_RAM_LOADER_PC_EVENT;
150
151
152 /*
153 * RAM loader command
154 */
155 typedef enum {
156 C_SIGNALLING_REQUEST_CMD = 0,
157 C_PARAMETER_REQUEST_CMD = 1,
158 C_WRITE_REQUEST_CMD = 2,
159 C_ABORT_REQUEST_CMD = 3,
160 C_CERTIFICATE_REQUEST_CMD = 4
161 } T_RAM_LOADER_PC_COMMAND;
162
163
164 /*
165 * RAM loader timer
166 */
167 typedef enum {
168 C_SIGNALLING_TIMER = 0,
169 C_WATCHDOG_TIMER = 1
170 } T_RAM_LOADER_PC_TIMER;
171
172 #define C_RAM_LOADER_PC_NB_TIMER 2
173
174
175 /*
176 * Timeout definition in ms
177 */
178 #define C_SIGNALLING_TIMEOUT_VALUE 4L /* 2 ms */
179 #define C_WATCHDOG_TIMEOUT_VALUE 120000L /* 2 mn */
180
181
182 /*
183 * RAM loader status
184 */
185 typedef enum {
186 C_NO_STATUS = 0,
187 C_BAD_INPUT_FILE = 1,
188 C_SUCCESS = 2,
189 C_BAD_PARAMETERS = 3,
190 C_ERROR_DURING_WRITE = 4,
191 C_BAD_ADDRESS_OF_BRANCH = 5,
192 C_WATCHDOG_TIMER_REACHED = 6,
193 C_USER_ABORT = 7
194 } T_RAM_LOADER_PC_STATUS;
195
196
197 enum {
198 C_COMMAND_NOT_RECEIVED = 0,
199 C_COMMAND_RECEIVED = 1,
200 C_SERIAL_TIMEOUT = 2
201 };
202
203 typedef struct {
204 UWORD8 d_nb_data;
205 UWORD32 d_address;
206 UWORD8 *p_block;
207 } T_WRITE_REQUEST;
208
209
210 typedef struct {
211 UWORD16 d_max_byte;
212 UWORD8 a_data[sizeof(T_MANUFACTURER_CERTIFICATE_FLASH_PROGRAMMER)];
213 } T_FRAME;
214
215
216 typedef struct {
217 UWORD8 d_device_id;
218 UWORD8 d_baud_rate;
219 char *p_file_name;
220
221 /*
222 * Signalling response variable
223 */
224 UWORD16 d_romcode_version;
225 UWORD8 a_hash_man_pub_key[C_MD5HASHLG * C_WORD32LGB];
226 UWORD8 a_die_id[C_WORD32LGB * C_DIE_ID_SIZE];
227 UWORD8 a_Certsig[C_WORD32LGB * C_MANUF_SIG_SIZE];
228
229 /*
230 * Parameter NACK response variable
231 */
232 UWORD8 d_param_req_sts;
233
234 /*
235 * Certificate request variable
236 */
237 BOOLEAN b_certificate_request;
238
239 /*
240 * Certificate response variable
241 */
242 union {
243 UWORD8 a_firm_cert[C_MAX_BUFFER_SIZE]; /* Take into account max data_platform size */
244 T_MANUFACTURER_CERTIFICATE_PLATFORM_DATA d_firm_cert;
245 } u_firm_cert;
246
247 /*
248 * Command request variable
249 */
250 UWORD32 d_uart_timeout;
251 union {
252 UWORD8 a_code_certificate[sizeof(T_MANUFACTURER_CERTIFICATE_FLASH_PROGRAMMER)];
253 T_MANUFACTURER_CERTIFICATE_FLASH_PROGRAMMER d_code_certificate;
254 } u_code_certificate;
255
256 /*
257 * Write request variable
258 */
259 UWORD32 d_nb_byte_in_block;
260 UWORD32 d_nb_byte_sent;
261 UWORD8 *p_block_buffer;
262 UWORD32 d_block_address;
263 UWORD32 d_block_size;
264
265 /*
266 * Mobile received variable
267 */
268 //UWORD16 d_max_block_size;
269 //UWORD16 d_mobile_buffer_size;
270 UWORD8 d_write_status;
271
272 //T_WRITE_REQUEST d_parameter_request;
273 } T_RAM_LOADER;
274
275
276 /*
277 * RAM loader baud rate definition
278 */
279 typedef enum {
280 C_BAUD_RATE_812500 = 0,
281 C_BAUD_RATE_406250 = 1,
282 C_BAUD_RATE_203125 = 2,
283 C_BAUD_RATE_115200 = 3,
284 C_BAUD_RATE_57600 = 4,
285 C_BAUD_RATE_38400 = 5,
286 C_BAUD_RATE_28800 = 6,
287 C_BAUD_RATE_19200 = 7,
288 C_BAUD_RATE_DEFAULT = 7,
289 C_BAUD_RATE_9600 = 8
290 } T_BAUD_RATE;
291
292
293 #define C_BLOCK_INDEX_OFFSET 0
294 #define C_NB_BLOCK_OFFSET 1
295 #define C_BLOCK_SIZE_OFFSET 2
296 #define C_BLOCK_ADDRESS_OFFSET 4
297 #define C_BLOCK_DATA_OFFSET 8
298
299 #endif