Debian Codegraph @

plat/intel/soc/common/include/socfpga_vab.h

raw
1 /*
2 * Copyright (c) 2020-2023, Intel Corporation. All rights reserved.
3 * Copyright (c) 2024, Altera Corporation. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #ifndef SOCFPGA_VAB_H
9 #define SOCFPGA_VAB_H
10
11 #include <stdlib.h>
12 #include "socfpga_fcs.h"
13
14 /* Macros */
15 #define IS_BYTE_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
16 #define BYTE_ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1)
17 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
18 #define VAB_CERT_HEADER_SIZE sizeof(struct fcs_hps_vab_certificate_header)
19 #define VAB_CERT_MAGIC_OFFSET offsetof(struct fcs_hps_vab_certificate_header, d)
20 #define VAB_CERT_FIT_SHA384_OFFSET offsetof(struct fcs_hps_vab_certificate_data, fcs_sha384[0])
21 #define SDM_CERT_MAGIC_NUM 0x25D04E7F
22 #define CHUNKSZ_PER_WD_RESET (256 * 1024)
23 #define CCERT_CMD_TEST_PGM_MASK 0x80000000 //TODO: ATF FDT location
24
25 /* SHA related return Macro */
26 #define ENOVABCERT 1 /* VAB certificate not available */
27 #define EIMGERR 2 /* Image format/size not valid */
28 #define ETIMEOUT 3 /* Execution timeout */
29 #define EPROCESS 4 /* Process error */
30 #define EKEYREJECTED 5 /* Key was rejected by service */
31 #define EINITREJECTED 6 /* VAB init was rejected */
32
33 struct fcs_hps_vab_certificate_data {
34 uint32_t vab_cert_magic_num; /* offset 0x10 */
35 uint32_t flags;
36 uint8_t rsvd0_1[8];
37 uint8_t fcs_sha384[FCS_SHA384_WORD_SIZE]; /* offset 0x20 */
38 };
39
40 struct fcs_hps_vab_certificate_header {
41 uint32_t cert_magic_num; /* offset 0 */
42 uint32_t cert_data_sz;
43 uint32_t cert_ver;
44 uint32_t cert_type;
45 struct fcs_hps_vab_certificate_data d; /* offset 0x10 */
46 /* keychain starts at offset 0x50 */
47 };
48
49 /* Function Definitions */
50 size_t get_img_size(uint8_t *img_buf, size_t img_buf_sz);
51 uint32_t get_unaligned_le32(const void *p);
52 int socfpga_vab_authentication(void **p_image, size_t *p_size);
53 int socfpga_vab_init(unsigned int image_id);
54 #endif