summaryrefslogtreecommitdiff
path: root/util/amdfwtool
diff options
context:
space:
mode:
authorZheng Bao <fishbaozi@gmail.com>2020-10-01 17:05:43 +0800
committerPatrick Georgi <pgeorgi@google.com>2020-11-04 09:42:04 +0000
commit77a2c67dfe94e1dac09c5878d9963d30fae2a90f (patch)
treee4391bbc8bc0c6717f2e717aa58ce87ca97d0e97 /util/amdfwtool
parent9e90807b40529e1e8b236fe73505c3c43f5ca5b5 (diff)
downloadcoreboot-77a2c67dfe94e1dac09c5878d9963d30fae2a90f.tar.xz
amdfwtool: Change all error output to fprintf stderr
Change-Id: Ie4ce0f1fb3aea8f12dfae9e5d16589262e7d6ab0 Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45895 Reviewed-by: Felix Held <felix-coreboot@felixheld.de> Reviewed-by: Martin Roth <martinroth@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/amdfwtool')
-rw-r--r--util/amdfwtool/amdfwtool.c54
-rw-r--r--util/amdfwtool/data_parse.c4
2 files changed, 29 insertions, 29 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 0c4153e10d..9cf6a4f8c0 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -529,19 +529,19 @@ static ssize_t copy_blob(void *dest, const char *src_file, size_t room)
fd = open(src_file, O_RDONLY);
if (fd < 0) {
- printf("Error opening file: %s: %s\n",
+ fprintf(stderr, "Error opening file: %s: %s\n",
src_file, strerror(errno));
return -1;
}
if (fstat(fd, &fd_stat)) {
- printf("fstat error: %s\n", strerror(errno));
+ fprintf(stderr, "fstat error: %s\n", strerror(errno));
close(fd);
return -2;
}
if ((size_t)fd_stat.st_size > room) {
- printf("Error: %s will not fit. Exiting.\n", src_file);
+ fprintf(stderr, "Error: %s will not fit. Exiting.\n", src_file);
close(fd);
return -3;
}
@@ -549,7 +549,7 @@ static ssize_t copy_blob(void *dest, const char *src_file, size_t room)
bytes = read(fd, dest, (size_t)fd_stat.st_size);
close(fd);
if (bytes != (ssize_t)fd_stat.st_size) {
- printf("Error while reading %s\n", src_file);
+ fprintf(stderr, "Error while reading %s\n", src_file);
return -4;
}
@@ -755,7 +755,7 @@ static void integrate_psp_firmwares(context *ctx,
}
if (count > MAX_PSP_ENTRIES) {
- printf("Error: PSP entries exceed max allowed items\n");
+ fprintf(stderr, "Error: PSP entries exceed max allowed items\n");
free(ctx->rom);
exit(1);
}
@@ -871,7 +871,7 @@ static void integrate_bios_firmwares(context *ctx,
if (!fw_table[i].size && !fw_table[i].src)
continue; /* APOB_NV not used */
if (fw_table[i].src && !fw_table[i].size) {
- printf("Error: APOB NV address provided, but no size\n");
+ fprintf(stderr, "Error: APOB NV address provided, but no size\n");
free(ctx->rom);
exit(1);
}
@@ -883,7 +883,7 @@ static void integrate_bios_firmwares(context *ctx,
/* APOB_DATA needs destination */
if (fw_table[i].type == AMD_BIOS_APOB && !fw_table[i].dest) {
- printf("Error: APOB destination not provided\n");
+ fprintf(stderr, "Error: APOB destination not provided\n");
free(ctx->rom);
exit(1);
}
@@ -893,12 +893,12 @@ static void integrate_bios_firmwares(context *ctx,
*/
if (fw_table[i].type == AMD_BIOS_BIN) {
if (!fw_table[i].dest || !fw_table[i].size) {
- printf("Error: BIOS binary destination and uncompressed size are required\n");
+ fprintf(stderr, "Error: BIOS binary destination and uncompressed size are required\n");
free(ctx->rom);
exit(1);
}
if (!fw_table[i].filename && !fw_table[i].src) {
- printf("Error: BIOS binary assumed outside amdfw.rom but no source address given\n");
+ fprintf(stderr, "Error: BIOS binary assumed outside amdfw.rom but no source address given\n");
free(ctx->rom);
exit(1);
}
@@ -1015,7 +1015,7 @@ static void integrate_bios_firmwares(context *ctx,
}
if (count > MAX_BIOS_ENTRIES) {
- printf("Error: BIOS entries (%d) exceeds max allowed items "
+ fprintf(stderr, "Error: BIOS entries (%d) exceeds max allowed items "
"(%d)\n", count, MAX_BIOS_ENTRIES);
free(ctx->rom);
exit(1);
@@ -1177,7 +1177,7 @@ static int set_efs_table(uint8_t soc_id, embedded_firmware *amd_romsig,
uint8_t efs_spi_micron_flag)
{
if ((efs_spi_readmode == 0xFF) || (efs_spi_speed == 0xFF)) {
- printf("Error: EFS read mode and SPI speed must be set\n");
+ fprintf(stderr, "Error: EFS read mode and SPI speed must be set\n");
return 1;
}
switch (soc_id) {
@@ -1199,7 +1199,7 @@ static int set_efs_table(uint8_t soc_id, embedded_firmware *amd_romsig,
amd_romsig->qpr_dummy_cycle_f17_mod_00_2f = 0xa;
break;
default:
- printf("Error: EFS Micron flag must be correctly set.\n\n");
+ fprintf(stderr, "Error: EFS Micron flag must be correctly set.\n\n");
return 1;
}
break;
@@ -1219,13 +1219,13 @@ static int set_efs_table(uint8_t soc_id, embedded_firmware *amd_romsig,
amd_romsig->micron_detect_f17_mod_30_3f = 0x55;
break;
default:
- printf("Error: EFS Micron flag must be correctly set.\n\n");
+ fprintf(stderr, "Error: EFS Micron flag must be correctly set.\n\n");
return 1;
}
break;
case PLATFORM_UNKNOWN:
default:
- printf("Error: Invalid SOC name.\n\n");
+ fprintf(stderr, "Error: Invalid SOC name.\n\n");
return 1;
}
return 0;
@@ -1398,7 +1398,7 @@ int main(int argc, char **argv)
case 'C':
soc_id = identify_platform(optarg);
if (soc_id == PLATFORM_UNKNOWN) {
- printf("Error: Invalid SOC name specified\n\n");
+ fprintf(stderr, "Error: Invalid SOC name specified\n\n");
retval = 1;
}
sub = instance = 0;
@@ -1421,7 +1421,7 @@ int main(int argc, char **argv)
case 'f':
ctx.rom_size = (uint32_t)strtoul(optarg, &tmp, 16);
if (*tmp != '\0') {
- printf("Error: ROM size specified"
+ fprintf(stderr, "Error: ROM size specified"
" incorrectly (%s)\n\n", optarg);
retval = 1;
}
@@ -1429,7 +1429,7 @@ int main(int argc, char **argv)
case 'l':
dir_location = (uint32_t)strtoul(optarg, &tmp, 16);
if (*tmp != '\0') {
- printf("Error: Directory Location specified"
+ fprintf(stderr, "Error: Directory Location specified"
" incorrectly (%s)\n\n", optarg);
retval = 1;
}
@@ -1518,14 +1518,14 @@ int main(int argc, char **argv)
rom_base_address = 0xFFFFFFFF - ctx.rom_size + 1;
if (dir_location && (dir_location < rom_base_address)) {
- printf("Error: Directory location outside of ROM.\n\n");
+ fprintf(stderr, "Error: Directory location outside of ROM.\n\n");
return 1;
}
if (any_location) {
if (dir_location & 0x3f) {
- printf("Error: Invalid Directory location.\n");
- printf(" Valid locations are 64-byte aligned\n");
+ fprintf(stderr, "Error: Invalid Directory location.\n");
+ fprintf(stderr, " Valid locations are 64-byte aligned\n");
return 1;
}
} else {
@@ -1539,16 +1539,16 @@ int main(int argc, char **argv)
case 0xFF020000: /* Fall through */
break;
default:
- printf("Error: Invalid Directory location.\n");
- printf(" Valid locations are 0xFFFA0000, 0xFFF20000,\n");
- printf(" 0xFFE20000, 0xFFC20000, 0xFF820000, 0xFF020000\n");
+ fprintf(stderr, "Error: Invalid Directory location.\n");
+ fprintf(stderr, " Valid locations are 0xFFFA0000, 0xFFF20000,\n");
+ fprintf(stderr, " 0xFFE20000, 0xFFC20000, 0xFF820000, 0xFF020000\n");
return 1;
}
}
ctx.rom = malloc(ctx.rom_size);
if (!ctx.rom) {
- printf("Error: Failed to allocate memory\n");
+ fprintf(stderr, "Error: Failed to allocate memory\n");
return 1;
}
memset(ctx.rom, 0xFF, ctx.rom_size);
@@ -1570,11 +1570,11 @@ int main(int argc, char **argv)
retval = set_efs_table(soc_id, amd_romsig, efs_spi_readmode,
efs_spi_speed, efs_spi_micron_flag);
if (retval) {
- printf("ERROR: Failed to initialize EFS table!\n");
+ fprintf(stderr, "ERROR: Failed to initialize EFS table!\n");
return retval;
}
} else {
- printf("WARNING: No SOC name specified.\n");
+ fprintf(stderr, "WARNING: No SOC name specified.\n");
}
integrate_firmwares(&ctx, amd_romsig, amd_fw_table);
@@ -1650,7 +1650,7 @@ int main(int argc, char **argv)
}
close(targetfd);
} else {
- printf("Error: could not open file: %s\n", output);
+ fprintf(stderr, "Error: could not open file: %s\n", output);
retval = 1;
}
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c
index bb616d3405..2af6c31991 100644
--- a/util/amdfwtool/data_parse.c
+++ b/util/amdfwtool/data_parse.c
@@ -38,7 +38,7 @@ void compile_reg_expr(int cflags, const char *expr, regex_t *reg)
result = regcomp(reg, expr, cflags);
if (result != 0) {
regerror(result, reg, error_msg, ERROR_BUF_SIZE);
- printf("%s\n", error_msg);
+ fprintf(stderr, "%s\n", error_msg);
}
}
@@ -304,7 +304,7 @@ int get_input_file_line(FILE *f, char line[], int line_buf_size)
line[strlen(line) - 1] = '\0';
if (strlen(line) == ((size_t) (line_buf_size - 1))) {
- printf("The line size in config file should be lower than %d bytes.\n",
+ fprintf(stderr, "The line size in config file should be lower than %d bytes.\n",
MAX_LINE_SIZE);
exit(1);
}