diff options
Diffstat (limited to 'util/ich_descriptors_tool')
-rw-r--r-- | util/ich_descriptors_tool/Makefile | 23 | ||||
-rw-r--r-- | util/ich_descriptors_tool/ich_descriptors_tool.c | 27 | ||||
-rw-r--r-- | util/ich_descriptors_tool/meson.build | 5 |
3 files changed, 38 insertions, 17 deletions
diff --git a/util/ich_descriptors_tool/Makefile b/util/ich_descriptors_tool/Makefile index c32e30be5..aa1b696c3 100644 --- a/util/ich_descriptors_tool/Makefile +++ b/util/ich_descriptors_tool/Makefile @@ -4,6 +4,8 @@ # This Makefile works standalone, but it is usually called from the main # Makefile in the flashrom directory. +include ../../Makefile.include + PROGRAM=ich_descriptors_tool EXTRAINCDIRS = ../../ . DEPPATH = .dep @@ -16,31 +18,33 @@ WARNERROR ?= yes SRC = $(wildcard *.c) -CC ?= gcc - # If the user has specified custom CFLAGS, all CFLAGS settings below will be # completely ignored by gnumake. CFLAGS ?= -Os -Wall -Wshadow +override CFLAGS += -I$(SHAREDSRCDIR)/include +# Auto determine HOST_OS and TARGET_OS if they are not set as argument HOST_OS ?= $(shell uname) +TARGET_OS := $(call c_macro_test, ../../Makefile.d/os_test.h) + ifeq ($(findstring MINGW, $(HOST_OS)), MINGW) # Explicitly set CC = gcc on MinGW, otherwise: "cc: command not found". CC = gcc -EXEC_SUFFIX := .exe -# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that -# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ */ -FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 endif -override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \ - cut -f 2 -d'"') - ifeq ($(TARGET_OS), DOS) EXEC_SUFFIX := .exe # DJGPP has odd uint*_t definitions which cause lots of format string warnings. CFLAGS += -Wno-format endif +ifeq ($(TARGET_OS), MinGW) +EXEC_SUFFIX := .exe +# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that +# for MinGW. See http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/ +CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 +endif + ifeq ($(WARNERROR), yes) CFLAGS += -Werror endif @@ -68,6 +72,7 @@ $(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c $(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ) $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ) +# We don't use EXEC_SUFFIX here because we want to clean everything. clean: rm -f $(PROGRAM) $(PROGRAM).exe rm -rf $(DEPPATH) $(OBJATH) diff --git a/util/ich_descriptors_tool/ich_descriptors_tool.c b/util/ich_descriptors_tool/ich_descriptors_tool.c index 32eea12c9..a5a59ad29 100644 --- a/util/ich_descriptors_tool/ich_descriptors_tool.c +++ b/util/ich_descriptors_tool/ich_descriptors_tool.c @@ -46,7 +46,6 @@ static const char *const region_names[] = { static void dump_file(const char *prefix, const uint32_t *dump, unsigned int len, const struct ich_desc_region *const reg, unsigned int i) { - int ret; char *fn; const char *reg_name; uint32_t file_len; @@ -85,8 +84,8 @@ static void dump_file(const char *prefix, const uint32_t *dump, unsigned int len } free(fn); - ret = write(fh, &dump[base >> 2], file_len); - if (ret != file_len) { + const ssize_t ret = write(fh, &dump[base >> 2], file_len); + if (ret < 0 || ((size_t) ret) != file_len) { fprintf(stderr, "FAILED.\n"); exit(1); } @@ -127,6 +126,9 @@ static void usage(char *argv[], const char *error) "\t- \"ich10\",\n" "\t- \"silvermont\" for chipsets from Intel's Silvermont architecture (e.g. Bay Trail),\n" "\t- \"apollo\" for Intel's Apollo Lake SoC.\n" +"\t- \"gemini\" for Intel's Gemini Lake SoC.\n" +"\t- \"jasper\" for Intel's Jasper Lake SoC.\n" +"\t- \"meteor\" for Intel's Meteor Lake SoC.\n" "\t- \"5\" or \"ibex\" for Intel's 5 series chipsets,\n" "\t- \"6\" or \"cougar\" for Intel's 6 series chipsets,\n" "\t- \"7\" or \"panther\" for Intel's 7 series chipsets.\n" @@ -134,6 +136,9 @@ static void usage(char *argv[], const char *error) "\t- \"9\" or \"wildcat\" for Intel's 9 series chipsets.\n" "\t- \"100\" or \"sunrise\" for Intel's 100 series chipsets.\n" "\t- \"300\" or \"cannon\" for Intel's 300 series chipsets.\n" +"\t- \"400\" or \"comet\" for Intel's 400 series chipsets.\n" +"\t- \"500\" or \"tiger\" for Intel's 500 series chipsets.\n" +"\t- \"600\" or \"alder\" for Intel's 600 series chipsets.\n" "If '-d' is specified some regions such as the BIOS image as seen by the CPU or\n" "the GbE blob that is required to initialize the GbE are also dumped to files.\n", argv[0], argv[0]); @@ -228,8 +233,21 @@ int main(int argc, char *argv[]) else if ((strcmp(csn, "400") == 0) || (strcmp(csn, "comet") == 0)) cs = CHIPSET_400_SERIES_COMET_POINT; + else if ((strcmp(csn, "500") == 0) || + (strcmp(csn, "tiger") == 0)) + cs = CHIPSET_500_SERIES_TIGER_POINT; + else if (strcmp(csn, "600") == 0) + cs = CHIPSET_600_SERIES_ALDER_POINT; else if (strcmp(csn, "apollo") == 0) cs = CHIPSET_APOLLO_LAKE; + else if (strcmp(csn, "gemini") == 0) + cs = CHIPSET_GEMINI_LAKE; + else if (strcmp(csn, "jasper") == 0) + cs = CHIPSET_JASPER_LAKE; + else if (strcmp(csn, "elkhart") == 0) + cs = CHIPSET_ELKHART_LAKE; + else if (strcmp(csn, "meteor") == 0) + cs = CHIPSET_METEOR_LAKE; } ret = read_ich_descriptors_from_dump(buf, len, &cs, &desc); @@ -251,7 +269,8 @@ int main(int argc, char *argv[]) prettyprint_ich_descriptors(cs, &desc); pMAC = (uint8_t *) &buf[ICH_FREG_BASE(desc.region.FLREGs[3]) >> 2]; - if (len >= ICH_FREG_BASE(desc.region.FLREGs[3]) + 6 && pMAC[0] != 0xff) + /* The case len < 0 is handled above as error. At this point len is non-negative. */ + if (((size_t) len) >= ICH_FREG_BASE(desc.region.FLREGs[3]) + 6 && pMAC[0] != 0xff) printf("The MAC address might be at offset 0x%x: " "%02x:%02x:%02x:%02x:%02x:%02x\n", ICH_FREG_BASE(desc.region.FLREGs[3]), diff --git a/util/ich_descriptors_tool/meson.build b/util/ich_descriptors_tool/meson.build index b5bf09ec9..80f4a521b 100644 --- a/util/ich_descriptors_tool/meson.build +++ b/util/ich_descriptors_tool/meson.build @@ -4,10 +4,7 @@ executable( 'ich_descriptors_tool.c', '../../ich_descriptors.c', ], - dependencies : [ - deps, - ], - include_directories : include_directories('../..'), + include_directories : include_dir, c_args : [ '-DICH_DESCRIPTORS_FROM_DUMP_ONLY', ], |