1 /**
2   ******************************************************************************
3   * @file    rtl8721d_otf.h
4   * @author
5   * @version V1.0.0
6   * @date    2016-05-17
7   * @brief   This file contains all the functions prototypes for the flash run time decrypt firmware
8   *          library.
9   ******************************************************************************
10   * @attention
11   *
12   * This module is a confidential and proprietary property of RealTek and
13   * possession or use of this module requires written permission of RealTek.
14   *
15   * Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
16   ******************************************************************************
17   */
18 
19 #ifndef _RTL8721D_RSIP_H_
20 #define _RTL8721D_RSIP_H_
21 
22 /** @addtogroup AmebaD_Platform
23   * @{
24   */
25 
26 /** @defgroup PROTECTION
27   * @brief PROTECTION driver modules
28   * @{
29   */
30 
31 /** @addtogroup PROTECTION
32   * @verbatim
33   *****************************************************************************************
34   * RSIP(OTF) Introduction
35   *****************************************************************************************
36   *		-used for flash firmware protection, and flash firmware will be encrypted use AES.
37   *		-16B KEY shoud be written to EFUSE OTP KEY area use EFUSE_OTF_KEY.
38   *		-Enable should be write to EFUSE 0x19[5].
39   *****************************************************************************************
40   * @endverbatim
41   */
42 
43 /* Exported constants --------------------------------------------------------*/
44 
45 /* Exported functions --------------------------------------------------------*/
46 /** @defgroup PROTECTION_Exported_Functions OTF Exported Functions
47   * @{
48   */
49 _LONG_CALL_ void RSIP_Cmd(u32 NewStatus);
50 _LONG_CALL_ void RSIP_OTF_init(u8* IV);
51 _LONG_CALL_ void RSIP_OTF_Cmd(u32 NewStatus);
52 _LONG_CALL_ void RSIP_OTF_Mask(u32 MaskIdx, u32 Addr, u32 Len, u32 NewStatus);
53 _LONG_CALL_ u32 RSIP_KEY_Request(u32 KeyTypeBit);
54 _LONG_CALL_ void RSIP_MMU_Config(u32 MMUIdx, u32 AddrStart, u32 AddrEnd, u32 IsMinus, u32 AddrOffset);
55 _LONG_CALL_ void RSIP_MMU_Cmd(u32 MMUIdx, u32 NewStatus);
56 /**
57   * @}
58   */
59 
60 /* Registers Definitions --------------------------------------------------------*/
61 /**************************************************************************//**
62  * @defgroup RSIP_Register_Definitions OTF Register Definitions
63  * @{
64  *****************************************************************************/
65 
66 /**************************************************************************//**
67  * @defgroup OTF_DEC
68  * @{
69  *****************************************************************************/
70 #define REG_SYS_OTF_DEC_CTRL				0x02D8
71 #define REG_SYS_OTF_DEC_ADDR_MASK0		0x02DC
72 #define REG_SYS_OTF_DEC_ADDR_MASK1		0x02E4
73 #define REG_SYS_OTF_DEC_ADDR_MASK2		0x02E8
74 #define REG_SYS_OTF_DEC_ADDR_MASK3		0x02EC
75 #define REG_SYS_OTF_DEC_IV_EXT			0x02F0
76 /** @} */
77 
78 /**************************************************************************//**
79  * @defgroup REG_OTF_DEC_CTRL
80  * @{
81  *****************************************************************************/
82 #define OTF_FEN_OTFDEC				((u32)0x00000001)			/*!<function enable of OTF decoder */
83 #define OTF_DEC_IV_BYTE_SWAP		((u32)0x00000002)			/*!<Big/little endian conversion for input OTF IV */
84 #define OTF_DEC_KEY_BYTE_SWAP		((u32)0x00000004)			/*!<Big/little endian conversion for input OTF KEY*/
85 #define OTF_DEC_CIPHER_BYTE_SWAP	((u32)0x00000008)			/*!Big/little endian conversion for calculated cipher*/
86 /** @} */
87 
88 /**************************************************************************//**
89  * @defgroup OTF_MASK_ENTRYx_CTRL
90  * @{
91  *****************************************************************************/
92 #define OTF_DEC_BIT_MASK_EN			((u32)0x00000001)			/*!<Decoder mask enable for address~address+length */
93 #define OTF_DEC_BIT_MASK_SIZE			((u32)0x000000FF)			/*!<Address range for decoder mask, unit is 4KB */
94 #define OTF_DEC_BIT_SHIFT_SIZE			8
95 #define IS_OTF_MASK_SIZE(SIZE) ((((SIZE) & ~OTF_DEC_BIT_MASK_SIZE) == 0x00) && (((SIZE) & OTF_DEC_BIT_MASK_SIZE) != 0x00))
96 /** @} */
97 
98 /**************************************************************************//**
99  * @defgroup MMU_ENTRYx_CTRL
100  * @{
101  *****************************************************************************/
102 #define MMU_BIT_ENTRY_VALID			((u32)0x00000001)			/*!< MMU entry_x valid */
103 #define MMU_BIT_ENTRY_OFFSET_MINUS	((u32)0x00000002)			/*!< MMU_ENTRYx_OFFSET flag, 0 Plus, 1 Minus. */
104 /** @} */
105 
106 /**************************************************************************//**
107  * @defgroup RDP_ERROR_STATUS
108  * @{
109  *****************************************************************************/
110 #define RDP_SYSTEMBIN_WRONG		((u32)0x00000001)            /*!<system.bin not load to flash */
111 #define RDP_RDPBIN_WRONG			((u32)0x00000002)            /*!<rdp.bin not load to flash */
112 #define RDP_KEY_REQUEST_TIMEOUT	((u32)0x00000003)            /*!<Key request timeout */
113 #define RDP_NOT_ENABLE				((u32)0x00000004)            /*!<RDP not enable in efuse */
114 #define RDP_CHECKSUM_ERROR		((u32)0x00000005)            /*!<Check sum error */
115 /** @} */
116 
117 /** @} */
118 
119 /**
120   * @}
121   */
122 
123 /**
124   * @}
125   */
126 
127 /* Other definations --------------------------------------------------------*/
128 #define KEY_REQ_POLL_TIMES			0xFF
129 
130 #endif
131 /******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
132