Allow users to specify the handler to process special configuration
PATCH 1/3 Allow users to specify the handler to process special configuration
--- src/cbootimage.c | 4 ++-- src/parse.c | 13 +++++++++---- src/parse.h | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-)
src/cbootimage.c +2 -2
@@ -200,14 +200,14 @@ main(int argc, char *argv[])/* first, if we aren't generating the bct, read in config file */ if (context.generate_bct ==0 ) { -process_config_file (&context,1 ); +process_config_file (&context,1 ,NULL ); }/* Generate the new bct file */ else {/* Initialize the bct memory */ init_bct (&context);/* Parse & process the contents of the config file. */ -process_config_file (&context,0 ); +process_config_file (&context,0 ,NULL );/* Update the BCT */ begin_update (&context);/* Signing the bct. */
src/parse.c +9 -4
@@ -698,7 +698,8 @@ process_statement(build_image_context *context,* @param context The main context pointer * @param simple_parse Simple parse flag */ -void process_config_file (build_image_context *context,u_int8_t simple_parse) +void process_config_file (build_image_context *context,u_int8_t simple_parse, +int (*special_handler)(build_image_context *context,char *buffer)) {char buffer[MAX_BUFFER ];int space =0 ;
@@ -707,6 +708,7 @@ void process_config_file(build_image_context *context, u_int8_t simple_parse)u_int8_t comment =0 ;u_int8_t string =0 ;u_int8_t equal_encounter =0 ; +int e;assert (context !=NULL );assert (context->config_file !=NULL );
@@ -737,11 +739,14 @@ void process_config_file(build_image_context *context, u_int8_t simple_parse)case ';' :if (!string && !comment) { buffer[space++] ='\0' ; +if (special_handler) + e =special_handler (context, buffer); +else + e =process_statement (context, buffer, simple_parse); -if (process_statement (context, - buffer, - simple_parse)) +if (e) goto error; + space =0 ; equal_encounter =0 ; }else if (string)
src/parse.h +2 -1
@@ -763,7 +763,8 @@ typedef struct cbootimage_soc_config_rec {parse_subfield_item *device_type_table; } cbootimage_soc_config; -void process_config_file (build_image_context *context,u_int8_t simple_parse); +void process_config_file (build_image_context *context,u_int8_t simple_parse, +int (*special_handler)(build_image_context *context,char *buffer));void t124_get_soc_config (build_image_context *context,cbootimage_soc_config **soc_config);
Signature · 1 line
1.8.1.5
A message that is not in the archive (sent off-list or not yet received): 1390893857-18716-1-git-send-email-vinceh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
PATCH 2/3 Export several parsing functions for external use
--- src/parse.c | 14 +++----------- src/parse.h | 7 +++++++ 2 files changed, 10 insertions(+), 11 deletions(-)
src/parse.c +3 -11
@@ -43,20 +43,12 @@ set_array(build_image_context *context,u_int32_t index, parse_token token, u_int32_t value); -static char *parse_u32 (char *str,u_int32_t *val);static char *parse_u8 (char *str,u_int32_t *val);static char *parse_filename (char *str,char *name,int chars_remaining);static char *parse_enum (build_image_context *context,char *str,enum_item *table,u_int32_t *val); -static char -*parse_field_name (char *rest,field_item *field_table,field_item **field); -static char -*parse_field_value (build_image_context *context, -char *rest, -field_item *field, -u_int32_t *value);static int parse_array (build_image_context *context,parse_token token,char *rest); static int
@@ -115,7 +107,7 @@ static parse_item s_top_level_items[] = {* @param val Returns value that was parsed * @return the remainder of the string after the number was parsed */ -static char * +char *parse_u32 (char *str,u_int32_t *val) {u_int32_t value =0 ;
@@ -206,7 +198,7 @@ parse_filename(char *str, char *name, int chars_remaining)* @param field Returns the field item that was parsed * @return NULL or the remainder of the string after the field item was parsed */ -static char +char *parse_field_name (char *rest,field_item *field_table,field_item **field) {u_int32_t i;
@@ -245,7 +237,7 @@ static char* @param value Returns the value that was parsed * @return the remainder of the string after the value was parsed */ -static char +char *parse_field_value(build_image_context *context, char *rest, field_item *field,
src/parse.h +7 -0
@@ -921,4 +921,11 @@ extern parse_subfield_item s_device_type_table_t30[];extern parse_subfield_item s_device_type_table_t114[];extern parse_subfield_item s_device_type_table_t124[]; +char *parse_u32 (char *str,u_int32_t *val); +char *parse_field_name (char *rest,field_item *field_table,field_item **field); +char *parse_field_value (build_image_context *context, +char *rest, +field_item *field, +u_int32_t *value); +#endif /* #ifndef INCLUDED_PARSE_H */
Signature · 1 line
1.8.1.5
PATCH 3/3 Implement the utility gen_sdram_array
In reply to a message not in the archiveThis patch implemtns the ubility to generate a header file from multiple sdram config files which each has one set of sdram parameters inside only.
--- src/Makefile.am | 34 +++++- src/gen_sdram_array.c | 305 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+), 1 deletion(-) create mode 100644 src/gen_sdram_array.c
src/Makefile.am +33 -1
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CFLAGS = -Wall -std=c99 -bin_PROGRAMS = cbootimage bct_dump +bin_PROGRAMS = cbootimage bct_dump gen_sdram_array cbootimage_SOURCES = \ cbootimage.c \ data_layout.c \
@@ -68,3 +68,35 @@ bct_dump_SOURCES = \ t114/nvboot_sdram_param_t114.h \ t124/nvboot_bct_t124.h \ t124/nvboot_sdram_param_t124.h + +gen_sdram_array_SOURCES = \ + gen_sdram_array.c \ + data_layout.c \ + set.c \ + crypto.c \ + aes_ref.c \ + context.c \ + parse.c \ + t124/parse_t124.c \ + t114/parse_t114.c \ + t30/parse_t30.c \ + t20/parse_t20.c \ + t124/nvbctlib_t124.c \ + t114/nvbctlib_t114.c \ + t30/nvbctlib_t30.c \ + t20/nvbctlib_t20.c \ + cbootimage.h \ + context.h \ + crypto.h \ + data_layout.h \ + nvaes_ref.h \ + parse.h \ + set.h \ + t20/nvboot_bct_t20.h \ + t20/nvboot_sdram_param_t20.h \ + t30/nvboot_bct_t30.h \ + t30/nvboot_sdram_param_t30.h \ + t114/nvboot_bct_t114.h \ + t114/nvboot_sdram_param_t114.h \ + t124/nvboot_bct_t124.h \ + t124/nvboot_sdram_param_t124.h
src/gen_sdram_array.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
1.8.1.5
A message that is not in the archive (sent off-list or not yet received): 1390893857-18716-3-git-send-email-vinceh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Re: [cbootimage PATCH 3/3] Implement the utility gen_sdram_array
Quoted 3 lines · Vince Hsu
This patch implemtns the ubility to generate a header file from multiple sdram config files which each has one set of sdram parameters inside only.
I have no idea what this patch is meant to do. What kind of header file, what are the input and output formats *exactly*, is there an example somewhere?
Reading the code doesn't give me much more of a clue. but I /think/ the following might do the same thing?
cat all_the_input_files | sed -e 's/SDRAM[\d+]//'
?
If so, then I'm not sure it's worth even putting this feature into cbootimage at all, and if it is, a shell script might be a better idea.