lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 | // ¶¨Òå½á¹¹ |
| 47 | typedef volatile struct |
| 48 | { |
| 49 | u32 secure_flag; |
| 50 | u32 puk_hash[4]; |
| 51 | u32 dev_id[3]; |
| 52 | } efuse_struct; |
| 53 | |
xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 54 | typedef volatile struct |
| 55 | { |
| 56 | u32 secure_flag; |
| 57 | u32 puk_hash[8]; |
| 58 | u32 dev_id[3]; |
| 59 | } otp_struct; |
| 60 | |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 61 | typedef struct |
| 62 | { |
| 63 | u32 uiPubKeyRsaE[32]; |
| 64 | u32 uiPubKeyRsaN[32]; |
| 65 | u32 uiHashY[32]; |
| 66 | } sImageHeader; |
| 67 | |
xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 68 | typedef 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 | |
| 80 | extern otp_struct otpInfo; |
| 81 | |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 82 | static void get_efuse_data(void); |
| 83 | static u32 SMALL2BIG(u32 *puiArrIn, u32 *puiArrOut, u32 uiLen); |
| 84 | u8 secure_verify(u32 addr); |
xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 85 | u8 rootfs_secure_verify(u32 addr); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 86 | static u8 data_cmp_word(u32* src, u32* dst, u32 cnt); |
| 87 | int efuse_init(void); |
| 88 | void efuse_get_devinfo(efuse_struct *efuse_info); |
| 89 | |
| 90 | #endif /* __SECURE_VERIFY_H__ */ |