comparison src/cs/system/bootloader/inc/command.h @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /*******************************************************************************
2 *
3 * COMMAND.H
4 *
5 * This module contains commands structures and functions to analyze a command
6 * received and to build a command to send (request and confirmation).
7 *
8 * (C) Texas Instruments 1998
9 *
10 ******************************************************************************/
11
12 #ifndef __COMMAND_H__
13 #define __COMMAND_H__
14
15 #include "main/sys_types.h"
16
17 #define COM_SERIAL_COMMAND_LENGTH (256) /* In bytes. */
18 #define COM_MAX_NUMBER_OF_16BITS_DATA ( 64)
19
20 /*
21 * Constants used in the confirmation of the COM_GET_MONITOR_ID command.
22 */
23
24 enum {
25 COM_MONITOR_STAND_ALONE,
26 COM_MONITOR_LIBRARY,
27 COM_BOOTLOADER
28 };
29
30 /*
31 * Constants used in the confirmation of the COM_GET_CHIP_ID command.
32 */
33
34 enum {
35 COM_POLE112LA00,
36 COM_GEMINI_EFH,
37 COM_CHIP_NOT_SUPPORTED
38 };
39
40 /*
41 * Constants used in the confirmation of the COM_GET_BOARD_ID command.
42 */
43
44 enum {
45 COM_A_SAMPLE_1_0,
46 COM_A_SAMPLE_1_5,
47 COM_EVA4,
48 COM_GAIA_BOARD21
49 };
50
51 /*
52 * Constants used in the confirmation of the COM_START_APPLICATION command.
53 */
54
55 enum {
56 COM_APPLICATION_IS_RUNNING,
57 COM_MONITOR_IS_RUNNING
58 };
59
60 /*
61 * List of commands.
62 */
63
64 enum {
65 COM_GET_MONITOR_ID,
66 COM_GET_FLASH_ID,
67 COM_GET_CHIP_ID,
68 COM_GET_BOARD_ID,
69 COM_ERASE_FLASH,
70 COM_WRITE_DATA,
71 COM_START_APPLICATION,
72 COM_READ_PARAMETERS,
73 COM_WRITE_PARAMETERS,
74 COM_LOAD_APPLICATION,
75 COM_SEND_RUN_ADDRESS
76 };
77
78 /*
79 * Functions results.
80 */
81
82 enum {
83 COM_SUCCESS,
84 COM_NO_EXECUTION,
85 COM_ERASE_ERROR,
86 COM_WRITE_ERROR,
87 COM_PARAMETER_ERROR,
88 COM_ADDRESS_ERROR,
89 COM_FILE_ERROR,
90 COM_NOT_SUPPORTED,
91 COM_COMMAND_UNKNOWN
92 };
93
94
95 /*
96 * Constants used in the bootloader.
97 */
98
99 enum {
100 CMD_RAM_SUCCESS,
101 CMD_RAM_NO_EXECUTION,
102 CMD_RAM_WRITE_ERROR,
103 CMD_RAM_ADDRESS_ERROR,
104 CMD_RAM_FILE_ERROR
105 };
106
107 /*
108 * These macros allow to access to fields of each structure.
109 */
110
111 #define COM_COMMAND_WORD(COMMAND) ((COMMAND)->command_word)
112
113 #define COM_RESULT(COMMAND) ((COMMAND)->result)
114
115 #define COM_MONITOR_ID(COMMAND) ((COMMAND)->param.monitor_id.identifier)
116
117 #define COM_MONITOR_VERSION_FIRST_NBR(COMMAND) ((COMMAND)->param.monitor_id.version_first_nbr)
118
119 #define COM_MONITOR_VERSION_SECOND_NBR(COMMAND) ((COMMAND)->param.monitor_id.version_second_nbr)
120
121 #define COM_FLASH_ID(COMMAND) ((COMMAND)->param.flash_id.identifier)
122
123 #define COM_BOARD_ID(COMMAND) ((COMMAND)->param.board_id.identifier)
124
125 #define COM_FILE_CHECKSUM(COMMAND) ((COMMAND)->param.checksum.file_checksum)
126
127 #define COM_FLASH_CHECKSUM(COMMAND) ((COMMAND)->param.checksum.flash_checksum)
128
129 #define COM_CHIP_ID(COMMAND) ((COMMAND)->param.chip_id.identifier)
130
131 #define COM_STARTING_STATE(COMMAND) ((COMMAND)->param.starting.state)
132
133 #define COM_READ_PARAMS_OFFSET(COMMAND) \
134 ((COMMAND)->param.params_read.param_offset)
135
136 #define COM_NUMBER_OF_PARAMS_READ(COMMAND) \
137 ((COMMAND)->param.params_read.number_of_params)
138
139 #define COM_READ_PARAMS_LIST_ADDRESS(COMMAND) \
140 (&((COMMAND)->param.params_read.param[0]))
141
142 #define COM_WRITTEN_PARAMS_OFFSET(COMMAND) \
143 ((COMMAND)->param.params_written.param_offset)
144
145 #define COM_NUMBER_OF_PARAMS_WRITTEN(COMMAND) \
146 ((COMMAND)->param.params_written.number_of_params)
147
148 #define COM_WRITTEN_PARAMS_LIST_ADDRESS(COMMAND) \
149 (&((COMMAND)->param.params_written.param[0]))
150
151 #define COM_FILE_RAM_CHECKSUM(COMMAND) ((COMMAND)->param.checksum_RAM.file_checksum)
152
153 #define COM_RAM_CHECKSUM(COMMAND) ((COMMAND)->param.checksum_RAM.RAM_checksum)
154
155 #define COM_ADDRESS_MSB(COMMAND) \
156 ((COMMAND)->param.address.address_msb)
157
158 #define COM_ADDRESS_LSB(COMMAND) \
159 ((COMMAND)->param.address.address_lsb)
160
161
162
163 /*
164 * Parameters for each command.
165 * Get software id : no parameter.
166 * Get flash id : no parameter.
167 * Get chip id : no parameter.
168 * Get board id : no parameter.
169 * Erase flash : no parameter.
170 * Write data : no parameter.
171 * Start application : no parameter.
172 */
173
174 /*
175 * Read parameters:
176 * - parameter offset (even),
177 * - number of parameters to read
178 */
179
180 typedef struct s_com_read_params_req {
181 SYS_UWORD16 param_offset;
182 SYS_UWORD8 number_of_params;
183 } t_com_read_params_req;
184
185 /*
186 * Write parameters:
187 * - parameter offset (even),
188 * - number of parameters (16 bits) to write,
189 * - list of parameters to write.
190 */
191
192 typedef struct s_com_write_params_req {
193 SYS_UWORD16 param_offset;
194 SYS_UWORD8 number_of_params;
195 SYS_UWORD16 param[COM_MAX_NUMBER_OF_16BITS_DATA];
196 } t_com_write_params_req;
197
198
199 /*
200 * Start application in RAM
201 * - file checksum,
202 * - flash checksum
203 */
204
205 typedef struct s_com_send_run_address_req {
206 SYS_UWORD16 address_msb;
207 SYS_UWORD16 address_lsb;
208 } t_com_send_run_address_req;
209
210
211 /*
212 * General request structure.
213 */
214
215 typedef struct s_com_request {
216 SYS_UWORD8 command_word;
217 union u_req_param {
218 t_com_read_params_req params_read;
219 t_com_write_params_req params_written;
220 t_com_send_run_address_req address;
221 } param;
222 } t_com_request;
223
224 /*
225 * Parameters for each confirmation.
226 * Erase flash : no parameter.
227 * Write parameters : no parameter.
228 */
229
230 /*
231 * Get monitor id:
232 * - identifier,
233 * - version.
234 */
235
236 typedef struct s_com_get_monitor_id_cnf {
237 SYS_UWORD8 identifier;
238 SYS_UWORD8 version_first_nbr;
239 SYS_UWORD8 version_second_nbr;
240 } t_com_get_monitor_id_cnf;
241
242 /*
243 * Get flash id:
244 * - identifier.
245 */
246
247 typedef struct s_com_get_flash_id_cnf {
248 SYS_UWORD8 identifier;
249 } t_com_get_flash_id_cnf;
250
251 /*
252 * Get chip id:
253 * - identifier.
254 */
255
256 typedef struct s_com_get_chip_id_cnf {
257 SYS_UWORD8 identifier;
258 } t_com_get_chip_id_cnf;
259
260 /*
261 * Get board id:
262 * - identifier.
263 */
264
265 typedef struct s_com_get_board_id_cnf {
266 SYS_UWORD8 identifier;
267 } t_com_get_board_id_cnf;
268
269 /*
270 * Write data:
271 * - file checksum,
272 * - flash checksum
273 */
274
275 typedef struct s_com_write_data_cnf {
276 SYS_UWORD16 file_checksum;
277 SYS_UWORD16 flash_checksum;
278 } t_com_write_data_cnf;
279
280 /*
281 * Start application:
282 * - state (application is running or not)
283 */
284
285 typedef struct s_com_start_application_cnf {
286 SYS_UWORD8 state;
287 } t_com_start_application_cnf;
288
289 /*
290 * Read parameters:
291 * - number of words (16 bits) read,
292 * - list of words read.
293 */
294
295 typedef struct s_com_read_params_cnf {
296 SYS_UWORD8 number_of_params;
297 SYS_UWORD16 param[COM_MAX_NUMBER_OF_16BITS_DATA];
298 } t_com_read_params_cnf;
299
300
301 /*
302 * Load application
303 * - file checksum,
304 * - flash checksum
305 */
306
307 typedef struct s_com_load_appli_cnf {
308 SYS_UWORD16 file_checksum;
309 SYS_UWORD16 RAM_checksum;
310 } t_com_load_appli_cnf;
311
312
313
314
315 /*
316 * General confirmation structure.
317 */
318
319 typedef struct s_com_confirmation {
320 SYS_UWORD8 command_word;
321 SYS_UWORD8 result;
322 union u_cnf_param {
323 t_com_get_monitor_id_cnf monitor_id;
324 t_com_get_flash_id_cnf flash_id;
325 t_com_get_chip_id_cnf chip_id;
326 t_com_get_board_id_cnf board_id;
327 t_com_write_data_cnf checksum;
328 t_com_start_application_cnf starting;
329 t_com_read_params_cnf params_read;
330 t_com_load_appli_cnf checksum_RAM;
331 } param;
332 } t_com_confirmation;
333
334 extern long com_analyze_request (SYS_UWORD8 *request_received,
335 t_com_request *request);
336
337 extern long com_analyze_confirmation (SYS_UWORD8 *confirmation_received,
338 t_com_confirmation *confirmation);
339
340 extern long com_build_request (t_com_request *request,
341 SYS_UWORD8 *request_to_send);
342
343 extern long com_build_confirmation (t_com_confirmation *confirmation,
344 SYS_UWORD8 *confirmation_to_send);
345
346 #endif /* __COMMAND_H__ */