From 58a7e397a1168253216e68e753545dd8f18a690f Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 20 Aug 2018 16:39:47 +0200 Subject: [PATCH] util/ifdfake: Remove deprecated utility Since ifdfake has been deprecated in favor of better alternatives, there is no need to support it any further. Remove it from "util/", as well as any leftover references in other files. Change-Id: I45fe3d9fd606a61d5c3b9d0e6489a1df6d6510f0 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/28234 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Nico Huber Reviewed-by: Stefan Reinauer --- .gitignore | 1 - Documentation/util.md | 2 - MAINTAINERS | 1 - util/README.md | 2 - util/ifdfake/Makefile | 39 ------- util/ifdfake/description.md | 1 - util/ifdfake/ifdfake.c | 221 ------------------------------------ 7 files changed, 267 deletions(-) delete mode 100644 util/ifdfake/Makefile delete mode 100644 util/ifdfake/description.md delete mode 100644 util/ifdfake/ifdfake.c diff --git a/.gitignore b/.gitignore index 378741f0cd..7523a5fe87 100644 --- a/.gitignore +++ b/.gitignore @@ -99,7 +99,6 @@ util/futility/futility util/genprof/genprof util/getpir/getpir util/ifdtool/ifdtool -util/ifdfake/ifdfake util/intelmetool/intelmetool util/inteltool/.dependencies util/inteltool/inteltool diff --git a/Documentation/util.md b/Documentation/util.md index be7cc9906c..72355e3fe5 100644 --- a/Documentation/util.md +++ b/Documentation/util.md @@ -46,8 +46,6 @@ Controller (EC). `C` * __genprof__ - Format function tracing logs `Bash` `C` * __gitconfig__ - Initialize git repository submodules install git hooks `Bash` -* __ifdfake__ - Create an Intel Firmware Descriptor with just a section -layout `C` * __ifdtool__ - Extract and dump Intel Firmware Descriptor information `C` * __intelmetool__ - Dump interesting things about Management Engine diff --git a/MAINTAINERS b/MAINTAINERS index 0875fdd2d5..ca8a6f2a74 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -414,7 +414,6 @@ F: util/me_cleaner/ IFDTOOL M: Stefan Reinauer F: util/ifdtool/ -F: util/ifdfake/ BUILD SYSTEM M: Patrick Georgi diff --git a/util/README.md b/util/README.md index 96d59181c4..69ed11e593 100644 --- a/util/README.md +++ b/util/README.md @@ -44,8 +44,6 @@ Controller (EC). `C` * __genprof__ - Format function tracing logs `Bash` `C` * __gitconfig__ - Initialize git repository submodules install git hooks `Bash` -* __ifdfake__ - Create an Intel Firmware Descriptor with just a section -layout `C` * __ifdtool__ - Extract and dump Intel Firmware Descriptor information `C` * __intelmetool__ - Dump interesting things about Management Engine diff --git a/util/ifdfake/Makefile b/util/ifdfake/Makefile deleted file mode 100644 index 4080ef9863..0000000000 --- a/util/ifdfake/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# -# ifdfake - Create an Intel Firmware Descriptor with just a section layout -# -# Copyright (C) 2013 secunet Security Networks AG -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# - -PROGRAM = ifdfake - -CC ?= gcc -INSTALL ?= /usr/bin/install -PREFIX ?= /usr/local -CFLAGS ?= -O2 -g -Wall -W - -OBJS = ifdfake.o - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) - $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS) - -clean: - rm -f $(PROGRAM) *.o *~ - -distclean: clean - -install: $(PROGRAM) - mkdir -p $(DESTDIR)$(PREFIX)/bin - $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/bin - -.PHONY: all clean distclean diff --git a/util/ifdfake/description.md b/util/ifdfake/description.md deleted file mode 100644 index 5835bec6ce..0000000000 --- a/util/ifdfake/description.md +++ /dev/null @@ -1 +0,0 @@ -Create an Intel Firmware Descriptor with just a section layout `C` diff --git a/util/ifdfake/ifdfake.c b/util/ifdfake/ifdfake.c deleted file mode 100644 index b549f3ad8d..0000000000 --- a/util/ifdfake/ifdfake.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * ifdfake - Create an Intel Firmware Descriptor with just a section layout - * - * Copyright (C) 2013 secunet Security Networks AG - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include - -#define REGION_COUNT 5 - -#define FDBAR_OFFSET 0x10 -#define FRBA_OFFSET 0x40 - -typedef struct { - uint32_t base, limit, size; -} region_t; - -static void write_image(const region_t regions[], const char *const image) -{ - FILE *const f = fopen(image, "w"); - if (!f) { - perror("Could not open file"); - exit(EXIT_FAILURE); - } - - if (fseek(f, 0x1000 - 1, SEEK_SET)) { - perror("Failed to seek to end of descriptor"); - exit(EXIT_FAILURE); - } - char zero = '\0'; - if (fwrite(&zero, 1, 1, f) != 1) { - fprintf(stderr, "Failed to write at end of descriptor.\n"); - exit(EXIT_FAILURE); - } - - if (fseek(f, FDBAR_OFFSET, SEEK_SET)) { - perror("Failed to seek to fdbar"); - exit(EXIT_FAILURE); - } - - struct { - uint32_t flvalsig; - uint32_t flmap0; - } fdbar; - memset(&fdbar, 0x00, sizeof(fdbar)); - fdbar.flvalsig = 0x0ff0a55a; - fdbar.flmap0 = (REGION_COUNT - 1) << 24 | (FRBA_OFFSET >> 4) << 16; - if (fwrite(&fdbar, sizeof(fdbar), 1, f) != 1) { - fprintf(stderr, "Failed to write fdbar.\n"); - exit(EXIT_FAILURE); - } - - int i; - uint32_t frba[REGION_COUNT]; - for (i = 0; i < REGION_COUNT; ++i) { - if (regions[i].size) - frba[i] = ((regions[i].limit & 0xfff000) << (16 - 12)) | - ((regions[i].base & 0xfff000) >> 12); - else - frba[i] = 0x00000fff; - } - - if (fseek(f, FRBA_OFFSET, SEEK_SET)) { - perror("Failed to seek to frba"); - exit(EXIT_FAILURE); - } - if (fwrite(frba, sizeof(frba), 1, f) != 1) { - fprintf(stderr, "Failed to write frba.\n"); - exit(EXIT_FAILURE); - } - - fclose(f); -} - -static int parse_region(const char *_arg, region_t *const region) -{ - char *const start = strdup(_arg); - int size_spec = 0; - unsigned long first, second; - if (!start) { - fprintf(stderr, "Out of memory.\n"); - exit(EXIT_FAILURE); - } - - char *colon = strchr(start, ':'); - if (!colon) { - colon = strchr(start, '+'); - if (!colon) { - free(start); - return -1; - } - size_spec = 1; - } - *colon = '\0'; - - char *const end = colon + 1; - - errno = 0; - first = strtoul(start, NULL, 0); - second = strtoul(end, NULL, 0); - - if (size_spec) { - region->base = first; - region->size = second; - region->limit = region->base + region->size - 1; - } else { - region->base = first; - region->limit = second; - region->size = region->limit - region->base + 1; - } - - free(start); - if (errno) { - perror("Failed to parse region"); - return -1; - } else { - return 0; - } -} - -static void print_usage(const char *name) -{ - printf("usage: %s [(-b|-m|-g|-p) :]... \n", name); - printf("\n" - " -b | --bios : BIOS region\n" - " -m | --me : Intel ME region\n" - " -g | --gbe : Gigabit Ethernet region\n" - " -p | --platform : Platform Data region\n" - " -h | --help print this help\n\n" - " and bounds are given in bytes, the bound is inclusive.\n" - "All regions must be multiples of 4K in size and 4K aligned.\n" - "The descriptor region always resides in the first 4K.\n\n" - "An IFD created with ifdfake won't work as a replacement for a real IFD.\n" - "Never try to flash such an IFD to your board!\n\n"); -} - -int main(int argc, char *argv[]) -{ - int opt, option_index = 0, idx; - region_t regions[REGION_COUNT]; - - memset(regions, 0x00, sizeof(regions)); - - static struct option long_options[] = { - {"bios", 1, NULL, 'b'}, - {"me", 1, NULL, 'm'}, - {"gbe", 1, NULL, 'g'}, - {"platform", 1, NULL, 'p'}, - {"help", 0, NULL, 'h'}, - {0, 0, 0, 0} - }; - - while ((opt = getopt_long(argc, argv, "b:m:g:p:h?", - long_options, &option_index)) != EOF) { - switch (opt) { - case 'b': case 'm': case 'g': case 'p': - switch (opt) { - case 'b': idx = 1; break; - case 'm': idx = 2; break; - case 'g': idx = 3; break; - case 'p': idx = 4; break; - default: idx = 0; break; /* can't happen */ - } - if (parse_region(optarg, ®ions[idx])) { - print_usage(argv[0]); - exit(EXIT_FAILURE); - } - break; - case 'h': - case '?': - default: - print_usage(argv[0]); - exit(EXIT_SUCCESS); - break; - } - } - - if (optind + 1 != argc) { - fprintf(stderr, "No output file given.\n\n"); - print_usage(argv[0]); - exit(EXIT_FAILURE); - } - - regions[0].base = 0x00000000; - regions[0].limit = 0x00000fff; - regions[0].size = 0x00001000; - for (idx = 1; idx < REGION_COUNT; ++idx) { - if (regions[idx].size) { - if (regions[idx].base & 0xfff) - fprintf(stderr, "Region %d is " - "not 4K aligned.\n", idx); - else if (regions[idx].size & 0xfff) - fprintf(stderr, "Region %d size is " - "no multiple of 4K.\n", idx); - else if (regions[idx].limit <= regions[idx].base) - fprintf(stderr, "Region %d is empty.\n", idx); - else - continue; - print_usage(argv[0]); - exit(EXIT_FAILURE); - } - } - - write_image(regions, argv[optind]); - - return 0; -}