blob: 2132a03f63473db35a27c2c55f3268f35c8fc11c [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2 * Copyright (C) 2016, ZIXC Corporation.
3 *
4 * File Name:
5 * File Mark:
6 * Description:
7 * Others:
8 * Version:
9 * Author:
10 * Date:
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ********************************************************************************/
18#ifndef __SECURE_VERIFY_H__
19#define __SECURE_VERIFY_H__
20//#include <image.h>
21
22/*--------------CRM ¼Ä´æÆ÷------------*/
23#define SYS_CTRL_BASE 0x00140000
24#define SYS_LSP_CRM_BASE 0x01400000
25#define SYS_MATRIX_CRM_BASE 0x01306000
26#define SYS_SOC_CRM_BASE 0x0013b000
27
28
29#define EFUSE_BYPASS (SYS_CTRL_BASE+0x140)
30#define BOOTSEL_INFO (SYS_SOC_CRM_BASE+0x4)
31#define MPLL_CFG0 (SYS_SOC_CRM_BASE+0x8)
32#define UPLL_CFG0 (SYS_SOC_CRM_BASE+0x10)
33#define RMCORE_CLK_CFG (SYS_SOC_CRM_BASE+0x38)
34#define RM_MOD_CLKSEL (SYS_SOC_CRM_BASE+0x3c)
35#define MATRIX_AXI_SEL (SYS_MATRIX_CRM_BASE+0x0)
36
37/* -------- efuse ²ÎÊý-------------*/
38#define SYS_EFUSE_BASE 0x0121b000
39#define EFUSE_RAM_BASE (SYS_EFUSE_BASE+0x40)
40
41/* -------- RSA, HASH ²ÎÊý-------------*/
42#define SYS_RSA_BASE 0x0121c000
43#define SYS_HASH_BASE 0x0121d000
44
45/*ΪÁË¿´ÆðÀ´·½±ã, hashºÍkeyÔÚbufferµÄ´æ·Å˳ÐòΪµÍµØÖ··Å¸ßλÊý¾Ý*/
46// ¶¨Òå½á¹¹
47typedef volatile struct
48{
49 u32 secure_flag;
50 u32 puk_hash[4];
51 u32 dev_id[3];
52} efuse_struct;
53
xf.liaa4d92f2023-09-13 00:18:58 -070054typedef volatile struct
55{
56 u32 secure_flag;
57 u32 puk_hash[8];
58 u32 dev_id[3];
59} otp_struct;
60
lh9ed821d2023-04-07 01:36:19 -070061typedef struct
62{
63 u32 uiPubKeyRsaE[32];
64 u32 uiPubKeyRsaN[32];
65 u32 uiHashY[32];
66} sImageHeader;
67
xf.liaa4d92f2023-09-13 00:18:58 -070068typedef struct
69{
70 uint16_t signtype;
71 uint16_t hashtype;
72 uint32_t uiPubKeyRsaELen;
73 uint32_t uiPubKeyRsaNLen;
74 uint8_t uiPubKeyRsaE[4];
75 uint8_t uiPubKeyRsaN[256];
76 uint8_t reserve[112]; //380 bytes
77 uint8_t uiHashY[256]; //256 bytes
78} sImageNewHeader;
79
80extern otp_struct otpInfo;
81
lh9ed821d2023-04-07 01:36:19 -070082static void get_efuse_data(void);
83static u32 SMALL2BIG(u32 *puiArrIn, u32 *puiArrOut, u32 uiLen);
84u8 secure_verify(u32 addr);
xf.liaa4d92f2023-09-13 00:18:58 -070085u8 rootfs_secure_verify(u32 addr);
lh9ed821d2023-04-07 01:36:19 -070086static u8 data_cmp_word(u32* src, u32* dst, u32 cnt);
87int efuse_init(void);
88void efuse_get_devinfo(efuse_struct *efuse_info);
89
90#endif /* __SECURE_VERIFY_H__ */