Callisto4Bootloader: include/c4_parser.h Source File

Callisto4Bootloader

c4_parser.h
Go to the documentation of this file.
1
11 #ifndef C4_PARSER_H_
12 #define C4_PARSER_H_
13
14 /*******************************************************************************
15 * Includes
16 ******************************************************************************/
17
18 #include "c4_error_codes.h"
19 #include "stdint.h"
20
21 /*******************************************************************************
22 * Defines
23 ******************************************************************************/
24
35 #define PARSER_KEYWORDS \
36 CALLISTO_PARSER(START, "Callisto4BootConfig", \
37 "this specifies the file as applying to the Remsdaq Callisto 4 bootloader and contains a version identifier in maj.min form.", \
38 "=0.1") \
39 CALLISTO_PARSER(CURRENT, "CurrentApp", \
40 "this specifies the address the current application image is stored at in QSPI flash. It also implicitly specifies the location of the configuration file for the current application.\n\tThis appears exactly once.", \
41 "=0x60120000") \
42 CALLISTO_PARSER(RECOVERY, "RecoveryApp", \
43 "this specifies the address the recovery application image is stored at in QSPI flash. It also implicitly specifies the location of the configuration file for the recovery application.\n\tThis appears zero or one time.", \
44 "=0x601B0000") \
45 CALLISTO_PARSER(FAULTY, "FaultyApp", \
46 "this specifies a location containing a known faulty application.\n\tThis appears zero or more times. Multiple definitions are combined.", \
47 "=0x60220000") \
48 CALLISTO_PARSER(ARGS, "Args", \
49 "Optional field for arguments to be passed t all applications.\n\t This may appear zero or more times. Multiple definitions are concatenated.", \
50 "=--colour=CYAN --rate=250\nArgs=--ratio=2") \
51 CALLISTO_PARSER(END, "EndConfig", \
52 "This marks the end of the configuration file and is followed by a checksum to verify the integrity of the boot configuration and a terminating Null which enables the file to be parsed as a string.", \
53 "\n0x########\n\\0\n")
54
55
56 /*******************************************************************************
57 * Structures
58 ******************************************************************************/
59
61 typedef enum
62 {
63 #define CALLISTO_PARSER(Id, Text, Desc, Exa) \
64 C4_BOOT_CONFIG_PARSER_##Id,
65 PARSER_KEYWORDS
66 #undef CALLISTO_PARSER
67 NUM_PARSE_TERMS
68 } E_parseIndices_t;
69
72 typedef enum {
73 E_NOOP, //< @brief Null operation so op can be replaced in parser processing.
74 E_REPLACE, //< @brief Replace existing field only if present, otherwise return error.
75 E_APPEND, //< @brief Replace existing field if present, or append new field of this name.
76 E_EXTEND, //< @brief Extend existing field if present or append new field of this name.
77 E_REMOVE //< @brief Remove existing field if present with specified value.
78 } file_op_t;
79
80 /*******************************************************************************
81 * Prototypes
82 ******************************************************************************/
83
100 exit_code_t GetConfig(const char *mem, uint32_t mem_len, E_parseIndices_t field, char *pVal);
101
119 exit_code_t SetConfig(const char *mem, uint32_t mem_len, E_parseIndices_t field, const char *val, file_op_t op);
120
121 /*******************************************************************************
122 * Variables
123 ******************************************************************************/
124
126 extern const char C4_parseStrings[NUM_PARSE_TERMS+1][32];
127
128 #endif /* C4_PARSER_H_ */
PARSER_KEYWORDS
#define PARSER_KEYWORDS
definition of parser keywords.
Definition: c4_parser.h:34
E_APPEND
Definition: c4_parser.h:73
file_op_t
file_op_t
file operation type.
Definition: c4_parser.h:70
NUM_PARSE_TERMS
Definition: c4_parser.h:66
c4_error_codes.h
Enumeration of Error Codes.
SetConfig
exit_code_t SetConfig(const char *mem, uint32_t mem_len, E_parseIndices_t field, const char *val, file_op_t op)
Set value in the specified memory location.
Definition: c4_parser.c:221
E_EXTEND
Definition: c4_parser.h:74
exit_code_t
exit_code_t
Enumeration of error codes.
Definition: c4_error_codes.h:96
E_parseIndices_t
E_parseIndices_t
Enumeration of parser items.
Definition: c4_parser.h:59
E_REMOVE
Definition: c4_parser.h:75
E_NOOP
Definition: c4_parser.h:71
GetConfig
exit_code_t GetConfig(const char *mem, uint32_t mem_len, E_parseIndices_t field, char *pVal)
Parse the specified memory location.
Definition: c4_parser.c:139
C4_parseStrings
const char C4_parseStrings[NUM_PARSE_TERMS+1][32]
Array of strings to use in parser.
Definition: c4_parser.c:110
E_REPLACE
Definition: c4_parser.h:72