Commit 8ac544e4 authored by davidcunado-arm's avatar davidcunado-arm Committed by GitHub
Browse files

Merge pull request #1122 from EvanLloyd/ejll/62_fiptool1

fiptool: Precursor changes for Visual Studio
parents 9679297f 96851114
...@@ -9,18 +9,12 @@ ...@@ -9,18 +9,12 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <getopt.h>
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <openssl/sha.h>
#include <firmware_image_package.h>
#include "fiptool.h" #include "fiptool.h"
#include "tbbr_config.h" #include "tbbr_config.h"
...@@ -161,7 +155,7 @@ static void set_image_desc_action(image_desc_t *desc, int action, ...@@ -161,7 +155,7 @@ static void set_image_desc_action(image_desc_t *desc, int action,
{ {
assert(desc != NULL); assert(desc != NULL);
if (desc->action_arg != DO_UNSPEC) if (desc->action_arg != (char *)DO_UNSPEC)
free(desc->action_arg); free(desc->action_arg);
desc->action = action; desc->action = action;
desc->action_arg = NULL; desc->action_arg = NULL;
...@@ -278,7 +272,7 @@ static void uuid_from_str(uuid_t *u, const char *s) ...@@ -278,7 +272,7 @@ static void uuid_from_str(uuid_t *u, const char *s)
static int parse_fip(const char *filename, fip_toc_header_t *toc_header_out) static int parse_fip(const char *filename, fip_toc_header_t *toc_header_out)
{ {
struct stat st; struct BLD_PLAT_STAT st;
FILE *fp; FILE *fp;
char *buf, *bufend; char *buf, *bufend;
fip_toc_header_t *toc_header; fip_toc_header_t *toc_header;
...@@ -370,11 +364,12 @@ static int parse_fip(const char *filename, fip_toc_header_t *toc_header_out) ...@@ -370,11 +364,12 @@ static int parse_fip(const char *filename, fip_toc_header_t *toc_header_out)
static image_t *read_image_from_file(const uuid_t *uuid, const char *filename) static image_t *read_image_from_file(const uuid_t *uuid, const char *filename)
{ {
struct stat st; struct BLD_PLAT_STAT st;
image_t *image; image_t *image;
FILE *fp; FILE *fp;
assert(uuid != NULL); assert(uuid != NULL);
assert(filename != NULL);
fp = fopen(filename, "rb"); fp = fopen(filename, "rb");
if (fp == NULL) if (fp == NULL)
...@@ -469,6 +464,7 @@ static int info_cmd(int argc, char *argv[]) ...@@ -469,6 +464,7 @@ static int info_cmd(int argc, char *argv[])
(unsigned long long)image->toc_e.offset_address, (unsigned long long)image->toc_e.offset_address,
(unsigned long long)image->toc_e.size, (unsigned long long)image->toc_e.size,
desc->cmdline_name); desc->cmdline_name);
#ifndef _MSC_VER /* We don't have SHA256 for Visual Studio. */
if (verbose) { if (verbose) {
unsigned char md[SHA256_DIGEST_LENGTH]; unsigned char md[SHA256_DIGEST_LENGTH];
...@@ -476,6 +472,7 @@ static int info_cmd(int argc, char *argv[]) ...@@ -476,6 +472,7 @@ static int info_cmd(int argc, char *argv[])
printf(", sha256="); printf(", sha256=");
md_print(md, sizeof(md)); md_print(md, sizeof(md));
} }
#endif
putchar('\n'); putchar('\n');
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <firmware_image_package.h> #include <firmware_image_package.h>
#include <uuid.h> #include <uuid.h>
#include "fiptool_platform.h"
#define NELEM(x) (sizeof (x) / sizeof *(x)) #define NELEM(x) (sizeof (x) / sizeof *(x))
enum { enum {
......
/*
* Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Build platform specific handling.
* This allows for builds on non-Posix platforms
* e.g. Visual Studio on Windows
*/
#ifndef __FIPTOOL_PLATFORM_H__
# define __FIPTOOL_PLATFORM_H__
# ifndef _MSC_VER
/* Not Visual Studio, so include Posix Headers. */
# include <getopt.h>
# include <openssl/sha.h>
# include <unistd.h>
# define BLD_PLAT_STAT stat
# else
/* Visual Studio. */
# endif
#endif /* __FIPTOOL_PLATFORM_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment