blob: ee67ca96f4c272ada71dca21e19a9808bf1db146 [file] [log] [blame]
Peng Fan1a7e6252019-08-22 07:42:33 +00001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2018-2019 NXP
4 */
5
6#ifndef __CONTAINER_HEADER_H_
7#define __CONTAINER_HEADER_H_
8
9#include <linux/sizes.h>
10#include <linux/types.h>
11
12#define IV_MAX_LEN 32
13#define HASH_MAX_LEN 64
14
15#define CONTAINER_HDR_ALIGNMENT 0x400
16#define CONTAINER_HDR_EMMC_OFFSET 0
17#define CONTAINER_HDR_MMCSD_OFFSET SZ_32K
18#define CONTAINER_HDR_QSPI_OFFSET SZ_4K
19#define CONTAINER_HDR_NAND_OFFSET SZ_128M
20
21struct container_hdr {
22 u8 version;
23 u8 length_lsb;
24 u8 length_msb;
25 u8 tag;
26 u32 flags;
27 u16 sw_version;
28 u8 fuse_version;
29 u8 num_images;
30 u16 sig_blk_offset;
31 u16 reserved;
32} __packed;
33
34struct boot_img_t {
35 u32 offset;
36 u32 size;
37 u64 dst;
38 u64 entry;
39 u32 hab_flags;
40 u32 meta;
41 u8 hash[HASH_MAX_LEN];
42 u8 iv[IV_MAX_LEN];
43} __packed;
44
45struct signature_block_hdr {
46 u8 version;
47 u8 length_lsb;
48 u8 length_msb;
49 u8 tag;
50 u16 srk_table_offset;
51 u16 cert_offset;
52 u16 blob_offset;
53 u16 signature_offset;
54 u32 reserved;
55} __packed;
Clement Faure9cb2f972021-03-25 17:30:34 +080056
57struct generate_key_blob_hdr {
58 u8 version;
59 u8 length_lsb;
60 u8 length_msb;
61 u8 tag;
62 u8 flags;
63 u8 size;
64 u8 algorithm;
65 u8 mode;
66} __packed;
Ye Li7a71c612021-08-07 16:00:39 +080067
68int get_container_size(ulong addr, u16 *header_length);
Peng Fan1a7e6252019-08-22 07:42:33 +000069#endif