blob: 1adc55c5fca9effb91eeb8f8541282abd8ba7839 [file] [log] [blame]
Karicheri, Muralidharanbf411ea2014-04-04 13:16:48 -04001/*
2 * (C) Copyright 2014
3 * Texas Instruments Incorporated
4 * Add gpimage format for keystone devices to format spl image. This is
5 * Based on omapimage.c
6 *
7 * (C) Copyright 2010
8 * Linaro LTD, www.linaro.org
9 * Author: John Rigby <john.rigby@linaro.org>
10 * Based on TI's signGP.c
11 *
12 * (C) Copyright 2009
13 * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
14 *
15 * (C) Copyright 2008
16 * Marvell Semiconductor <www.marvell.com>
17 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
18 *
19 * SPDX-License-Identifier: GPL-2.0+
20 */
21
22#include "imagetool.h"
23#include <compiler.h>
24#include <image.h>
25#include "gpheader.h"
26
27static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
28
29/* to be in keystone gpimage */
30static int gpimage_check_image_types(uint8_t type)
31{
32 if (type == IH_TYPE_GPIMAGE)
33 return EXIT_SUCCESS;
34 return EXIT_FAILURE;
35}
36
37static int gpimage_verify_header(unsigned char *ptr, int image_size,
38 struct image_tool_params *params)
39{
40 struct gp_header *gph = (struct gp_header *)ptr;
41
42 return gph_verify_header(gph, 1);
43}
44
45static void gpimage_print_header(const void *ptr)
46{
47 const struct gp_header *gph = (struct gp_header *)ptr;
48
49 gph_print_header(gph, 1);
50}
51
52static void gpimage_set_header(void *ptr, struct stat *sbuf, int ifd,
53 struct image_tool_params *params)
54{
55 struct gp_header *gph = (struct gp_header *)ptr;
56
57 gph_set_header(gph, sbuf->st_size - GPIMAGE_HDR_SIZE, params->addr, 1);
58}
59
60/*
61 * gpimage parameters
62 */
Guilherme Maciel Ferreiraa93648d2015-01-15 02:48:07 -020063U_BOOT_IMAGE_TYPE(
64 gpimage,
65 "TI KeyStone GP Image support",
66 GPIMAGE_HDR_SIZE,
67 (void *)&gpimage_header,
68 gpimage_check_params,
69 gpimage_verify_header,
70 gpimage_print_header,
71 gpimage_set_header,
72 NULL,
73 gpimage_check_image_types,
74 NULL,
75 NULL
76);