xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvAESDMA.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
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 ///
97 /// @file   drvAESDMA.h
98 /// @brief  AESDMA Driver Interface
99 /// @author MStar Semiconductor,Inc.
100 ///
101 ////////////////////////////////////////////////////////////////////////////////////////////////////
102 
103 
104 /*! \defgroup G_AESDMA AESDMA interface
105     \ingroup  G_CIPHER
106 
107     \brief
108     AESDMA is a DMA ip with En/Decrypt engine. It can Encrypt/Decrypt data transmission between MIU to MIU,
109     parse data header, provide random numbers, calculate SHA and RSA of data.
110 
111     <b>Features</b>
112 
113     - Encrypt/Decrypt Algorithm: AES/DES/Triple DEC + ECB/CBC
114     - SHA1, SHA256
115     - RSA
116     - Hardware parser
117 
118 
119     <b> AESDMA Block Diagram: </b> \n
120 
121     Data  ==>   AESDMA   ==>  En/Decrypted Data  \n
122     Data  ==>   SHA      ==>  Hash Value  \n
123     Data  ==>   RSA      ==>  Decrypted Value  \n
124     Random Number Generatore   ==>  Random number \n
125 
126 
127     \defgroup G_AES_INIT Initialization Task relative
128     \ingroup  G_AESDMA
129     \defgroup G_AES_EnDecrypt En/Decrypt Task relative
130     \ingroup  G_AESDMA
131     \defgroup G_AES_SHA Hash relative
132     \ingroup  G_AESDMA
133     \defgroup G_AES_OTHER  other relative
134     \ingroup  G_AESDMA
135     \defgroup G_AES_ToBeModified AESDMA api to be modified
136     \ingroup  G_AESDMA
137     \defgroup G_AES_ToBeRemove AESDMA api to be removed
138     \ingroup  G_AESDMA
139 */
140 
141 #ifndef _DRVAESDMA_H_
142 #define _DRVAESDMA_H_
143 
144 #ifdef __cplusplus
145 extern "C"
146 {
147 #endif
148 
149 #include "MsTypes.h"
150 #include "MsDevice.h"
151 
152 //--------------------------------------------------------------------------------------------------
153 //  Define
154 //--------------------------------------------------------------------------------------------------
155 #define AES_ENABLE                   0x01
156 #define TDES_ENABLE                  0x10
157 #define WORD_MASK                    0x0000000F
158 #define RSA_INPUT_SIZE               256
159 #define RSA_UNIT_SIZE                4
160 #define SHA_WAIT                     1
161 #if (SHA_WAIT==1)
162 #define SHA_TIMEOUT_VALUE            1200000
163 #endif
164 #define AES_MAX_TIMEOUT_VALUE        0x500000
165 #define RSA_MAX_TIMEOUT_VALUE        0x500000
166 
167 
168 #define MSIF_AESDMA_LIB_CODE                     {'D','M','A','_'}    //Lib code
169 #define MSIF_AESDMA_LIBVER                       {'0','3'}            //LIB version
170 #define MSIF_AESDMA_BUILDNUM                     {'0','3'}            //Build Number
171 #define MSIF_AESDMA_CHANGELIST                   {'0','0','3','3','1','6','3','7'} //P4 ChangeList Number
172 
173 #define AESDMA_DRV_VERSION                 /* Character String for DRV/API version             */  \
174     MSIF_TAG,                           /* 'MSIF'                                           */  \
175     MSIF_CLASS,                         /* '00'                                             */  \
176     MSIF_CUS,                           /* 0x0000                                           */  \
177     MSIF_MOD,                           /* 0x0000                                           */  \
178     MSIF_CHIP,                                                                                  \
179     MSIF_CPU,                                                                                   \
180     MSIF_AESDMA_LIB_CODE,                  /* IP__                                             */  \
181     MSIF_AESDMA_LIBVER,                          /* 0.0 ~ Z.Z                                        */  \
182     MSIF_AESDMA_BUILDNUM,                          /* 00 ~ 99                                          */  \
183     MSIF_AESDMA_CHANGELIST,  /* CL#                                              */  \
184     MSIF_OS
185 
186 /// AESDMA Cipher Mode
187 typedef enum
188 {
189     E_DRVAESDMA_CIPHER_ECB = 0,
190     E_DRVAESDMA_CIPHER_CTR,
191     E_DRVAESDMA_CIPHER_CBC,
192     E_DRVAESDMA_CIPHER_DES_ECB,
193     E_DRVAESDMA_CIPHER_DES_CTR,
194     E_DRVAESDMA_CIPHER_DES_CBC,
195     E_DRVAESDMA_CIPHER_TDES_ECB,
196     E_DRVAESDMA_CIPHER_TDES_CTR,
197     E_DRVAESDMA_CIPHER_TDES_CBC,
198     E_DRVAESDMA_CIPHER_CTS_CBC,
199     E_DRVAESDMA_CIPHER_CTS_ECB,
200     E_DRVAESDMA_CIPHER_DES_CTS_CBC,
201     E_DRVAESDMA_CIPHER_DES_CTS_ECB,
202     E_DRVAESDMA_CIPHER_TDES_CTS_CBC,
203     E_DRVAESDMA_CIPHER_TDES_CTS_ECB,
204 } DrvAESDMA_CipherMode;
205 
206 /// AESDMA HW Parser mode
207 typedef enum
208 {
209     E_DRVAESDMA_PARSER_TS_PKT192 = 0,
210     E_DRVAESDMA_PARSER_TS_PKT192_CLEAR,
211     E_DRVAESDMA_PARSER_TS_PKT188,
212     E_DRVAESDMA_PARSER_TS_PKT188_CLEAR,
213     E_DRVAESDMA_PARSER_HDCP20_PKT192,
214     E_DRVAESDMA_PARSER_HDCP20_PKT192_CLEAR,
215     E_DRVAESDMA_PARSER_HDCP20_PKT188,
216     E_DRVAESDMA_PARSER_HDCP20_PKT188_CLEAR,
217 } DrvAESDMA_ParserMode;
218 
219 typedef enum
220 {
221     E_DRVAESDMA_PARSER_SCRMB_10 = 0,
222     E_DRVAESDMA_PARSER_SCRMB_11,
223     E_DRVAESDMA_PARSER_SCRMB_CLEAR,
224 } DrvAESDMA_ScrmbPattern;
225 
226 /// SHA Mode
227 typedef enum
228 {
229     E_DRVAESDMA_SHA1 = 0,
230     E_DRVAESDMA_SHA256,
231 } DrvAESDMA_SHAMode;
232 
233 /// RSA Mode
234 typedef enum
235 {
236     E_DRVAESDMA_RSA1024_PUBLIC = 0,
237     E_DRVAESDMA_RSA1024_PRIVATE,
238     E_DRVAESDMA_RSA2048_PUBLIC,
239     E_DRVAESDMA_RSA2048_PRIVATE,
240     E_DRVAESDMA_RSA256_PUBLIC,
241     E_DRVAESDMA_RSA256_PRIVATE,
242 } DrvAESDMA_RSAMode;
243 
244 /// RSA HW Key Mode
245 typedef enum
246 {
247     E_DRVAESDMA_RSA_HWKEY_PRIVATE = 0,
248     E_DRVAESDMA_RSA_HWKEY_PUBLIC1,
249     E_DRVAESDMA_RSA_HWKEY_PUBLIC2,
250 } DrvAESDMA_RSAHwKeyMode;
251 
252 /// AESDMA notification event
253 typedef enum //_DrvAESDMA_Event
254 {
255     E_DRVAESDMA_EVENT_DATA_INIT         = 0x00000000,
256     /// DMA Done
257     E_DRVAESDMA_EVENT_DMA_DONE          = 0x00010000,
258     /// DMA Pause
259     E_DRVAESDMA_EVENT_DMA_PAUSE         = 0x00020000,
260 
261 } DrvAESDMA_Event;
262 
263 typedef enum //_DrvTSP_DbgLevel
264 {
265     E_DRVAESDMA_DBG_Release = 0,
266     E_DRVAESDMA_DBG_L1, // display error msg
267     E_DRVAESDMA_DBG_L2, // display error msg and enter while(1)
268 } DrvAESDMA_DbgLevel;
269 
270 typedef enum //_DrvAESDMA_KEY_TYPE
271 {
272     E_DRVAESDMA_ODD_KEY = 0,
273     E_DRVAESDMA_EVEN_KEY,
274 } DrvAESDMA_KEY_TYPE;
275 
276 //--------------------------------------------------------------------------------------------------
277 //  Driver Capability
278 //--------------------------------------------------------------------------------------------------
279 
280 //--------------------------------------------------------------------------------------------------
281 //  Local variable
282 //--------------------------------------------------------------------------------------------------
283 
284 //--------------------------------------------------------------------------------------------------
285 //  Type and Structure
286 //--------------------------------------------------------------------------------------------------
287 /// AESDMA DDI return value
288 typedef MS_U32                         DRVAESDMA_RESULT;
289 
290 typedef struct
291 {
292     MS_U32 u32KeyN[64];
293     MS_U32 u32KeyE[64];
294 
295 }DrvAESDMA_RSAKey;
296 
297 typedef struct
298 {
299     MS_U32 u32Sig[64];
300 
301 }DrvAESDMA_RSASig;
302 
303 typedef struct
304 {
305     MS_U32 u32RSAOut[64];
306 
307 }DrvAESDMA_RSAOut;
308 
309 /// Secure information
310 typedef struct
311 {
312     MS_U32  u32SHMPhyAddr;
313     MS_BOOL bSecureModeEnable;
314     MS_U32  u32SHMSize;
315     MS_U8   u8SHMMiuSel;
316 
317 }DrvAESDMA_SecureInfo;
318 
319 typedef struct
320 {
321     MS_U32 u32Addr;
322     MS_U32 u32Size;
323 }DrvAESDMA_SHADataInfo;
324 
325 typedef enum
326 {
327     E_DRVAESDMA_HASH_STAGE_FIRST ,
328     E_DRVAESDMA_HASH_STAGE_UPDATE ,
329     E_DRVAESDMA_HASH_STAGE_LAST ,
330 }DrvAESDMA_HASH_STAGE;
331 
332 typedef struct
333 {
334     DrvAESDMA_SHAMode   eMode;
335     DrvAESDMA_SHADataInfo  stInput;
336     DrvAESDMA_SHADataInfo  stOutput;
337 }DrvAESDMA_HASHCFG;
338 
339 /// @name DRVAESDMA_RESULT
340 /// @ref DRVAESDMA_RESULT
341 /// return value
342 /// @{
343 #define DRVAESDMA_OK                   0x00000000
344 #define DRVAESDMA_FAIL                 0x00000001
345 #define DRVAESDMA_INVALID_PARAM        0x00000002
346 #define DRVAESDMA_FUNC_ERROR           0x00000003
347 #define DRVAESDMA_MIU_ADDR_ERROR       0x00000004
348 
349 /// @}
350 
351 #define AESDMA_DMA_DONE                     0x00010000
352 #define AESDMA_DMA_PAUSE                    0x00020000
353 #define AESDMA_STATES_GROUP                 (AESDMA_DMA_DONE  | \
354                                              AESDMA_DMA_PAUSE  )
355 
356 #define AESDMA_PARSER_PID_MAX          0x00001FFF
357 /// AESDMA notification function
358 typedef void (*P_DrvAESDMA_EvtCallback)(DrvAESDMA_Event eEvent);
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 // include utopia v2  header files here
362 ////////////////////////////////////////////////////////////////////////////////
363 #include "drvAESDMA_v2.h"
364 
365 //--------------------------------------------------------------------------------------------------
366 //  Function Prototype
367 //--------------------------------------------------------------------------------------------------
368 #ifndef MSOS_TYPE_NUTTX
369 //-------------------------------------------------------------------------------------------------
370 /// SetSecurityInfo
371 /// @ingroup G_AES_OTHER
372 /// @param  pSecureInfo         \b IN: Security information
373 /// @return DRVAESDMA_OK : Success
374 /// @return Others : Fail
375 //-------------------------------------------------------------------------------------------------
376 // DRVAESDMA_RESULT MDrv_AESDMA_SetSecurityInfo(DrvAESDMA_SecureInfo *pSecureInfo);
377 #endif
378 
379 //-------------------------------------------------------------------------------------------------
380 /// Initialize AESDMA
381 /// @ingroup G_AES_INIT
382 /// @param  u32miu0addr         \b IN: MIU0 Base Address (Unused)
383 /// @param  u32miu1addr         \b IN: MIU1 Base Address (Unused)
384 /// @param  u32miunum           \b IN: Numbers of MIU
385 /// @return DRVAESDMA_OK : Success
386 /// @return Others : Fail
387 //-------------------------------------------------------------------------------------------------
388 DRVAESDMA_RESULT MDrv_AESDMA_Init(MS_PHY u32miu0addr , MS_PHY u32miu1addr , MS_U32 u32miunum);
389 //-------------------------------------------------------------------------------------------------
390 /// Check Cihper Mode
391 /// @ingroup G_AES_EnDecrypt
392 /// @param  eMode         \b IN: Cipher Mode
393 /// @return DRVAESDMA_OK : Success
394 /// @return Others : Fail
395 //-------------------------------------------------------------------------------------------------
396 // DRVAESDMA_RESULT MDrv_AESDMA_QueryCipherMode(DrvAESDMA_CipherMode eMode);
397 
398 //-------------------------------------------------------------------------------------------------
399 /// Set Cipher mode and En/Decrypt
400 /// @ingroup G_AES_EnDecrypt
401 /// @param  eMode         \b IN: Cipher Mode
402 /// @param  bDescrypt     \b IN: TRUE: Decrypt, FALSE: Encrypt
403 /// @return DRVAESDMA_OK : Success
404 /// @return Others : Fail
405 //-------------------------------------------------------------------------------------------------
406 DRVAESDMA_RESULT MDrv_AESDMA_SelEng(DrvAESDMA_CipherMode eMode, MS_BOOL bDescrypt);
407 
408 //-------------------------------------------------------------------------------------------------
409 /// Set a set of key to AESDMA
410 /// @ingroup G_AES_EnDecrypt
411 /// @param pu8Key \b IN: The key is represented as vectors of bytes with the MSB first
412 /// @param u32Len \b IN: The byte length of the pu8Key. 16 for AES/TDES and 8 for DES
413 /// @return DRVAESDMA_OK : Success
414 /// @return DRVAESDMA_INVALID_PARAM : Invalid key length
415 /// @return Others : Fail
416 //-------------------------------------------------------------------------------------------------
417 DRVAESDMA_RESULT MDrv_AESDMA_SetKey_Ex(const MS_U8 *pu8Key, MS_U32 u32Len);
418 //-------------------------------------------------------------------------------------------------
419 /// Set IV to the AESDMA
420 /// @ingroup G_AES_EnDecrypt
421 /// @param pu8IV \b IN: The IV is represented as vectors of bytes with the MSB first
422 /// @param u32Len \b IN: The byte length of the pu8IV. 16 for AES and 8 for TDES/DES
423 /// @return DRVAESDMA_OK : Success
424 /// @return DRVAESDMA_INVALID_PARAM : Invalid key length
425 /// @return Others : Fail
426 //-------------------------------------------------------------------------------------------------
427 DRVAESDMA_RESULT MDrv_AESDMA_SetIV_Ex(const MS_U8 *pu8IV, MS_U32 u32Len);
428 
429 //-------------------------------------------------------------------------------------------------
430 /// Set a set of even key to AESDMA
431 /// @ingroup G_AES_EnDecrypt
432 /// @param pCipherKey \b IN: Key set
433 /// @return DRVAESDMA_OK : Success
434 /// @return DRVAESDMA_INVALID_PARAM : Invalid key length
435 /// @return Others : Fail
436 //-------------------------------------------------------------------------------------------------
437 DRVAESDMA_RESULT MDrv_AESDMA_SetKey(MS_U32 *pCipherKey);
438 
439 //-------------------------------------------------------------------------------------------------
440 /// Set Odd/Even Key to AESDMA
441 /// @ingroup G_AES_EnDecrypt
442 /// @param pCipherKey \b IN: Key set
443 /// @param stKeyType \b IN: Enum: E_DRVAESDMA_ODD_KEY, E_DRVAESDMA_EVEN_KEY
444 /// @return DRVAESDMA_OK : Success
445 /// @return Others : Fail
446 //-------------------------------------------------------------------------------------------------
447 // DRVAESDMA_RESULT MDrv_AESDMA_SetKeySel(MS_U32 *pCipherKey, DrvAESDMA_KEY_TYPE stKeyType);
448 //-------------------------------------------------------------------------------------------------
449 /// Set Odd IV to AESDMA
450 /// @ingroup G_AES_EnDecrypt
451 /// @param pCipherKey \b IN: Odd IV
452 /// @return DRVAESDMA_OK : Success
453 /// @return Others : Fail
454 //-------------------------------------------------------------------------------------------------
455 // DRVAESDMA_RESULT MDrv_AESDMA_SetOddIV(MS_U32 *pInitVector);
456 //-------------------------------------------------------------------------------------------------
457 /// Enable Secure Key of AESDMA
458 /// @ingroup G_AES_EnDecrypt
459 /// @return DRVAESDMA_OK : Success
460 /// @return Others : Fail
461 //-------------------------------------------------------------------------------------------------
462 DRVAESDMA_RESULT MDrv_AESDMA_SetSecureKey(void);
463 //-------------------------------------------------------------------------------------------------
464 /// Set a set of default IV (even iv) to AESDMA
465 /// @ingroup G_AES_EnDecrypt
466 /// @param pCipherKey \b IN: IV
467 /// @return DRVAESDMA_OK : Success
468 /// @return Others : Fail
469 //-------------------------------------------------------------------------------------------------
470 DRVAESDMA_RESULT MDrv_AESDMA_SetIV(MS_U32 *pInitVector);
471 //-------------------------------------------------------------------------------------------------
472 /// Set a set of PS Pattern to AESDMA
473 /// @ingroup G_AES_EnDecrypt
474 /// @param u32PTN \b IN: PS Pattern
475 /// @param u32Mask \b IN: Mask
476 /// @param bPSin_Enable \b IN: Bit of In Enable
477 /// @param bPSout_Enable \b IN: Bit of Out Enable
478 /// @return DRVAESDMA_OK : Success
479 /// @return Others : Fail
480 //-------------------------------------------------------------------------------------------------
481 DRVAESDMA_RESULT MDrv_AESDMA_SetPS(MS_U32 u32PTN, MS_U32 u32Mask, MS_BOOL bPSin_Enable, MS_BOOL bPSout_Enable);
482 //-------------------------------------------------------------------------------------------------
483 /// Release PS of AESDMA
484 /// @ingroup G_AES_EnDecrypt
485 /// @return DRVAESDMA_OK : Success
486 /// @return Others : Fail
487 //-------------------------------------------------------------------------------------------------
488 // DRVAESDMA_RESULT MDrv_AESDMA_PSRelease(void);
489 //-------------------------------------------------------------------------------------------------
490 /// Set File in/out address and size to AESDMA
491 /// @ingroup G_AES_EnDecrypt
492 /// @param u32FileinAddr \b IN: Source Address
493 /// @param u32FileInNum \b IN: Size of Data
494 /// @param u32FileOutSAddr \b IN: Dest Start Address
495 /// @param u32FileOutEAddr \b IN: Dest End Address
496 /// @return DRVAESDMA_OK : Success
497 /// @return Others : Fail
498 //-------------------------------------------------------------------------------------------------
499 DRVAESDMA_RESULT MDrv_AESDMA_SetFileInOut(MS_PHY phy64FileinAddr, MS_U32 u32FileInNum, MS_PHY phy64FileOutSAddr, MS_PHY phy64FileOutEAddr);
500 //-------------------------------------------------------------------------------------------------
501 /// Trigger AESDMA engine
502 /// @ingroup G_AES_EnDecrypt
503 /// @return DRVAESDMA_OK : Success
504 /// @return Others : Fail
505 //-------------------------------------------------------------------------------------------------
506 DRVAESDMA_RESULT MDrv_AESDMA_Start(MS_BOOL bStart);
507 
508 //-------------------------------------------------------------------------------------------------
509 /// Reset AESDMA engine
510 /// @ingroup G_AES_INIT
511 /// @return DRVAESDMA_OK : Success
512 /// @return Others : Fail
513 //-------------------------------------------------------------------------------------------------
514 DRVAESDMA_RESULT MDrv_AESDMA_Reset(void);
515 
516 //-------------------------------------------------------------------------------------------------
517 /// Get the status of AESDMA engine
518 /// @ingroup G_AES_EnDecrypt
519 /// @return DRVAESDMA_OK : Ready
520 /// @return Others : Not Ready
521 //-------------------------------------------------------------------------------------------------
522 DRVAESDMA_RESULT MDrv_AESDMA_GetStatus(void);
523 
524 //-------------------------------------------------------------------------------------------------
525 /// Check the status of AESDMA engine
526 /// @ingroup G_AES_EnDecrypt
527 /// @return DRVAESDMA_OK : Done
528 /// @return Others : Not yet
529 //-------------------------------------------------------------------------------------------------
530 DRVAESDMA_RESULT MDrv_AESDMA_IsFinished(void);
531 
532 //-------------------------------------------------------------------------------------------------
533 /// Get the byte count of PS matched.
534 /// @ingroup G_AES_EnDecrypt
535 /// @return Numbers of byte counts.
536 //-------------------------------------------------------------------------------------------------
537 // MS_U32 MDrv_AESDMA_GetPSMatchedByteCNT(void);
538 
539 //-------------------------------------------------------------------------------------------------
540 /// Get the byte count of PTN matched.
541 /// @ingroup G_AES_EnDecrypt
542 /// @return Numbers of byte counts.
543 //-------------------------------------------------------------------------------------------------
544 // MS_U32 MDrv_AESDMA_GetPSMatchedPTN(void);
545 
546 //-------------------------------------------------------------------------------------------------
547 /// Call back function of AESDMA interrupt.
548 /// @ingroup G_AES_OTHER
549 /// @param eEvents \b IN: Interrupt event
550 /// @param pfCallback \b OUT: pointer of callback function
551 /// @return DRVAESDMA_OK : Success
552 /// @return Others : Fail
553 //-------------------------------------------------------------------------------------------------
554 DRVAESDMA_RESULT MDrv_AESDMA_Notify(DrvAESDMA_Event eEvents, P_DrvAESDMA_EvtCallback pfCallback);
555 
556 //-------------------------------------------------------------------------------------------------
557 /// Set debug level
558 /// @ingroup G_AES_OTHER
559 /// @param DbgLevel \b IN: Interrupt event
560 /// @return DRVAESDMA_OK : Success
561 /// @return Others : Fail
562 //-------------------------------------------------------------------------------------------------
563 DRVAESDMA_RESULT MDrv_AESDMA_SetDbgLevel(DrvAESDMA_DbgLevel DbgLevel);
564 
565 //-------------------------------------------------------------------------------------------------
566 /// Get library version
567 /// @ingroup G_AES_OTHER
568 /// @param ppVersion \b OUT: version
569 /// @return DRVAESDMA_OK : Success
570 /// @return Others : Fail
571 //-------------------------------------------------------------------------------------------------
572 // DRVAESDMA_RESULT MDrv_AESDMA_GetLibVer(const MSIF_Version **ppVersion);
573 
574 //-------------------------------------------------------------------------------------------------
575 /// Get random numbers.
576 /// @ingroup G_AES_OTHER
577 /// @param u32PABuf \b OUT: an array of random numbers.
578 /// @param u32Size \b IN: Array size
579 /// @return DRVAESDMA_OK : Success
580 /// @return Others : Fail
581 //-------------------------------------------------------------------------------------------------
582 DRVAESDMA_RESULT MDrv_AESDMA_Rand(MS_U32 *u32PABuf, MS_U32 u32Size);
583 
584 //-------------------------------------------------------------------------------------------------
585 /// Enable/Disable Clock
586 /// @ingroup G_AES_INIT
587 /// @param benable \b IN: TRUE: Enable, FALSE: Disable
588 /// @return DRVAESDMA_OK : Success
589 /// @return Others : Fail
590 //-------------------------------------------------------------------------------------------------
591 DRVAESDMA_RESULT MDrv_AESDMA_Set_Clk(MS_BOOL benable);
592 //-------------------------------------------------------------------------------------------------
593 /// Calculate SHA
594 /// @ingroup G_AES_SHA
595 /// @param eMode \b IN: SHA Mode
596 /// @param u32PAInBuf \b IN: Source address of data
597 /// @param u32Size \b IN: Size of data
598 /// @param u32PAOutBuf \b IN: out hash address
599 /// @return DRVAESDMA_OK : Success
600 /// @return Others : Fail
601 //-------------------------------------------------------------------------------------------------
602 DRVAESDMA_RESULT MDrv_SHA_Calculate(DrvAESDMA_SHAMode eMode, MS_PHY phy64PAInBuf, MS_U32 u32Size, MS_PHY phy64PAOutBuf);
603 //-------------------------------------------------------------------------------------------------
604 /// Calculate Manual SHA
605 /// @ingroup G_AES_SHA
606 /// @param stCfg \b IN: SHA Config
607 /// @param eStage \b IN: SHA Stage
608 /// @param u32DoneBytes \b IN: Size
609 /// @param pu8SetIV \b IN: Init value
610 /// @return DRVAESDMA_OK : Success
611 /// @return Others : Fail
612 //-------------------------------------------------------------------------------------------------
613 // DRVAESDMA_RESULT MDrv_SHA_CalculateManual(DrvAESDMA_HASHCFG stCfg, DrvAESDMA_HASH_STAGE eStage, MS_U32 u32DoneBytes, MS_U8 *pu8SetIV);
614 //-------------------------------------------------------------------------------------------------
615 /// MOBF
616 /// @ingroup G_AES_ToBeRemove
617 /// @return DRVAESDMA_OK : Success
618 /// @return Others : Fail
619 //-------------------------------------------------------------------------------------------------
620 // DRVAESDMA_RESULT MDrv_MOBF_DmaOnly(void);
621 
622 //-------------------------------------------------------------------------------------------------
623 /// MOBF Encrypt
624 /// @ingroup G_AES_ToBeRemove
625 /// @param u32Key \b IN: Key
626 /// @param bEnable \b IN: TRUE/FLASE
627 /// @return DRVAESDMA_OK : Success
628 /// @return Others : Fail
629 //-------------------------------------------------------------------------------------------------
630 // DRVAESDMA_RESULT MDrv_MOBF_Encrypt(MS_U32 u32Key, MS_BOOL bEnable);
631 
632 //-------------------------------------------------------------------------------------------------
633 /// MOBF Decrypt
634 /// @ingroup G_AES_ToBeRemove
635 /// @param u32Key \b IN: Key
636 /// @param bEnable \b IN: TRUE/FLASE
637 /// @return DRVAESDMA_OK : Success
638 /// @return Others : Fail
639 //-------------------------------------------------------------------------------------------------
640 // DRVAESDMA_RESULT MDrv_MOBF_Decrypt(MS_U32 u32Key, MS_BOOL bEnable);
641 
642 //-------------------------------------------------------------------------------------------------
643 /// MOBF Oneway
644 /// @ingroup G_AES_ToBeRemove
645 /// @return DRVAESDMA_OK : Success
646 /// @return Others : Fail
647 //-------------------------------------------------------------------------------------------------
648 // DRVAESDMA_RESULT MDrv_MOBF_OneWay(void);
649 
650 //-------------------------------------------------------------------------------------------------
651 /// NA
652 /// @ingroup G_AES_EnDecrypt
653 /// @return DRVAESDMA_OK : Success
654 /// @return Others : Fail
655 //-------------------------------------------------------------------------------------------------
656 DRVAESDMA_RESULT MDrv_AESDMA_Parser_MaskScrmb(MS_BOOL bEnable);
657 
658 //-------------------------------------------------------------------------------------------------
659 /// NA
660 /// @ingroup G_AES_EnDecrypt
661 /// @return DRVAESDMA_OK : Success
662 /// @return Others : Fail
663 //-------------------------------------------------------------------------------------------------
664 DRVAESDMA_RESULT MDrv_AESDMA_Parser_SetScrmbPattern(DrvAESDMA_ScrmbPattern ePattern);
665 
666 //-------------------------------------------------------------------------------------------------
667 /// NA
668 /// @ingroup G_AES_EnDecrypt
669 /// @return DRVAESDMA_OK : Success
670 /// @return Others : Fail
671 //-------------------------------------------------------------------------------------------------
672 DRVAESDMA_RESULT MDrv_AESDMA_Parser_SetAddedScrmbPattern(DrvAESDMA_ScrmbPattern ePattern);
673 
674 //-------------------------------------------------------------------------------------------------
675 /// NA
676 /// @ingroup G_AES_OTHER
677 /// @return DRVAESDMA_OK : Success
678 /// @return Others : Fail
679 //-------------------------------------------------------------------------------------------------
680 // MS_U8 MDrv_AESDMA_Parser_QueryPidCount(void);
681 
682 //-------------------------------------------------------------------------------------------------
683 /// NA
684 /// @ingroup G_AES_EnDecrypt
685 /// @return DRVAESDMA_OK : Success
686 /// @return Others : Fail
687 //-------------------------------------------------------------------------------------------------
688 // DRVAESDMA_RESULT MDrv_AESDMA_Parser_SetPid(MS_U8 u8Index, MS_U16 u16Pid);
689 
690 //-------------------------------------------------------------------------------------------------
691 /// NA
692 /// @ingroup G_AES_EnDecrypt
693 /// @return DRVAESDMA_OK : Success
694 /// @return Others : Fail
695 //-------------------------------------------------------------------------------------------------
696 DRVAESDMA_RESULT MDrv_AESDMA_Parser_BypassPid(MS_BOOL bEnable);
697 
698 //-------------------------------------------------------------------------------------------------
699 /// NA
700 /// @ingroup G_AES_EnDecrypt
701 /// @return DRVAESDMA_OK : Success
702 /// @return Others : Fail
703 //-------------------------------------------------------------------------------------------------
704 DRVAESDMA_RESULT MDrv_AESDMA_Parser_Encrypt(DrvAESDMA_ParserMode eMode);
705 
706 //-------------------------------------------------------------------------------------------------
707 /// NA
708 /// @ingroup G_AES_EnDecrypt
709 /// @return DRVAESDMA_OK : Success
710 /// @return Others : Fail
711 //-------------------------------------------------------------------------------------------------
712 DRVAESDMA_RESULT MDrv_AESDMA_Parser_Decrypt(DrvAESDMA_ParserMode eMode);
713 
714 //-------------------------------------------------------------------------------------------------
715 /// NA
716 /// @ingroup G_AES_OTHER
717 /// @return DRVAESDMA_OK : Success
718 /// @return Others : Fail
719 //-------------------------------------------------------------------------------------------------
720 // MS_BOOL MDrv_AESDMA_Lock(void);
721 
722 //-------------------------------------------------------------------------------------------------
723 /// NA
724 /// @ingroup G_AES_OTHER
725 /// @return DRVAESDMA_OK : Success
726 /// @return Others : Fail
727 //-------------------------------------------------------------------------------------------------
728 // MS_BOOL MDrv_AESDMA_Unlock(void);
729 
730 //-------------------------------------------------------------------------------------------------
731 /// NA
732 /// @ingroup G_AES_EnDecrypt
733 /// @return DRVAESDMA_OK : Success
734 /// @return Others : Fail
735 //-------------------------------------------------------------------------------------------------
736 // DRVAESDMA_RESULT MDrv_RSA_Calculate(DrvAESDMA_RSASig *pstSign, DrvAESDMA_RSAKey *pstKey, DrvAESDMA_RSAMode eMode);
737 //-------------------------------------------------------------------------------------------------
738 /// NA
739 /// @ingroup G_AES_EnDecrypt
740 /// @return DRVAESDMA_OK : Success
741 /// @return Others : Fail
742 //-------------------------------------------------------------------------------------------------
743 // DRVAESDMA_RESULT MDrv_RSA_Calculate_Hw_Key(DrvAESDMA_RSASig *pstSign, DrvAESDMA_RSAHwKeyMode eMode);
744 // DRVAESDMA_RESULT MDrv_RSA_IsFinished(void);
745 
746 //-------------------------------------------------------------------------------------------------
747 /// NA
748 /// @ingroup G_AES_EnDecrypt
749 /// @return DRVAESDMA_OK : Success
750 /// @return Others : Fail
751 //-------------------------------------------------------------------------------------------------
752 // DRVAESDMA_RESULT MDrv_RSA_Output(DrvAESDMA_RSAMode eMode, DrvAESDMA_RSAOut *pstRSAOut);
753 
754 //-------------------------------------------------------------------------------------------------
755 /// NA
756 /// @ingroup G_AES_OTHER
757 /// @return DRVAESDMA_OK : Success
758 /// @return Others : Fail
759 //-------------------------------------------------------------------------------------------------
760 MS_U32 MDrv_AESDMA_SetPowerState(EN_POWER_MODE u16PowerState);
761 
762 //-------------------------------------------------------------------------------------------------
763 /// NA
764 /// @ingroup G_AES_OTHER
765 /// @return DRVAESDMA_OK : Success
766 /// @return Others : Fail
767 //-------------------------------------------------------------------------------------------------
768 // DRVAESDMA_RESULT MDrv_AESDMA_IsSecretKeyInNormalBank(void);
769 
770 //-------------------------------------------------------------------------------------------------
771 /// NA
772 /// @ingroup G_AES_INIT
773 /// @return DRVAESDMA_OK : Success
774 /// @return Others : Fail
775 //-------------------------------------------------------------------------------------------------
776 // DRVAESDMA_RESULT MDrv_AESDMA_NormalReset(void);
777 
778 //-------------------------------------------------------------------------------------------------
779 /// NA
780 /// @ingroup G_AES_OTHER
781 /// @return DRVAESDMA_OK : Success
782 /// @return Others : Fail
783 //-------------------------------------------------------------------------------------------------
784 // DRVAESDMA_RESULT MDrv_HDCP_ProcessCipher(MS_U8 u8Idx, MS_U8* pu8Riv, MS_U8 *pu8ContentKey);
785 
786 //-------------------------------------------------------------------------------------------------
787 /// NA
788 /// @ingroup G_AES_OTHER
789 /// @return DRVAESDMA_OK : Success
790 /// @return Others : Fail
791 //-------------------------------------------------------------------------------------------------
792 // DRVAESDMA_RESULT MDrv_HDCP_GetHdcpCipherState(MS_U8 u8Idx, MS_U8 *pu8State);
793 
794 //reserved for secure protect function
795 /*
796 DRVAESDMA_RESULT MDrv_AESDMA_SecureSetKey(MS_U32 *pCipherKey);
797 DRVAESDMA_RESULT MDrv_AESDMA_SecureProtect(MS_BOOL bEnable);
798 DRVAESDMA_RESULT MDrv_AESDMA_SecureSetIV(MS_U32 *pInitVector);
799 DRVAESDMA_RESULT MDrv_AESDMA_SetFileOutEnable(MS_BOOL bEnable);
800 DRVAESDMA_RESULT MDrv_AESDMA_SecureStart(MS_BOOL bStart);
801 DRVAESDMA_RESULT MDrv_AESDMA_SecureIsFinished(void);
802 */
803 #ifdef __cplusplus
804 }
805 #endif
806 
807 
808 #endif // _DRVAESDMA_H_
809