diff options
author | Zheng Bao <fishbaozi@gmail.com> | 2023-10-10 11:15:07 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-03-04 14:50:53 +0000 |
commit | 92a9d9314421369bdff572b4d34fd1258585ffe3 (patch) | |
tree | 8b1d8c3e97cee5fdf4fb29ee8b653e06129435b4 /util/amdfwtool/amdfwtool.c | |
parent | 80b853e626919c7add6cd767ee5a5ce2af599616 (diff) |
amdfwtool: Move the functions to handle_file.c
Change-Id: I4cfec13cbc2a86dc352758541cce915a838e0d0f
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78305
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/amdfwtool/amdfwtool.c')
-rw-r--r-- | util/amdfwtool/amdfwtool.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index b071e6c6fe..e37c6355b2 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -95,10 +95,6 @@ #define DEFAULT_SOFT_FUSE_CHAIN "0x1" -#define EFS_FILE_SUFFIX ".efs" -#define TMP_FILE_SUFFIX ".tmp" -#define BODY_FILE_SUFFIX ".body" - static void output_manifest(int manifest_fd, amd_fw_entry *fw_entry); /* @@ -745,41 +741,6 @@ static void fill_bios_directory_to_efs(embedded_firmware *amd_romsig, void *bios } } -static ssize_t copy_blob(void *dest, const char *src_file, size_t room) -{ - int fd; - struct stat fd_stat; - ssize_t bytes; - - fd = open(src_file, O_RDONLY); - if (fd < 0) { - fprintf(stderr, "Error opening file: %s: %s\n", - src_file, strerror(errno)); - return -1; - } - - if (fstat(fd, &fd_stat)) { - fprintf(stderr, "fstat error: %s\n", strerror(errno)); - close(fd); - return -2; - } - - if ((size_t)fd_stat.st_size > room) { - fprintf(stderr, "Error: %s will not fit. Exiting.\n", src_file); - close(fd); - return -3; - } - - bytes = read(fd, dest, (size_t)fd_stat.st_size); - close(fd); - if (bytes != (ssize_t)fd_stat.st_size) { - fprintf(stderr, "Error while reading %s\n", src_file); - return -4; - } - - return bytes; -} - static uint32_t get_psp_id(enum platform soc_id) { uint32_t psp_id; @@ -1814,54 +1775,6 @@ static int set_efs_table(uint8_t soc_id, amd_cb_config *cb_config, return 0; } -static ssize_t write_body(char *output, void *body_offset, ssize_t body_size) -{ - char body_name[PATH_MAX], body_tmp_name[PATH_MAX]; - int ret; - int fd; - ssize_t bytes = -1; - - /* Create a tmp file and rename it at the end so that make does not get confused - if amdfwtool is killed for some unexpected reasons. */ - ret = snprintf(body_tmp_name, sizeof(body_tmp_name), "%s%s%s", - output, BODY_FILE_SUFFIX, TMP_FILE_SUFFIX); - if (ret < 0) { - fprintf(stderr, "Error %s forming BODY tmp file name: %d\n", - strerror(errno), ret); - return -1; - } else if ((unsigned int)ret >= sizeof(body_tmp_name)) { - fprintf(stderr, "BODY File name %d > %zu\n", ret, sizeof(body_tmp_name)); - return -1; - } - - fd = open(body_tmp_name, O_RDWR | O_CREAT | O_TRUNC, 0666); - if (fd < 0) { - fprintf(stderr, "Error: Opening %s file: %s\n", body_tmp_name, strerror(errno)); - return -1; - } - - bytes = write_from_buf_to_file(fd, body_offset, body_size); - if (bytes != body_size) { - fprintf(stderr, "Error: Writing to file %s failed\n", body_tmp_name); - return -1; - } - close(fd); - - /* Rename the tmp file */ - ret = snprintf(body_name, sizeof(body_name), "%s%s", output, BODY_FILE_SUFFIX); - if (ret < 0) { - fprintf(stderr, "Error %s forming BODY file name: %d\n", strerror(errno), ret); - return -1; - } - - if (rename(body_tmp_name, body_name)) { - fprintf(stderr, "Error: renaming file %s to %s\n", body_tmp_name, body_name); - return -1; - } - - return bytes; -} - void open_process_config(char *config, amd_cb_config *cb_config, int debug) { FILE *config_handle; |