1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2006-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94
95 ////////////////////////////////////////////////////////////////////////////////////////////////////
96 // file halTCF.c
97 // @brief TCF HAL
98 // @author MStar Semiconductor,Inc.
99 ////////////////////////////////////////////////////////////////////////////////////////////////////
100
101 #include <string.h>
102 #include "MsCommon.h"
103 #include "halTCF.h"
104 #include "regTCF.h"
105
106
107 //--------------------------------------------------------------------------------------------------
108 // Debug Function
109 //--------------------------------------------------------------------------------------------------
110 #define _TCF_DBG(fmt, args...) //printf("\033[32m""[DBG]"fmt"\033[m", ## args)
111 #define _TCF_ERR(fmt, args...) printf("\033[31m""[ERR]"fmt"\033[m", ## args)
112
113
114 //--------------------------------------------------------------------------------------------------
115 // Internal Variable
116 //--------------------------------------------------------------------------------------------------
117 static MS_U32 _u32NonPmBankAddr = 0;
118 static REG_CFCtrl *_CFCtrl = (REG_CFCtrl*)CF_BASE;
119 static REG_CFKECtrl *_CFKECtrl = (REG_CFKECtrl*)CFKE_BASE;
120 static REG_CRIKLCtrl *_CRIKLCtrl = (REG_CRIKLCtrl*)CRI_KL_BASE;
121
122 static MS_U16 u16KeyPara[4] = {0}; // Key Parameter-- shared by DSCMB Key, AESDMA Key
123
124
125 //--------------------------------------------------------------------------------------------------
126 // Macro of bit operations
127 //--------------------------------------------------------------------------------------------------
_REG32_W(REG32 * reg,MS_U32 value)128 void _REG32_W(REG32 *reg, MS_U32 value)
129 {
130 (*((volatile MS_U32*)(reg))) = value;
131 }
132
_REG32_R(REG32 * reg)133 MS_U32 _REG32_R(REG32 *reg)
134 {
135 MS_U32 value = (*(volatile MS_U32*)(reg));
136 return value;
137 }
138
139
140 //--------------------------------------------------------------------------------------------------
141 // Inline Function
142 //--------------------------------------------------------------------------------------------------
HAL_TCF_SetBank(MS_U32 u32NonPmBankAddr)143 void HAL_TCF_SetBank(MS_U32 u32NonPmBankAddr)
144 {
145 _u32NonPmBankAddr = u32NonPmBankAddr;
146 /// CF
147 _CFCtrl = (REG_CFCtrl*) (_u32NonPmBankAddr + CF_BASE);
148 /// CFKE
149 _CFKECtrl = (REG_CFKECtrl*) (_u32NonPmBankAddr + CFKE_BASE);
150
151 /// CRIKL
152 _CRIKLCtrl = (REG_CRIKLCtrl*) (_u32NonPmBankAddr + CRI_KL_BASE);
153 }
154
HAL_TCF_Clk(MS_BOOL bEnable)155 void HAL_TCF_Clk(MS_BOOL bEnable)
156 {
157 REG32 *Reg32_Clk_CF = (REG32*)(_u32NonPmBankAddr + CLKGEN0_BASE + REG_CLK_TCF_SEL);
158
159 if(bEnable){
160 _TCF_DBG("[%s] Enable CF Clock!!\n", __FUNCTION__);
161 _REG32_W( Reg32_Clk_CF, (_REG32_R( Reg32_Clk_CF)|TCF_CLK_54_MHZ));
162 }
163 else{
164 _TCF_DBG("[%s] Disable CF Clock!!\n", __FUNCTION__);
165 _REG32_W( Reg32_Clk_CF, (_REG32_R( Reg32_Clk_CF)&~TCF_CLK_54_MHZ));
166 }
167 }
168
169
170 // CF
171 //
HAL_CF_Version_Info(HAL_CF_VERSION_INFO * _pstTransStatus)172 void HAL_CF_Version_Info(HAL_CF_VERSION_INFO *_pstTransStatus)
173 {
174 MS_U32 u32Value= _REG32_R( &_CFCtrl[0].Cf_Version);
175
176 _pstTransStatus->_u8ManufacturerId = ((u32Value & CF_VERSION_MANUFACTURER_ID_MASK) >> CF_VERSION_MANUFACTURER_ID_POS);
177 _pstTransStatus->_u8NetlistVersion = ((u32Value & CF_VERSION_NETLIST_VERSION_MASK) >> CF_VERSION_NETLIST_VERSION_POS);
178 _pstTransStatus->_u8VersionEpoch = ((u32Value & CF_VERSION_VERSION_EPOCH_MASK) >> CF_VERSION_VERSION_EPOCH_POS);
179 _pstTransStatus->_u8VersionBuildId = ((u32Value & CF_VERSION_BUILD_ID_MASK) >> CF_VERSION_BUILD_ID_POS);
180 }
181
HAL_CF_Trans_Status(HAL_CF_TRANS_STATUS * _pstStatus)182 void HAL_CF_Trans_Status(HAL_CF_TRANS_STATUS *_pstStatus)
183 {
184 MS_U32 u32Value= _REG32_R( &_CFCtrl[0].Cf_Status);
185
186 _pstStatus->_eTransStatus = ((u32Value & CF_TRANS_STATUS_MASK) >> CF_TRANS_STATUS_POS);
187 _pstStatus->_u8UseNvmKey = ((u32Value & CF_USE_NVMKEY_MASK) >> CF_USE_NVMKEY_POS);
188 _pstStatus->_eOperationType = ((u32Value & CF_OPERATION_TYPE_MASK) >> CF_OPERATION_TYPE_POS);
189 _pstStatus->_eDecmSrc = ((u32Value & CF_DECM_SOURCE_MASK) >> CF_DECM_SOURCE_POS);
190 _pstStatus->_eOutputUsage = ((u32Value & CF_OUTPUT_USAGE_MASK) >> CF_OUTPUT_USAGE_POS);
191 _pstStatus->_u8ProductRange = ((u32Value & CF_PRODUCT_RANGE_MASK) >> CF_PRODUCT_RANGE_POS);
192 _pstStatus->_u8ProductOffset = ((u32Value & CF_PRODUCT_OFFSET_MASK) >> CF_PRODUCT_OFFSET_POS);
193 }
194
HAL_CF_Cf_Status(HAL_CF_CF_STATUS * _pstCfStatus)195 void HAL_CF_Cf_Status(HAL_CF_CF_STATUS *_pstCfStatus)
196 {
197 MS_U32 u32Value= _REG32_R( &_CFCtrl[0].Cf_Status);
198 _pstCfStatus->_eNvmStatus = ((u32Value & CF_NVM_STATUS_MASK) >> CF_NVM_STATUS_POS);
199 _pstCfStatus->_eDiffStatus = ((u32Value & CF_DIFF_STATUS_MASK) >> CF_DIFF_STATUS_POS);
200
201 u32Value= _REG32_R( &_CFCtrl[0].Cf_Platform);
202 if( ((_REG32_R( &_CFCtrl[0].Cf_Version) & CF_VERSION_NETLIST_VERSION_MASK) >> CF_VERSION_NETLIST_VERSION_POS) == 0 ) // Netlist Version 0
203 {
204 _pstCfStatus->_u8RecentReset = ((u32Value & CF_PLATFORM_RECENT_RESET_MASK) >> CF_PLATFORM_RECENT_RESET_POS);
205 _pstCfStatus->_u8CfAlert = ((u32Value & CF_PLATFORM_CF_ALERT_MASK) >> CF_PLATFORM_CF_ALERT_POS);
206 // Netlist Version 0 has no development mode bit.
207 _pstCfStatus->_u8DevelopmentMode = 0x0;
208 // Netlist Version 0 has a different Fuse Activate and Fuse Block positions.
209 _pstCfStatus->_u8FuseActivate = ((u32Value & 0x00200000) >> 21);
210 _pstCfStatus->_u8FuseBlock = ((u32Value & 0x00100000) >> 20);
211 }
212 else
213 {
214 _pstCfStatus->_u8RecentReset = ((u32Value & CF_PLATFORM_RECENT_RESET_MASK) >> CF_PLATFORM_RECENT_RESET_POS);
215 _pstCfStatus->_u8CfAlert = ((u32Value & CF_PLATFORM_CF_ALERT_MASK) >> CF_PLATFORM_CF_ALERT_POS);
216 _pstCfStatus->_u8DevelopmentMode = ((u32Value & CF_PLATFORM_DEVELOPMENT_MODE_MASK) >> CF_PLATFORM_DEVELOPMENT_MODE_POS);
217 _pstCfStatus->_u8FuseActivate = ((u32Value & CF_PLATFORM_CF_ACTIVATED_MASK) >> CF_PLATFORM_CF_ACTIVATED_POS);
218 _pstCfStatus->_u8FuseBlock = ((u32Value & 0x00000080) >> 7);
219 }
220 }
221
HAL_CF_Cf_FeatureVector(HAL_CF_FEATURE_VECTOR * _pstCfFeature)222 void HAL_CF_Cf_FeatureVector(HAL_CF_FEATURE_VECTOR *_pstCfFeature)
223 {
224 _pstCfFeature->_u32FeatureVector= _REG32_R( &_CFCtrl[0].Cf_Feature);
225 }
226
HAL_CF_Get_Trans_Status(void)227 MS_U8 HAL_CF_Get_Trans_Status(void)
228 {
229 MS_U32 u32Value= _REG32_R( &_CFCtrl[0].Cf_Status);
230 //_TCF_DBG("[%s] === Trans_Status= 0x%08lx ===\n", __FUNCTION__, u32Value);
231 return (MS_U8)((u32Value & CF_TRANS_STATUS_MASK) >> CF_TRANS_STATUS_POS);
232 }
233
HAL_CF_Get_Operation_Type(void)234 MS_U8 HAL_CF_Get_Operation_Type(void)
235 {
236 MS_U32 u32Value= _REG32_R( &_CFCtrl[0].Cf_Status);
237
238 return (MS_U8)((u32Value & CF_OPERATION_TYPE_MASK) >> CF_OPERATION_TYPE_POS);
239 }
240
HAL_CF_Get_CwcValid(void)241 MS_U8 HAL_CF_Get_CwcValid(void)
242 {
243 MS_U32 u32Value= _REG32_R( &_CFCtrl[0].Cf_Platform);
244
245 return (MS_U8)((u32Value & CF_PLATFORM_CWC_VALID_MASK) >> CF_PLATFORM_CWC_VALID_POS);
246 }
247
HAL_CF_Read_Input(void)248 MS_U32 HAL_CF_Read_Input(void)
249 {
250 return _REG32_R( &_CFCtrl[0].Cf_Input);
251 }
252
HAL_CF_Read_Output(void)253 MS_U32 HAL_CF_Read_Output(void)
254 {
255 return _REG32_R( &_CFCtrl[0].Cf_Output);
256 }
257
HAL_CF_Write_Input(MS_U32 u32Cmd)258 void HAL_CF_Write_Input(MS_U32 u32Cmd)
259 {
260 _REG32_W( &_CFCtrl[0].Cf_Input, u32Cmd);
261 }
262
HAL_CF_Write_Output(MS_U32 u32Cmd)263 void HAL_CF_Write_Output(MS_U32 u32Cmd)
264 {
265 _REG32_W( &_CFCtrl[0].Cf_Output, u32Cmd);
266 }
267
268 #define _CF_TRANS_STATUS_BUSY_OP 0x4
HAL_CF_Get_CF_IsFinished(void)269 MS_U8 HAL_CF_Get_CF_IsFinished(void)
270 {
271 if( HAL_CF_Get_Trans_Status()==_CF_TRANS_STATUS_BUSY_OP ){
272 return FALSE;
273 }
274 else{
275 return TRUE;
276 }
277 }
278
279
280 // CFKE
281 //
HAL_CFKE_Get_OperationStatus(void)282 MS_U8 HAL_CFKE_Get_OperationStatus(void)
283 {
284 // CFKE_STATUS [31:28]
285 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
286
287 return (MS_U8)((u32Value & CFKE_OPERATION_STATUS_MASK) >> CFKE_OPERATION_STATUS_POS);
288 }
HAL_CFKE_Get_OperationCount(void)289 MS_U8 HAL_CFKE_Get_OperationCount(void)
290 {
291 // CFKE_STATUS [27:20]
292 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
293
294 return (MS_U8)((u32Value & CFKE_OPERATION_COUNT_MASK) >> CFKE_OPERATION_COUNT_POS);
295 }
HAL_CFKE_Get_ErrorCode(void)296 MS_U8 HAL_CFKE_Get_ErrorCode(void)
297 {
298 // CFKE_STATUS [19:16]
299 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
300
301 return (MS_U8)((u32Value & CFKE_ERROR_CODE_MASK) >> CFKE_ERROR_CODE_POS);
302 }
HAL_CFKE_Get_OperationType(void)303 MS_U8 HAL_CFKE_Get_OperationType(void)
304 {
305 // CFKE_STATUS [15:12]
306 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
307
308 return (MS_U8)((u32Value & CFKE_OPERATION_TYPE_MASK) >> CFKE_OPERATION_TYPE_POS);
309 }
HAL_CFKE_Get_DiffAllowNonUnw(void)310 MS_U8 HAL_CFKE_Get_DiffAllowNonUnw(void)
311 {
312 // CFKE_STATUS [3]
313 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
314
315 return (MS_U8)((u32Value & CFKE_DIFF_ALLOW_NON_UNW_MASK) >> CFKE_DIFF_ALLOW_NON_UNW_POS);
316 }
HAL_CFKE_Get_DiffAllowCk(void)317 MS_U8 HAL_CFKE_Get_DiffAllowCk(void)
318 {
319 // CFKE_STATUS [2]
320 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
321
322 return (MS_U8)((u32Value & CFKE_DIFF_ALLOW_CK_MASK) >> CFKE_DIFF_ALLOW_CK_POS);
323 }
HAL_CFKE_Get_DiffContentOutputAllowed(void)324 MS_U8 HAL_CFKE_Get_DiffContentOutputAllowed(void)
325 {
326 // CFKE_STATUS [1:0]
327 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Status);
328
329 return (MS_U8)((u32Value & CFKE_DIFF_CONTENT_OUTPUT_ALLOWED_MASK) >> CFKE_DIFF_CONTENT_OUTPUT_ALLOWED_POS);
330 }
331
332
HAL_CFKE_Read_Command(void)333 MS_U32 HAL_CFKE_Read_Command(void)
334 {
335 return _REG32_R( &_CFKECtrl[0].Cfke_Command);
336 }
HAL_CFKE_Write_Command(MS_U32 u32Cmd)337 void HAL_CFKE_Write_Command(MS_U32 u32Cmd)
338 {
339 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
340 _REG32_W( &_CFKECtrl[0].Cfke_Command, u32Cmd);
341 }
342
343
HAL_CFKE_Read_Platform(void)344 MS_U32 HAL_CFKE_Read_Platform(void)
345 {
346 return _REG32_R( &_CFKECtrl[0].Cfke_Platform);
347 }
348
HAL_CFKE_IsTransactionDone(void)349 MS_BOOL HAL_CFKE_IsTransactionDone(void)
350 {
351 // CFKE_PLATFORM [30]
352 MS_U32 u32Value= _REG32_R( &_CFKECtrl[0].Cfke_Platform);
353
354 return (MS_U8)((u32Value & CFKE_TRANSACTION_DONE_MASK) >> CFKE_TRANSACTION_DONE_POS);
355 }
356
357
HAL_CFKE_Read_UnwPath(void)358 MS_U32 HAL_CFKE_Read_UnwPath(void)
359 {
360 return _REG32_R( &_CFKECtrl[0].Cfke_Unw_Path);
361 }
HAL_CFKE_Write_UnwPath(MS_U32 u32Cmd)362 void HAL_CFKE_Write_UnwPath(MS_U32 u32Cmd)
363 {
364 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
365 _REG32_W( &_CFKECtrl[0].Cfke_Unw_Path, u32Cmd);
366 }
367
368
HAL_CFKE_Read_Validator0(void)369 MS_U32 HAL_CFKE_Read_Validator0(void)
370 {
371 return _REG32_R( &_CFKECtrl[0].Cfke_Validator_0);
372 }
HAL_CFKE_Write_Validator0(MS_U32 u32Cmd)373 void HAL_CFKE_Write_Validator0(MS_U32 u32Cmd)
374 {
375 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
376 _REG32_W( &_CFKECtrl[0].Cfke_Validator_0, u32Cmd);
377 }
378
379
HAL_CFKE_Read_Validator1(void)380 MS_U32 HAL_CFKE_Read_Validator1(void)
381 {
382 return _REG32_R( &_CFKECtrl[0].Cfke_Validator_1);
383 }
HAL_CFKE_Write_Validator1(MS_U32 u32Cmd)384 void HAL_CFKE_Write_Validator1(MS_U32 u32Cmd)
385 {
386 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
387 _REG32_W( &_CFKECtrl[0].Cfke_Validator_1, u32Cmd);
388 }
389
390
HAL_CFKE_Write_SlotA(MS_U32 u32Cmd)391 void HAL_CFKE_Write_SlotA(MS_U32 u32Cmd)
392 {
393 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
394 _REG32_W( &_CFKECtrl[0].Cfke_Slot_A, u32Cmd);
395 }
HAL_CFKE_Write_SlotB(MS_U32 u32Cmd)396 void HAL_CFKE_Write_SlotB(MS_U32 u32Cmd)
397 {
398 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
399 _REG32_W( &_CFKECtrl[0].Cfke_Slot_B, u32Cmd);
400 }
HAL_CFKE_Write_SlotC(MS_U32 u32Cmd)401 void HAL_CFKE_Write_SlotC(MS_U32 u32Cmd)
402 {
403 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
404 _REG32_W( &_CFKECtrl[0].Cfke_Slot_C, u32Cmd);
405 }
HAL_CFKE_Write_SlotD(MS_U32 u32Cmd)406 void HAL_CFKE_Write_SlotD(MS_U32 u32Cmd)
407 {
408 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
409 _REG32_W( &_CFKECtrl[0].Cfke_Slot_D, u32Cmd);
410 }
411
HAL_CFKE_Write_UserHash(MS_U32 u32Cmd)412 void HAL_CFKE_Write_UserHash(MS_U32 u32Cmd)
413 {
414 _TCF_DBG("[%s][%d] u32Cmd= 0x%08lx\n", __FUNCTION__, __LINE__, u32Cmd);
415 _REG32_W( &_CFKECtrl[0].Cfke_User_Hash, u32Cmd);
416 }
417
418
419 // CRIKL
420 //
HAL_CRIKL_Read_CfStatus(void)421 MS_U32 HAL_CRIKL_Read_CfStatus(void)
422 {
423 MS_U32 u32Val = 0;
424
425 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cfstatusout_h)&0xffff)<<16;
426 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cfstatusout_l)&0xffff);
427 return u32Val;
428 }
HAL_CRIKL_Read_CfkeStatus(void)429 MS_U32 HAL_CRIKL_Read_CfkeStatus(void)
430 {
431 MS_U32 u32Val = 0;
432
433 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cfkestatusout_h)&0xffff)<<16;
434 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cfkestatusout_l)&0xffff);
435 return u32Val;
436 }
HAL_CRIKL_Read_CfPlatform(void)437 MS_U32 HAL_CRIKL_Read_CfPlatform(void)
438 {
439 MS_U32 u32Val = 0;
440
441 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cfplatformout_h)&0xffff)<<16;
442 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cfplatformout_l)&0xffff);
443 return u32Val;
444 }
HAL_CRIKL_Read_CfFeature(void)445 MS_U32 HAL_CRIKL_Read_CfFeature(void)
446 {
447 MS_U32 u32Val = 0;
448
449 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cffeatureout_h)&0xffff)<<16;
450 u32Val |= (_REG32_R( &_CRIKLCtrl[0].reg_cffeatureout_l)&0xffff);
451 return u32Val;
452 }
453
HAL_CRIKL_Set_KTIndex(MS_U8 eScmbCtl,MS_U8 u8DscmbId)454 void HAL_CRIKL_Set_KTIndex( MS_U8 eScmbCtl, MS_U8 u8DscmbId)
455 {
456 _TCF_DBG("[%s][%d] u16KtIdx= 0x%1x%1x\n", __FUNCTION__, __LINE__, eScmbCtl, u8DscmbId);
457
458 MS_U16 u16KtIdx = 0;
459 u16KtIdx |= eScmbCtl << CRI_KT_SCMB_CTL_POS;
460 u16KtIdx |= u8DscmbId;
461 _REG32_W( &_CRIKLCtrl[0].reg_cri_kt_index, (MS_U32)u16KtIdx);
462 }
HAL_CRIKL_Write_KTPara_High_HalfWord(MS_U16 u16HalfWord)463 void HAL_CRIKL_Write_KTPara_High_HalfWord(MS_U16 u16HalfWord)
464 {
465 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
466 _REG32_W( &_CRIKLCtrl[0].reg_cri_kt_para_63_48, (MS_U32)u16HalfWord);
467 }
HAL_CRIKL_Write_KTPara_2nd_HalfWord(MS_U16 u16HalfWord)468 void HAL_CRIKL_Write_KTPara_2nd_HalfWord(MS_U16 u16HalfWord)
469 {
470 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
471 _REG32_W( &_CRIKLCtrl[0].reg_cri_kt_para_47_32, (MS_U32)u16HalfWord);
472 }
HAL_CRIKL_Write_KTPara_3rd_HalfWord(MS_U16 u16HalfWord)473 void HAL_CRIKL_Write_KTPara_3rd_HalfWord(MS_U16 u16HalfWord)
474 {
475 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
476 _REG32_W( &_CRIKLCtrl[0].reg_cri_kt_para_31_16, (MS_U32)u16HalfWord);
477 }
HAL_CRIKL_Write_KTPara_Low_HalfWord(MS_U16 u16HalfWord)478 void HAL_CRIKL_Write_KTPara_Low_HalfWord(MS_U16 u16HalfWord)
479 {
480 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
481 _REG32_W( &_CRIKLCtrl[0].reg_cri_kt_para_15_00, (MS_U32)u16HalfWord);
482 }
483
HAL_CRIKL_Read_KTIndex(void)484 MS_U16 HAL_CRIKL_Read_KTIndex(void)
485 {
486 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_kt_index))&0xFFFF;
487 }
HAL_CRIKL_Read_KTPara_High_HalfWord(void)488 MS_U16 HAL_CRIKL_Read_KTPara_High_HalfWord(void)
489 {
490 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_kt_para_63_48))&0xFFFF;
491 }
HAL_CRIKL_Read_KTPara_2nd_HalfWord(void)492 MS_U16 HAL_CRIKL_Read_KTPara_2nd_HalfWord(void)
493 {
494 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_kt_para_47_32))&0xFFFF;
495 }
HAL_CRIKL_Read_KTPara_3rd_HalfWord(void)496 MS_U16 HAL_CRIKL_Read_KTPara_3rd_HalfWord(void)
497 {
498 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_kt_para_31_16))&0xFFFF;
499 }
HAL_CRIKL_Read_KTPara_Low_HalfWord(void)500 MS_U16 HAL_CRIKL_Read_KTPara_Low_HalfWord(void)
501 {
502 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_kt_para_15_00))&0xFFFF;
503 }
504
505
506
HAL_CRIKL_Set_KSIndex(MS_U8 u8KsIdx)507 void HAL_CRIKL_Set_KSIndex(MS_U8 u8KsIdx)
508 {
509 _TCF_DBG("[%s][%d] u16KsIdx= 0x%02x\n", __FUNCTION__, __LINE__, u8KsIdx);
510
511 MS_U16 u16KsIdx = 0;
512 u16KsIdx |= (u8KsIdx&CRI_KS_IDX_VAL_MASK);
513 _REG32_W( &_CRIKLCtrl[0].reg_cri_ks_index, (MS_U32)u16KsIdx);
514 }
HAL_CRIKL_Write_KSPara_High_HalfWord(MS_U16 u16HalfWord)515 void HAL_CRIKL_Write_KSPara_High_HalfWord(MS_U16 u16HalfWord)
516 {
517 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
518 _REG32_W( &_CRIKLCtrl[0].reg_cri_ks_para_63_48, (MS_U32)u16HalfWord);
519 }
HAL_CRIKL_Write_KSPara_2nd_HalfWord(MS_U16 u16HalfWord)520 void HAL_CRIKL_Write_KSPara_2nd_HalfWord(MS_U16 u16HalfWord)
521 {
522 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
523 _REG32_W( &_CRIKLCtrl[0].reg_cri_ks_para_47_32, (MS_U32)u16HalfWord);
524 }
HAL_CRIKL_Write_KSPara_3rd_HalfWord(MS_U16 u16HalfWord)525 void HAL_CRIKL_Write_KSPara_3rd_HalfWord(MS_U16 u16HalfWord)
526 {
527 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
528 _REG32_W( &_CRIKLCtrl[0].reg_cri_ks_para_31_16, (MS_U32)u16HalfWord);
529 }
HAL_CRIKL_Write_KSPara_Low_HalfWord(MS_U16 u16HalfWord)530 void HAL_CRIKL_Write_KSPara_Low_HalfWord(MS_U16 u16HalfWord)
531 {
532 //_TCF_DBG("[%s][%d] u16HalfWord= 0x%08x\n", __FUNCTION__, __LINE__, u16HalfWord);
533 _REG32_W( &_CRIKLCtrl[0].reg_cri_ks_para_15_00, (MS_U32)u16HalfWord);
534 }
535
HAL_CRIKL_Read_KSIndex(void)536 MS_U16 HAL_CRIKL_Read_KSIndex(void)
537 {
538 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_ks_index))&0xFFFF;
539 }
HAL_CRIKL_Read_KSPara_High_HalfWord(void)540 MS_U16 HAL_CRIKL_Read_KSPara_High_HalfWord(void)
541 {
542 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_ks_para_63_48))&0xFFFF;
543 }
HAL_CRIKL_Read_KSPara_2nd_HalfWord(void)544 MS_U16 HAL_CRIKL_Read_KSPara_2nd_HalfWord(void)
545 {
546 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_ks_para_47_32))&0xFFFF;
547 }
HAL_CRIKL_Read_KSPara_3rd_HalfWord(void)548 MS_U16 HAL_CRIKL_Read_KSPara_3rd_HalfWord(void)
549 {
550 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_ks_para_31_16))&0xFFFF;
551 }
HAL_CRIKL_Read_KSPara_Low_HalfWord(void)552 MS_U16 HAL_CRIKL_Read_KSPara_Low_HalfWord(void)
553 {
554 return (_REG32_R( &_CRIKLCtrl[0].reg_cri_ks_para_15_00))&0xFFFF;
555 }
556
HAL_CRIKL_Reset_KeyPara(void)557 void HAL_CRIKL_Reset_KeyPara(void)
558 {
559 memset( (void*)u16KeyPara, 0x0, sizeof(u16KeyPara));
560 }
HAL_CRIKL_Write_KeyPara(MS_BOOL bDscmbKey)561 void HAL_CRIKL_Write_KeyPara(MS_BOOL bDscmbKey)
562 {
563 _TCF_DBG("[%s][%d] Setup %s Parameter\n", __FUNCTION__, __LINE__, (bDscmbKey)? "Key Table":"Key Slot");
564 _TCF_DBG("[%s][%d] >>> 0x%04X\n", __FUNCTION__, __LINE__, u16KeyPara[3]);
565 _TCF_DBG("[%s][%d] >>> 0x%04X\n", __FUNCTION__, __LINE__, u16KeyPara[2]);
566 _TCF_DBG("[%s][%d] >>> 0x%04X\n", __FUNCTION__, __LINE__, u16KeyPara[1]);
567 _TCF_DBG("[%s][%d] >>> 0x%04X\n", __FUNCTION__, __LINE__, u16KeyPara[0]);
568
569 if(bDscmbKey){
570 HAL_CRIKL_Write_KTPara_High_HalfWord( u16KeyPara[3]);
571 HAL_CRIKL_Write_KTPara_2nd_HalfWord( u16KeyPara[2]);
572 HAL_CRIKL_Write_KTPara_3rd_HalfWord( u16KeyPara[1]);
573 HAL_CRIKL_Write_KTPara_Low_HalfWord( u16KeyPara[0]);
574 }
575 else{
576 HAL_CRIKL_Write_KSPara_High_HalfWord( u16KeyPara[3]);
577 HAL_CRIKL_Write_KSPara_2nd_HalfWord( u16KeyPara[2]);
578 HAL_CRIKL_Write_KSPara_3rd_HalfWord( u16KeyPara[1]);
579 HAL_CRIKL_Write_KSPara_Low_HalfWord( u16KeyPara[0]);
580 }
581 }
582
HAL_CRIKL_Setup_VendorNo(MS_BOOL bDscmbKey,MS_U8 u8VendorNo)583 void HAL_CRIKL_Setup_VendorNo(MS_BOOL bDscmbKey, MS_U8 u8VendorNo)
584 {
585 if(bDscmbKey){ // Key Table
586 u16KeyPara[3] |= u8VendorNo << CRI_KT_VENDOR_NO_POS;
587 }
588 else{ // Key Slot
589 u16KeyPara[3] |= u8VendorNo << CRI_KS_VENDOR_NO_POS;
590 }
591 }
HAL_CRIKL_Setup_VendorAtt(MS_BOOL bDscmbKey,MS_U16 u16VendorAtt)592 void HAL_CRIKL_Setup_VendorAtt(MS_BOOL bDscmbKey, MS_U16 u16VendorAtt)
593 {
594 if(bDscmbKey){ // Key Table
595 u16KeyPara[3] |= ((u16VendorAtt&CRI_KT_VENDOR_ATT_H_VAL_MASK)>>CRI_KT_VENDOR_ATT_L_OFFSET) << CRI_KT_VENDOR_ATT_H_POS;
596 u16KeyPara[2] |= (u16VendorAtt&CRI_KT_VENDOR_ATT_L_VAL_MASK) << CRI_KT_VENDOR_ATT_L_POS;
597 }
598 else{ // Key Slot
599 u16KeyPara[3] |= ((u16VendorAtt&CRI_KS_VENDOR_ATT_H_VAL_MASK)>>CRI_KS_VENDOR_ATT_L_OFFSET) << CRI_KS_VENDOR_ATT_H_POS;
600 u16KeyPara[2] |= (u16VendorAtt&CRI_KS_VENDOR_ATT_L_VAL_MASK) << CRI_KS_VENDOR_ATT_L_POS;
601 }
602 }
HAL_CRIKL_Setup_OutputAllowed(MS_BOOL bDscmbKey,MS_U8 u8OutputAllowed)603 void HAL_CRIKL_Setup_OutputAllowed(MS_BOOL bDscmbKey, MS_U8 u8OutputAllowed)
604 {
605 if(bDscmbKey){ // Key Table
606 u16KeyPara[2] |= u8OutputAllowed << CRI_KT_OUTPUT_ALLOWED_POS;
607 }
608 else{ // Key Slot
609 u16KeyPara[2] |= u8OutputAllowed << CRI_KS_OUTPUT_ALLOWED_POS;
610 }
611 }
612
HAL_CRIKL_Setup_bMultiEng(MS_BOOL bDscmbKey,MS_BOOL bMultiEng)613 void HAL_CRIKL_Setup_bMultiEng(MS_BOOL bDscmbKey, MS_BOOL bMultiEng)
614 {
615 if(bDscmbKey){ // Key Table
616 u16KeyPara[2] |= ((bMultiEng)? 1:0) << CRI_KT_MULTI_ENG_POS;
617 }
618 else{ // Key Slot
619 u16KeyPara[2] |= ((bMultiEng)? 1:0) << CRI_KS_MULTI_ENG_POS;
620 }
621 }
HAL_CRIKL_Setup_bLsb64(MS_BOOL bDscmbKey,MS_BOOL bLsb64)622 void HAL_CRIKL_Setup_bLsb64(MS_BOOL bDscmbKey, MS_BOOL bLsb64)
623 {
624 if(bDscmbKey){ // Key Table
625 u16KeyPara[2] |= ((bLsb64)? 1:0) << CRI_KT_LSB64_POS;
626 }
627 else{ // Key Slot
628 u16KeyPara[2] |= ((bLsb64)? 1:0) << CRI_KS_LSB64_POS;
629 }
630 }
HAL_CRIKL_Setup_KeySize(MS_BOOL bDscmbKey,MS_U8 eKeySize)631 void HAL_CRIKL_Setup_KeySize(MS_BOOL bDscmbKey, MS_U8 eKeySize)
632 {
633 MS_U8 u8Pos = 0;
634
635 if(bDscmbKey){ // Key Table
636 switch(eKeySize){
637 case 0: u8Pos = CRI_KT_KEY_SIZE_64_POS; break;
638 case 1: u8Pos = CRI_KT_KEY_SIZE_128_POS; break;
639 case 2: u8Pos = CRI_KT_KEY_SIZE_192_POS; break;
640 case 3: u8Pos = CRI_KT_KEY_SIZE_256_POS; break;
641 default: break;
642 }
643 }
644 else{ // Key Slot
645 switch(eKeySize){
646 case 0: u8Pos = CRI_KS_KEY_SIZE_64_POS; break;
647 case 1: u8Pos = CRI_KS_KEY_SIZE_128_POS; break;
648 case 2: u8Pos = CRI_KS_KEY_SIZE_192_POS; break;
649 case 3: u8Pos = CRI_KS_KEY_SIZE_256_POS; break;
650 default: break;
651 }
652 }
653
654 u16KeyPara[2] |= 1 << u8Pos;
655 }
HAL_CRIKL_Setup_KeyEngine(MS_BOOL bDscmbKey,MS_U8 u8KeyEng)656 void HAL_CRIKL_Setup_KeyEngine(MS_BOOL bDscmbKey, MS_U8 u8KeyEng)
657 {
658 if(bDscmbKey){ // Key Table
659 if( /*CRIKL_KL_ENG_NPD*/0x80&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_NPD_POS;}
660 if( /*CRIKL_KL_ENG_MULTI2*/0x40&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_MULTI2_POS;}
661 if( /*CRIKL_KL_ENG_CSAV2*/0x20&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_CSAV2_POS;}
662 if( /*CRIKL_KL_ENG_CSAV3*/0x10&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_CSAV3_POS;}
663 if( /*CRIKL_KL_ENG_ASA*/0x08&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_ASA_POS;}
664 if( /*CRIKL_KL_ENG_DES*/0x04&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_DES_POS;}
665 if( /*CRIKL_KL_ENG_TDES*/0x02&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_TDES_POS;}
666 if( /*CRIKL_KL_ENG_AES*/0x01&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KT_ENG_AES_POS;}
667 }
668 else{ // Key Slot
669 if( /*CRIKL_KL_ENG_NPD*/0x80&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_NPD_POS;}
670 if( /*CRIKL_KL_ENG_MULTI2*/0x40&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_MULTI2_POS;}
671 if( /*CRIKL_KL_ENG_CSAV2*/0x20&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_CSAV2_POS;}
672 if( /*CRIKL_KL_ENG_CSAV3*/0x10&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_CSAV3_POS;}
673 if( /*CRIKL_KL_ENG_ASA*/0x08&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_ASA_POS;}
674 if( /*CRIKL_KL_ENG_DES*/0x04&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_DES_POS;}
675 if( /*CRIKL_KL_ENG_TDES*/0x02&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_TDES_POS;}
676 if( /*CRIKL_KL_ENG_AES*/0x01&u8KeyEng ) { u16KeyPara[1] |= 1 << CRI_KS_ENG_AES_POS;}
677 }
678 }
HAL_CRIKL_Setup_Drop(MS_BOOL bDscmbKey,MS_U8 u8Drop)679 void HAL_CRIKL_Setup_Drop(MS_BOOL bDscmbKey, MS_U8 u8Drop)
680 {
681 if(bDscmbKey){ // Key Table
682 u16KeyPara[1] |= u8Drop << CRI_KT_DROP_POS;
683 }
684 else{ // Key Slot
685 u16KeyPara[1] |= u8Drop << CRI_KS_DROP_POS;
686 }
687 }
HAL_CRIKL_Setup_Cnt(MS_BOOL bDscmbKey,MS_U8 u8Cnt)688 void HAL_CRIKL_Setup_Cnt(MS_BOOL bDscmbKey, MS_U8 u8Cnt)
689 {
690 if(bDscmbKey){ // Key Table
691 u16KeyPara[1] |= u8Cnt << CRI_KT_CNT_POS;
692 }
693 else{ // Key Slot
694 u16KeyPara[1] |= u8Cnt << CRI_KS_CNT_POS;
695 }
696 }
HAL_CRIKL_Setup_KeyDest(MS_BOOL bDscmbKey,MS_U8 u8KeyDest)697 void HAL_CRIKL_Setup_KeyDest(MS_BOOL bDscmbKey, MS_U8 u8KeyDest)
698 {
699 if(bDscmbKey){ // Key Table
700 if( /*CRIKL_KL_DEST_AESDMA*/0x4&u8KeyDest ) { u16KeyPara[0] |= 1 << CRI_KT_DEST_AESDMA_POS;}
701 if( /*CRIKL_KL_DEST_PVR*/0x2&u8KeyDest ) { u16KeyPara[0] |= 1 << CRI_KT_DEST_PVR_POS;}
702 if( /*CRIKL_KL_DEST_CIPHER*/0x1&u8KeyDest ) { u16KeyPara[0] |= 1 << CRI_KT_DEST_CIPHER_POS;}
703 }
704 else{ // Key Slot
705 if( /*CRIKL_KL_DEST_AESDMA*/0x4&u8KeyDest ) { u16KeyPara[0] |= 1 << CRI_KS_DEST_AESDMA_POS;}
706 if( /*CRIKL_KL_DEST_PVR*/0x2&u8KeyDest ) { u16KeyPara[0] |= 1 << CRI_KS_DEST_PVR_POS;}
707 if( /*CRIKL_KL_DEST_CIPHER*/0x1&u8KeyDest ) { u16KeyPara[0] |= 1 << CRI_KS_DEST_CIPHER_POS;}
708 }
709 }
HAL_CRIKL_Setup_OpType(MS_BOOL bDscmbKey,MS_U8 u8Op)710 void HAL_CRIKL_Setup_OpType(MS_BOOL bDscmbKey, MS_U8 u8Op)
711 {
712 if(bDscmbKey){ // Key Table
713 switch(u8Op){
714 case 0: break;
715 case 1: u16KeyPara[0] |= 1 << CRI_KT_DECRYPT_POS; break;
716 case 2: u16KeyPara[0] |= 1 << CRI_KT_ENCRYPT_POS; break;
717 default: break;
718 }
719 }
720 else{ // Key Slot
721 switch(u8Op){
722 case 0: break;
723 case 1: u16KeyPara[0] |= 1 << CRI_KS_DECRYPT_POS; break;
724 case 2: u16KeyPara[0] |= 1 << CRI_KS_ENCRYPT_POS; break;
725 default: break;
726 }
727 }
728 }
HAL_CRIKL_Setup_KteSel(MS_BOOL bDscmbKey,MS_U8 eKteSel)729 void HAL_CRIKL_Setup_KteSel(MS_BOOL bDscmbKey, MS_U8 eKteSel)
730 {
731 MS_U8 u8Pos = 0;
732
733 if(bDscmbKey){ // Key Table
734 switch(eKteSel){
735 case 0: u8Pos = CRI_KT_KTE_0; break;
736 case 1: u8Pos = CRI_KT_KTE_1; break;
737 case 2: u8Pos = CRI_KT_KTE_2; break;
738 case 3: u8Pos = CRI_KT_KTE_3; break;
739 default: break;
740 }
741 }
742 else{ // Key Slot
743 switch(eKteSel){
744 case 0: u8Pos = CRI_KS_KTE_0; break;
745 case 1: u8Pos = CRI_KS_KTE_1; break;
746 case 2: u8Pos = CRI_KS_KTE_2; break;
747 case 3: u8Pos = CRI_KS_KTE_3; break;
748 default: break;
749 }
750 }
751
752 u16KeyPara[0] |= 1 << u8Pos;
753 }
HAL_CRIKL_Setup_bLock(MS_BOOL bDscmbKey,MS_BOOL bLock)754 void HAL_CRIKL_Setup_bLock(MS_BOOL bDscmbKey, MS_BOOL bLock)
755 {
756 if(bDscmbKey){ // Key Table
757 u16KeyPara[0] |= ((bLock)? 1:0) << CRI_KT_LOCK;
758 }
759 else{ // Key Slot
760 u16KeyPara[0] |= ((bLock)? 1:0) << CRI_KS_LOCK;
761 }
762 }
HAL_CRIKL_Setup_bParaValid(MS_BOOL bDscmbKey,MS_BOOL bParaValid)763 void HAL_CRIKL_Setup_bParaValid(MS_BOOL bDscmbKey, MS_BOOL bParaValid)
764 {
765 if(bDscmbKey){ // Key Table
766 u16KeyPara[0] |= ((bParaValid)? 1:0) << CRI_KT_PARA_VLA;
767 }
768 else{ // Key Slot
769 u16KeyPara[0] |= ((bParaValid)? 1:0) << CRI_KS_PARA_VLA;
770 }
771 }
HAL_CRIKL_Setup_bKlEn(MS_BOOL bDscmbKey,MS_BOOL bKlEn)772 void HAL_CRIKL_Setup_bKlEn(MS_BOOL bDscmbKey, MS_BOOL bKlEn)
773 {
774 if(bDscmbKey){ // Key Table
775 u16KeyPara[0] |= ((bKlEn)? 1:0) << CRI_KT_KL_EN;
776 }
777 else{ // Key Slot
778 u16KeyPara[0] |= ((bKlEn)? 1:0) << CRI_KS_KL_EN;
779 }
780 }
781
782