[coreboot-gerrit] Patch set updated for coreboot: fmaptool: emit list of CBFS regions on request

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Thu Jan 21 15:19:46 CET 2016


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13058

-gerrit

commit 489b8bbe8bfc094d36695fb39f4f658492c9dbab
Author: Patrick Georgi <pgeorgi at chromium.org>
Date:   Wed Jan 20 15:29:30 2016 +0100

    fmaptool: emit list of CBFS regions on request
    
    The CBFS flag in fmd files isn't stored in the fmap, so allow storing it
    out of band using the -R option.
    
    Change-Id: I342772878d7f8ce350de1a32dc7b2a5b07d6617d
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
 util/cbfstool/fmaptool.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/util/cbfstool/fmaptool.c b/util/cbfstool/fmaptool.c
index c839707..c3b4a67 100644
--- a/util/cbfstool/fmaptool.c
+++ b/util/cbfstool/fmaptool.c
@@ -45,7 +45,7 @@ static void usage(const char *invoked_as)
 									stderr);
 	fputs("\nUSAGE:\n", stderr);
 	fprintf(stderr,
-		"\t%s [-h <header output file>] <fmd input file> <binary output file>\n",
+		"\t%s [-h <header output file>] [-R <region output file>] <fmd input file> <binary output file>\n",
 								invoked_as);
 	fputs("\nMANDATORY ARGUMENTS:\n", stderr);
 	fprintf(stderr,
@@ -56,6 +56,8 @@ static void usage(const char *invoked_as)
 	fprintf(stderr,
 		"-h\tAlso produce a C header defining %s to the FMAP section's flash offset.\n",
 							HEADER_FMAP_OFFSET);
+	fprintf(stderr,
+		"-R\tAlso produce a text file listing the CBFS regions, comma separated.\n");
 	fputs("\nOUTPUT:\n", stderr);
 	fputs("A successful invocation prints a summary of work done to standard error, and a comma-separated list\n",
 									stderr);
@@ -63,7 +65,7 @@ static void usage(const char *invoked_as)
 									stderr);
 }
 
-static void list_cbfs_section_names(void)
+static void list_cbfs_section_names(FILE *out)
 {
 	cbfs_section_iterator_t cbfs_it = cbfs_sections_iterator();
 	assert(cbfs_it);
@@ -73,11 +75,11 @@ static void list_cbfs_section_names(void)
 		const char *cur_name =
 				cbfs_sections_iterator_deref(cbfs_it)->name;
 		if (cbfs_sections_iterator_advance(&cbfs_it) && subsequent)
-			putchar(',');
-		fputs(cur_name, stdout);
+			fputc(',', out);
+		fputs(cur_name, out);
 		subsequent = true;
 	}
-	putchar('\n');
+	fputc('\n', out);
 }
 
 static bool write_header(const char *out_fname,
@@ -123,15 +125,19 @@ int main(int argc, char **argv)
 
 		// Optional
 		const char *header_filename;
-	} args = {NULL, NULL, NULL};
+		const char *region_filename;
+	} args = {NULL};
 
 	bool show_usage = false;
 	int each_arg;
-	while (!show_usage && (each_arg = getopt(argc, argv, ":h:")) != -1) {
+	while (!show_usage && (each_arg = getopt(argc, argv, ":h:R:")) != -1) {
 		switch (each_arg) {
 		case 'h':
 			args.header_filename = optarg;
 			break;
+		case 'R':
+			args.region_filename = optarg;
+			break;
 		case ':':
 			fprintf(stderr, "-%c: Expected an accompanying value\n",
 									optopt);
@@ -233,7 +239,15 @@ int main(int argc, char **argv)
 							args.fmap_filename,
 			args.header_filename ? " (and generated header)" : "");
 	fputs("The sections containing CBFSes are: ", stderr);
-	list_cbfs_section_names();
+	list_cbfs_section_names(stdout);
+	if (args.region_filename) {
+		FILE *region_file = fopen(args.region_filename, "w");
+		if (region_file == NULL)
+			return FMAPTOOL_EXIT_FAILED_WRITING_OUTPUT;
+
+		list_cbfs_section_names(region_file);
+		fclose(region_file);
+	}
 
 	full_fmd_cleanup(&descriptor);
 	return FMAPTOOL_EXIT_SUCCESS;



More information about the coreboot-gerrit mailing list