From 9ab80a33a53ec294d89d9d37deb5d48ada2e1935 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Mon, 18 Feb 2019 14:35:54 +0100 Subject: cbfstool: Drop update-fit option The ifittool is used instead. Drop old code. Change-Id: I70fec5fef9ffd1ba3049badb398783f31aefb02f Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/31496 Tested-by: build bot (Jenkins) Reviewed-by: Philipp Deppenwiese --- util/cbfstool/Makefile.inc | 1 - util/cbfstool/cbfstool.c | 69 --------------------------------- util/cbfstool/fit.c | 96 ---------------------------------------------- util/cbfstool/fit.h | 7 ---- 4 files changed, 173 deletions(-) (limited to 'util/cbfstool') diff --git a/util/cbfstool/Makefile.inc b/util/cbfstool/Makefile.inc index 0340c3eecb..efc3dca6f5 100644 --- a/util/cbfstool/Makefile.inc +++ b/util/cbfstool/Makefile.inc @@ -21,7 +21,6 @@ cbfsobj += cbfs-mkpayload.o cbfsobj += elfheaders.o cbfsobj += rmodule.o cbfsobj += xdr.o -cbfsobj += fit.o cbfsobj += partitioned_file.o # COMMONLIB cbfsobj += cbfs.o diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index e8b1f6f9ee..cf89b473fa 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -28,7 +28,6 @@ #include "cbfs_image.h" #include "cbfs_sections.h" #include "elfparsing.h" -#include "fit.h" #include "partitioned_file.h" #include #include @@ -84,7 +83,6 @@ static struct param { bool autogen_attr; bool machine_parseable; bool unprocessed; - int fit_empty_entries; enum comp_algo compression; int precompression; enum vb2_hash_algorithm hash; @@ -1190,54 +1188,6 @@ static int cbfs_read(void) return buffer_write_file(param.image_region, param.filename); } -static int cbfs_update_fit(void) -{ - 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; - } - - struct buffer bootblock; - // The bootblock is part of the CBFS on x86 - buffer_clone(&bootblock, param.image_region); - - struct cbfs_image image; - if (cbfs_image_from_buffer(&image, param.image_region, - param.headeroffset)) - return 1; - - uint32_t addr = 0; - - /* - * Get the address of provided region for first row. - */ - if (param.ucode_region) { - struct buffer ucode; - - if (partitioned_file_read_region(&ucode, - param.image_file, param.ucode_region)) - addr = -convert_to_from_top_aligned(&ucode, 0); - else - return 1; - } - - - if (fit_update_table(&bootblock, &image, param.name, - param.fit_empty_entries, convert_to_from_top_aligned, - param.topswap_size, addr)) - return 1; - - // The region to be written depends on the type of image, so we write it - // here rather than having main() write the CBFS region back as usual. - return !partitioned_file_write_region(param.image_file, &bootblock); -} - static int cbfs_copy(void) { struct cbfs_image src_image; @@ -1320,7 +1270,6 @@ static const struct command commands[] = { {"print", "H:r:vkh?", cbfs_print, true, false}, {"read", "r:f:vh?", cbfs_read, true, false}, {"remove", "H:r:n:vh?", cbfs_remove, true, true}, - {"update-fit", "H:r:n:x:vh?j:q:", cbfs_update_fit, true, true}, {"write", "r:f:i:Fudvh?", cbfs_write, true, true}, {"expand", "r:h?", cbfs_expand, true, true}, {"truncate", "r:h?", cbfs_truncate, true, true}, @@ -1486,15 +1435,6 @@ static void usage(char *name) "Truncate CBFS and print new size on stdout\n" " expand [-r fmap-region] " "Expand CBFS to span entire region\n" - " update-fit [-r image,regions] -n MICROCODE_BLOB_NAME \\\n" - " -x EMTPY_FIT_ENTRIES \\ \n" - " [-j topswap-size [-q ucode-region](Intel CPUs only)] " - "Updates the FIT table with microcode entries.\n" - " " - " ucode-region is a region in the FMAP, its address is \n" - " " - " inserted as the first entry in the topswap FIT. \n" - "\n" "OFFSETs:\n" " Numbers accompanying -b, -H, and -o switches* may be provided\n" " in two possible formats: if their value is greater than\n" @@ -1732,15 +1672,6 @@ int main(int argc, char **argv) case 'w': param.show_immutable = true; break; - case 'x': - param.fit_empty_entries = strtol( - optarg, &suffix, 0); - if (!*optarg || (suffix && *suffix)) { - ERROR("Invalid number of fit entries " - "'%s'.\n", optarg); - return 1; - } - break; case 'j': param.topswap_size = strtol(optarg, NULL, 0); if (!is_valid_topswap()) diff --git a/util/cbfstool/fit.c b/util/cbfstool/fit.c index 86dde4d23d..4cd84f232d 100644 --- a/util/cbfstool/fit.c +++ b/util/cbfstool/fit.c @@ -737,99 +737,3 @@ int fit_delete_entry(struct fit_table *fit, return 0; } - -/* Legacy code. TODO: Remove once ifittool is merged. */ - -static void add_microcodde_entries(struct fit_table *fit, - const struct cbfs_image *image, - ssize_t num_mcus, - struct microcode_entry *mcus, - fit_offset_converter_t offset_helper, - uint32_t first_mcu_addr) -{ - int i = 0; - /* - * Check if an entry has to be forced into the FIT at index 0. - * first_mcu_addr is an address (in ROM) that will point to a - * microcode patch. - */ - if (first_mcu_addr) { - struct fit_entry *entry = &fit->entries[0]; - update_fit_ucode_entry(fit, entry, first_mcu_addr); - i = 1; - } - - struct microcode_entry *mcu = &mcus[0]; - for (; i < num_mcus; i++) { - struct fit_entry *entry = &fit->entries[i]; - update_fit_ucode_entry(fit, entry, offset_to_ptr(offset_helper, - &image->buffer, mcu->offset)); - mcu++; - } -} - -int fit_update_table(struct buffer *bootblock, struct cbfs_image *image, - const char *microcode_blob_name, - unsigned int empty_entries, - fit_offset_converter_t offset_fn, uint32_t topswap_size, - uint32_t first_mcu_addr) -{ - struct fit_table *fit, *fit2; - struct microcode_entry *mcus; - size_t mcus_found; - - int ret = 0; - - fit = fit_get_table(bootblock, offset_fn, 0); - if (!fit) { - ERROR("FIT not found.\n"); - return 1; - } - - mcus = malloc(sizeof(*mcus) * empty_entries); - if (!mcus) { - ERROR("Couldn't allocate memory for microcode entries.\n"); - return 1; - } - - if (parse_microcode_blob(image, microcode_blob_name, &mcus_found, - mcus, empty_entries)) { - ERROR("Couldn't parse microcode blob.\n"); - ret = 1; - goto out; - } - - add_microcodde_entries(fit, image, mcus_found, mcus, offset_fn, 0); - - update_fit_checksum(fit); - - /* A second fit is exactly topswap size away from the bottom one */ - if (topswap_size) { - - fit2 = fit_get_table(bootblock, offset_fn, topswap_size); - - if (!fit_table_verified(fit2)) { - ERROR("second FIT is invalid\n"); - ret = 1; - goto out; - } - /* Check if we have room for first entry */ - if (first_mcu_addr) { - if (mcus_found >= empty_entries) { - ERROR("No room, blob mcus = %zd, total entries" - " = %d\n", mcus_found, empty_entries); - ret = 1; - goto out; - } - /* Add 1 for the first entry */ - mcus_found++; - } - /* Add entries in the second FIT */ - add_microcodde_entries(fit2, image, mcus_found, mcus, - offset_fn, first_mcu_addr); - update_fit_checksum(fit2); - } -out: - free(mcus); - return ret; -} diff --git a/util/cbfstool/fit.h b/util/cbfstool/fit.h index e5872ab599..c647ec506e 100644 --- a/util/cbfstool/fit.h +++ b/util/cbfstool/fit.h @@ -72,11 +72,4 @@ int fit_add_microcode_file(struct fit_table *fit, fit_offset_converter_t offset_helper, const size_t max_fit_entries); -/* Legacy code */ -int fit_update_table(struct buffer *bootblock, struct cbfs_image *image, - const char *microcode_blob_name, - unsigned int empty_entries, - fit_offset_converter_t offset_fn, uint32_t topswap_size, - uint32_t first_mcu_addr); - #endif -- cgit v1.2.3