Callisto4Bootloader: include/c4_parser.h File Reference

Callisto4Bootloader

Macros | Enumerations | Functions | Variables
c4_parser.h File Reference

Interface to simple parser. More...

`#include "c4_error_codes.h"`
`#include "stdint.h"`

Go to the source code of this file.

## Macros

#define | PARSER_KEYWORDS
| definition of parser keywords. More...
#define | CALLISTO_PARSER(Id, Text, Desc, Exa) C4_BOOT_CONFIG_PARSER_##Id,
| X-Macro function to construct enumeration, Text string array, description string array and example array. More...

## Enumerations

enum | E_parseIndices_t { NUM_PARSE_TERMS }
| Enumeration of parser items. More...
enum | file_op_t { E_NOOP, E_REPLACE, E_APPEND, E_EXTEND, E_REMOVE }
| file operation type. More...

## Functions

exit_code_t | GetConfig (const char *mem, uint32_t mem_len, E_parseIndices_t field, char *pVal)
| Parse the specified memory location. More...
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. More...

## Variables

const char | C4_parseStrings [NUM_PARSE_TERMS+1][32]
| Array of strings to use in parser. More...

## Detailed Description

Interface to simple parser.

Copyright
  2020 Remsdaq Ltd.

Date
  20 May 2020

Author
  Dan Smithers dwhs@.nosp@m.rems.nosp@m.daq.c.nosp@m.om

Definition in file c4_parser.h.

## Macro Definition Documentation

## ◆ CALLISTO_PARSER

#define CALLISTO_PARSER | ( |  | Id,
|  |  | Text,
|  |  | Desc,
|  |  | Exa
| ) |  | C4_BOOT_CONFIG_PARSER_##Id,

X-Macro function to construct enumeration, Text string array, description string array and example array.

Parameters

  [in] | Id | Identifier
  [in] | Text | Config file string.
  [in] | Desc | Descriptive string.
  [in] | Exa | Example string

Definition at line 62 of file c4_parser.h.

## ◆ PARSER_KEYWORDS

#define PARSER_KEYWORDS

Value:
CALLISTO_PARSER(START, "Callisto4BootConfig", \
"this specifies the file as applying to the Remsdaq Callisto 4 bootloader and contains a version identifier in maj.min form.", \
"=0.1") \
CALLISTO_PARSER(CURRENT, "CurrentApp", \
"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.", \
"=0x60120000") \
CALLISTO_PARSER(RECOVERY, "RecoveryApp", \
"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.", \
"=0x601B0000") \
CALLISTO_PARSER(FAULTY, "FaultyApp", \
"this specifies a location containing a known faulty application.\n\tThis appears zero or more times. Multiple definitions are combined.", \
"=0x60220000") \
CALLISTO_PARSER(ARGS, "Args", \
"Optional field for arguments to be passed t all applications.\n\t This may appear zero or more times. Multiple definitions are concatenated.", \
"=--colour=CYAN --rate=250\nArgs=--ratio=2") \
CALLISTO_PARSER(END, "EndConfig", \
"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.", \
"\n0x########\n\\0\n")

definition of parser keywords.

Definition at line 34 of file c4_parser.h.

## Enumeration Type Documentation

## ◆ E_parseIndices_t

enum E_parseIndices_t

Enumeration of parser items.

Enumerator
NUM_PARSE_TERMS |

Definition at line 59 of file c4_parser.h.

## ◆ file_op_t

enum file_op_t

file operation type.

Enumerator
E_NOOP |
E_REPLACE |
E_APPEND |
E_EXTEND |
E_REMOVE |

Definition at line 70 of file c4_parser.h.

## Function Documentation

## ◆ GetConfig()

exit_code_t GetConfig | ( | const char * | mem,
|  | uint32_t | mem_len,
|  | E_parseIndices_t | field,
|  | char * | pVal
| ) |  |

Parse the specified memory location.

Search from the memory location for the specified field and return the value stored there in pVal

Parameters

  [in] | mem | Memory location for start of file.
  [in] | mem_len | Length of data at location
  [in] | field | Field identifier
  [out] | pVal | Pointer to return field value.

Returns
  Exit code.

Return values

  ERR_OK | Success.
  ERR_FILE_NOT_FOUND | Memory file not found.
  ERR_FIELD_NOT_FOUND | Memory field not found.
  ERR_SYNTAX | Memory file does not parse.

Definition at line 139 of file c4_parser.c.

## ◆ 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.

Search from the memory location for the specified field and return the

Parameters

  [in] | mem | Memory location for start of file.
  [in] | mem_len | Length of data at location
  [in] | field | Field identifying string
  [in] | val | New field value.
  [in] | op | Flag to denote whether the value should be replaced only, used to extend existing field, or appended if not found

Returns
  Exit code.

Return values

  ERR_OK | Success.
  ERR_FILE_NOT_FOUND | Memory file not found.
  ERR_FIELD_NOT_FOUND | Memory field not found.
  ERR_NOT_IMPLEMENTED | Operation not implemented.
  ERR_SYNTAX | Memory file does not parse.

Definition at line 221 of file c4_parser.c.

## Variable Documentation

## ◆ C4_parseStrings

const char C4_parseStrings[NUM_PARSE_TERMS+1][32]

Array of strings to use in parser.

Definition at line 110 of file c4_parser.c.

CURRENT
static const uint32_t CURRENT
Index in jump location array for currant image.
Definition: bootloader.c:169
CALLISTO_PARSER
#define CALLISTO_PARSER(Id, Text, Desc, Exa)
X-Macro function to construct enumeration, Text string array, description string array and example ar...
Definition: c4_parser.h:62
RECOVERY
static const uint32_t RECOVERY
Definition: bootloader.c:170