blob: 691c764b3e5bd9f9fc4c44bca8ede845c648d7d3 [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
Sean Andersonc5126682023-10-14 16:47:43 -040021#define CONTAINER_HDR_TAG 0x87
22#define CONTAINER_HDR_VERSION 0
23
Peng Fan1a7e6252019-08-22 07:42:33 +000024struct container_hdr {
25 u8 version;
26 u8 length_lsb;
27 u8 length_msb;
28 u8 tag;
29 u32 flags;
30 u16 sw_version;
31 u8 fuse_version;
32 u8 num_images;
33 u16 sig_blk_offset;
34 u16 reserved;
35} __packed;
36
37struct boot_img_t {
38 u32 offset;
39 u32 size;
40 u64 dst;
41 u64 entry;
42 u32 hab_flags;
43 u32 meta;
44 u8 hash[HASH_MAX_LEN];
45 u8 iv[IV_MAX_LEN];
46} __packed;
47
48struct signature_block_hdr {
49 u8 version;
50 u8 length_lsb;
51 u8 length_msb;
52 u8 tag;
Peng Fan1a7e6252019-08-22 07:42:33 +000053 u16 cert_offset;
Javier Viguerab1e81652024-04-04 17:11:09 +020054 u16 srk_table_offset;
Peng Fan1a7e6252019-08-22 07:42:33 +000055 u16 signature_offset;
Javier Viguerab1e81652024-04-04 17:11:09 +020056 u16 blob_offset;
Peng Fan1a7e6252019-08-22 07:42:33 +000057 u32 reserved;
58} __packed;
Clement Faure9cb2f972021-03-25 17:30:34 +080059
60struct generate_key_blob_hdr {
61 u8 version;
62 u8 length_lsb;
63 u8 length_msb;
64 u8 tag;
65 u8 flags;
66 u8 size;
67 u8 algorithm;
68 u8 mode;
69} __packed;
Ye Li7a71c612021-08-07 16:00:39 +080070
71int get_container_size(ulong addr, u16 *header_length);
Sean Andersonc5126682023-10-14 16:47:43 -040072
73static inline bool valid_container_hdr(struct container_hdr *container)
74{
75 return container->tag == CONTAINER_HDR_TAG &&
76 container->version == CONTAINER_HDR_VERSION;
77}
Peng Fan1a7e6252019-08-22 07:42:33 +000078#endif