xref: /rk3399_ARM-atf/tools/fiptool/fiptool.h (revision 819281ee23e1fd048e8385ecc708f78dff5e51d9)
1*819281eeSdp-arm /*
2*819281eeSdp-arm  * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3*819281eeSdp-arm  *
4*819281eeSdp-arm  * Redistribution and use in source and binary forms, with or without
5*819281eeSdp-arm  * modification, are permitted provided that the following conditions are met:
6*819281eeSdp-arm  *
7*819281eeSdp-arm  * Redistributions of source code must retain the above copyright notice, this
8*819281eeSdp-arm  * list of conditions and the following disclaimer.
9*819281eeSdp-arm  *
10*819281eeSdp-arm  * Redistributions in binary form must reproduce the above copyright notice,
11*819281eeSdp-arm  * this list of conditions and the following disclaimer in the documentation
12*819281eeSdp-arm  * and/or other materials provided with the distribution.
13*819281eeSdp-arm  *
14*819281eeSdp-arm  * Neither the name of ARM nor the names of its contributors may be used
15*819281eeSdp-arm  * to endorse or promote products derived from this software without specific
16*819281eeSdp-arm  * prior written permission.
17*819281eeSdp-arm  *
18*819281eeSdp-arm  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*819281eeSdp-arm  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*819281eeSdp-arm  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*819281eeSdp-arm  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*819281eeSdp-arm  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*819281eeSdp-arm  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*819281eeSdp-arm  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*819281eeSdp-arm  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*819281eeSdp-arm  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*819281eeSdp-arm  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*819281eeSdp-arm  * POSSIBILITY OF SUCH DAMAGE.
29*819281eeSdp-arm  */
30*819281eeSdp-arm 
31*819281eeSdp-arm #ifndef __FIPTOOL_H__
32*819281eeSdp-arm #define __FIPTOOL_H__
33*819281eeSdp-arm 
34*819281eeSdp-arm #include <stddef.h>
35*819281eeSdp-arm #include <stdint.h>
36*819281eeSdp-arm 
37*819281eeSdp-arm #include "uuid.h"
38*819281eeSdp-arm 
39*819281eeSdp-arm #define NELEM(x) (sizeof (x) / sizeof *(x))
40*819281eeSdp-arm 
41*819281eeSdp-arm /* TODO: Do not hardcode, use realloc() */
42*819281eeSdp-arm #define MAX_IMAGES 32
43*819281eeSdp-arm 
44*819281eeSdp-arm enum {
45*819281eeSdp-arm 	DO_PACK   = 1,
46*819281eeSdp-arm 	DO_UNPACK = 2,
47*819281eeSdp-arm 	DO_REMOVE = 3
48*819281eeSdp-arm };
49*819281eeSdp-arm 
50*819281eeSdp-arm enum {
51*819281eeSdp-arm 	LOG_DBG,
52*819281eeSdp-arm 	LOG_WARN,
53*819281eeSdp-arm 	LOG_ERR
54*819281eeSdp-arm };
55*819281eeSdp-arm 
56*819281eeSdp-arm typedef struct image {
57*819281eeSdp-arm 	uuid_t            uuid;
58*819281eeSdp-arm 	size_t            size;
59*819281eeSdp-arm 	void             *buffer;
60*819281eeSdp-arm 	struct toc_entry *toc_entry;
61*819281eeSdp-arm } image_t;
62*819281eeSdp-arm 
63*819281eeSdp-arm typedef struct cmd {
64*819281eeSdp-arm 	char             *name;
65*819281eeSdp-arm 	int             (*handler)(int, char **);
66*819281eeSdp-arm 	void            (*usage)(void);
67*819281eeSdp-arm } cmd_t;
68*819281eeSdp-arm 
69*819281eeSdp-arm #endif /* __FIPTOOL_H__ */
70