summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfstool.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2012-12-14 17:16:21 -0600
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-03-27 01:25:12 +0100
commit6b0d0d6e14f8e385e1457df5699136473144ed60 (patch)
tree25a21e39c1729b996059b56ff83818ceb1d24595 /util/cbfstool/cbfstool.c
parentdc7bc8e589c4b9f45e57327c2f989ef8f2a0e7c4 (diff)
cbfstool: Add update-fit command
Add support for filling in the Firmware Interface Table. For now it only supports adding microcode entries. It takes 2 options: 1. Name of file in cbfs where the mircocode is located 2. The number of empty entries in the table. Verified with go firmware tools. Also commented out updating microcode in the bootblock. When romstage runs, the CPUs indicate their microcode is already loaded. Change-Id: Iaccaa9c226ee24868a5f4c0ba79729015d15bbef Signed-off-by: Aaron Durbin <adurbin@chromium.org> Signed-off-by: Stefan Reinauer <reinauer@google.com> Reviewed-on: http://review.coreboot.org/2712 Reviewed-by: Aaron Durbin <adurbin@google.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r--util/cbfstool/cbfstool.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index eeb6936510..1a3d25e44a 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -28,6 +28,7 @@
#include "common.h"
#include "cbfs.h"
#include "cbfs_image.h"
+#include "fit.h"
struct command {
const char *name;
@@ -53,6 +54,7 @@ static struct param {
uint32_t pagesize;
uint32_t offset;
uint32_t top_aligned;
+ int fit_empty_entries;
comp_algo algo;
} param = {
/* All variables not listed are initialized as zero. */
@@ -415,6 +417,36 @@ static int cbfs_extract(void)
return result;
}
+static int cbfs_update_fit(void)
+{
+ int ret = 0;
+ struct cbfs_image image;
+
+ if (!param.name) {
+ ERROR("You need to specify -n/--name.\n");
+ return 1;
+ }
+
+ if (param.fit_empty_entries <= 0) {
+ ERROR("Invalid number of fit entries "
+ "(-x/--empty-fits): %d\n", param.fit_empty_entries);
+ return 1;
+ }
+
+ if (cbfs_image_from_file(&image, param.cbfs_name) != 0) {
+ ERROR("Could not load ROM image '%s'.\n",
+ param.cbfs_name);
+ return 1;
+ }
+
+ ret = fit_update_table(&image, param.fit_empty_entries, param.name);
+ if (!ret)
+ ret = cbfs_image_write_file(&image, param.cbfs_name);
+
+ cbfs_image_delete(&image);
+ return ret;
+}
+
static const struct command commands[] = {
{"add", "f:n:t:b:vh?", cbfs_add},
{"add-payload", "f:n:t:c:b:vh?", cbfs_add_payload},
@@ -425,6 +457,7 @@ static const struct command commands[] = {
{"locate", "f:n:P:a:Tvh?", cbfs_locate},
{"print", "vh?", cbfs_print},
{"extract", "n:f:vh?", cbfs_extract},
+ {"update-fit", "n:x:vh?", cbfs_update_fit},
};
static struct option long_options[] = {
@@ -442,6 +475,7 @@ static struct option long_options[] = {
{"offset", required_argument, 0, 'o' },
{"file", required_argument, 0, 'f' },
{"arch", required_argument, 0, 'm' },
+ {"empty-fits", required_argument, 0, 'x' },
{"verbose", no_argument, 0, 'v' },
{"help", no_argument, 0, 'h' },
{NULL, 0, 0, 0 }
@@ -476,6 +510,8 @@ static void usage(char *name)
"Show the contents of the ROM\n"
" extract -n NAME -f FILE "
"Extracts a raw payload from ROM\n"
+ " update-fit -n MICROCODE_BLOB_NAME -x EMTPY_FIT_ENTRIES\n "
+ "Updates the FIT table with microcode entries\n"
"\n"
"ARCHes:\n"
" armv7, x86\n"
@@ -586,6 +622,9 @@ int main(int argc, char **argv)
case 'T':
param.top_aligned = 1;
break;
+ case 'x':
+ param.fit_empty_entries = strtol(optarg, NULL, 0);
+ break;
case 'v':
verbose++;
break;