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) 2008-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 #ifndef _DRVAESDMA_PRIV_H_ 95 #define _DRVAESDMA_PRIV_H_ 96 97 #ifdef __cplusplus 98 extern "C" 99 { 100 #endif 101 102 #include "MsTypes.h" 103 #include "drvCIPHER.h" 104 105 106 typedef MS_U32 (*IOCTL_AESDMA_INIT)(MS_PHY, MS_PHY, MS_U32); 107 typedef MS_U32 (*IOCTL_AESDMA_SETIV)(MS_U32 *); 108 typedef MS_U32 (*IOCTL_AESDMA_RESET)(void); 109 typedef MS_U32 (*IOCTL_AESDMA_SETFILEINOUT)(MS_PHY, MS_U32, MS_PHY, MS_PHY); 110 typedef MS_U32 (*IOCTL_AESDMA_SETKEY)(MS_U32 *); 111 typedef MS_U32 (*IOCTL_AESDMA_SELENG)(DrvAESDMA_CipherMode, MS_BOOL); 112 typedef MS_U32 (*IOCTL_AESDMA_START)(MS_BOOL); 113 typedef MS_U32 (*IOCTL_AESDMA_GETSTATUS)(MS_U32 *); 114 typedef MS_U32 (*IOCTL_AESDMA_ISFINISHED)(MS_U32 *); 115 typedef MS_U32 (*IOCTL_AESDMA_SETSECUREKEY)(void); 116 typedef MS_U32 (*IOCTL_AESDMA_SETPS)(MS_U32, MS_U32, MS_BOOL, MS_BOOL); 117 typedef MS_U32 (*IOCTL_AESDMA_PSRELEASE)(void); 118 typedef MS_U32 (*IOCTL_AESDMA_GETPSMATCHEDBYTECNT)(MS_U32 *); 119 typedef MS_U32 (*IOCTL_AESDMA_GETPSMATCHEDPTN)(void); 120 typedef MS_U32 (*IOCTL_AESDMA_NOTIFY)(DrvAESDMA_Event, P_DrvAESDMA_EvtCallback); 121 typedef MS_U32 (*IOCTL_AESDMA_RAND)(MS_U32 *, MS_U32); 122 typedef MS_U32 (*IOCTL_RSA_CALCULATE)(DrvAESDMA_RSASig *, DrvAESDMA_RSAKey *, DrvAESDMA_RSAMode); 123 typedef MS_U32 (*IOCTL_RSA_ISFINISHED)(void); 124 typedef MS_U32 (*IOCTL_RSA_OUTPUT)(DrvAESDMA_RSAMode, DrvAESDMA_RSAOut *); 125 typedef MS_U32 (*IOCTL_SHA_CALCULATE)(DrvAESDMA_SHAMode, MS_PHY, MS_U32, MS_PHY); 126 typedef MS_U32 (*IOCTL_SHA_CALCULATE_MANUAL)(DrvAESDMA_HASHCFG, DrvAESDMA_HASH_STAGE, MS_U32, MS_U8 *); 127 typedef MS_U32 (*IOCTL_AESDMA_SETKEY_EX)(const MS_U8 *, MS_U32); 128 typedef MS_U32 (*IOCTL_AESDMA_SETIV_EX)(const MS_U8 *, MS_U32); 129 typedef MS_U32 (*IOCTL_AESDMA_SETDEFAULTCAVID)(MS_U32); 130 typedef MS_U32 (*IOCTL_AESDMA_SETKEYINDEX)(MS_U32 , MS_BOOL); 131 typedef MS_U32 (*IOCTL_AESDMA_ALLOCKEYSLOT)(MS_U32 *); 132 typedef MS_U32 (*IOCTL_AESDMA_FREEKEYSLOT)(MS_U32); 133 typedef MS_U32 (*IOCTL_AESDMA_INITBYSWFLAG)(MS_BOOL); 134 135 typedef struct _AESDMA_RESOURCE_PRIVATE 136 { 137 MS_U32 AES_Dummy; 138 }AESDMA_RESOURCE_PRIVATE; 139 140 typedef struct _SHA_RESOURCE_PRIVATE 141 { 142 MS_U32 SHA_Dummy; 143 }SHA_RESOURCE_PRIVATE; 144 145 typedef struct _RSA_RESOURCE_PRIVATE 146 { 147 MS_U32 RSA_Dummy; 148 }RSA_RESOURCE_PRIVATE; 149 150 typedef struct _DRVAESDMA_RESOURCE_PRIVATE 151 { 152 MS_BOOL bInited_Drv; 153 } DRVAESDMA_RESOURCE_PRIVATE; 154 155 typedef struct _AESDMA_RESOURCE_SHARED 156 { 157 void* pAESResource; 158 }AESDMA_RESOURCE_SHARED; 159 160 typedef struct _RSA_RESOURCE_SHARED 161 { 162 void* pRSAResource; 163 }RSA_RESOURCE_SHARED; 164 165 typedef enum { 166 E_AESDMA_RESOURCE, 167 } eAESDMAResourceId; 168 169 typedef struct _AESDMA_INSTANT_PRIVATE 170 { 171 MS_U8 InitVector[16]; 172 MS_U32 u32IVLen; 173 MS_U32 u32FileinAddr; 174 MS_U32 u32FileInNum; 175 MS_U32 u32FileOutSAddr; 176 MS_U32 u32FileOutEAddr; 177 MS_VIRT ptrKey; 178 MS_U8 CipherKey[16]; 179 MS_U32 u32KeyLen; 180 MS_U32 u32KeyIndex; 181 MS_BOOL bOddKey; 182 MS_U32 u32Mode; 183 MS_BOOL bDescrypt; 184 MS_BOOL bSecretKey; 185 MS_U32 u32CmdId; 186 MS_U32 u32CAVid; 187 MS_U8 u8KeySlotUsage[4]; 188 IOCTL_AESDMA_INIT fpAESDMAInit; 189 IOCTL_AESDMA_SETIV fpAESDMASetIV; 190 IOCTL_AESDMA_RESET fpAESDMAReset; 191 IOCTL_AESDMA_SETFILEINOUT fpAESDMASetFileInOut; 192 IOCTL_AESDMA_SETKEY fpAESDMASetKey; 193 IOCTL_AESDMA_SELENG fpAESDMASelEng; 194 IOCTL_AESDMA_START fpAESDMAStart; 195 IOCTL_AESDMA_GETSTATUS fpAESDMAGetStatus; 196 IOCTL_AESDMA_ISFINISHED fpAESDMAIsFinished; 197 IOCTL_AESDMA_SETSECUREKEY fpAESDMASetSecureKey; 198 IOCTL_AESDMA_SETPS fpAESDMASetPS; 199 IOCTL_AESDMA_PSRELEASE fpAESDMAPSRelease; 200 IOCTL_AESDMA_GETPSMATCHEDBYTECNT fpAESDMAGetPSMatchedByteCNT; 201 IOCTL_AESDMA_GETPSMATCHEDPTN fpAESDMAGetPSMatchedPTN; 202 IOCTL_AESDMA_NOTIFY fpAESDMANotify; 203 IOCTL_AESDMA_RAND fpAESDMARand; 204 IOCTL_RSA_CALCULATE fpRSACalculate; 205 IOCTL_RSA_ISFINISHED fpRSAIsFinished; 206 IOCTL_RSA_OUTPUT fpRSAOutput; 207 IOCTL_SHA_CALCULATE fpSHACalculate; 208 IOCTL_SHA_CALCULATE_MANUAL fpSHACalculateManual; 209 IOCTL_AESDMA_SETKEY_EX fpAESDMASetKey_Ex; 210 IOCTL_AESDMA_SETIV_EX fpAESDMASetIV_Ex; 211 IOCTL_AESDMA_SETDEFAULTCAVID fpAESDMASetDefaultCAVid; 212 IOCTL_AESDMA_SETKEYINDEX fpAESDMASetKeyIndex; 213 IOCTL_AESDMA_ALLOCKEYSLOT fpAESDMAAllocKeySlot; 214 IOCTL_AESDMA_FREEKEYSLOT fpAESDMAFreeKeySlot; 215 IOCTL_AESDMA_INITBYSWFLAG fpAESDMAInitBySWFlag; 216 }AESDMA_INSTANT_PRIVATE; 217 218 void AESDMARegisterToUtopia(FUtopiaOpen ModuleType); 219 MS_U32 AESDMAOpen(void** pInstantTmp, MS_U32 u32ModuleVersion, void* pAttribute); 220 MS_U32 AESDMAClose(void* pInstantTmp); 221 MS_U32 AESDMAIoctl(void* pInstantTmp, MS_U32 u32Cmd, void* pArgs); 222 223 DRVAESDMA_RESULT _MDrv_AESDMA_Init(MS_PHY u32miu0addr , MS_PHY u32miu1addr , MS_U32 u32miunum); 224 DRVAESDMA_RESULT _MDrv_AESDMA_InitBySWFlag(MS_BOOL bSWInit); 225 DRVAESDMA_RESULT _MDrv_AESDMA_QueryCipherMode(DrvAESDMA_CipherMode eMode); 226 DRVAESDMA_RESULT _MDrv_AESDMA_SelEng(DrvAESDMA_CipherMode eMode, MS_BOOL bDescrypt); 227 DRVAESDMA_RESULT _MDrv_AESDMA_SetKey_Ex(const MS_U8 *pu8Key, MS_U32 u32Len); 228 DRVAESDMA_RESULT _MDrv_AESDMA_SetIV_Ex(const MS_U8 *pu8IV, MS_U32 u32Len); 229 DRVAESDMA_RESULT _MDrv_AESDMA_SetKey(MS_U32 *pCipherKey); 230 DRVAESDMA_RESULT _MDrv_AESDMA_SetSecureKey(void); 231 DRVAESDMA_RESULT _MDrv_AESDMA_SetIV(MS_U32 *pInitVector); 232 DRVAESDMA_RESULT _MDrv_AESDMA_SetPS(MS_U32 u32PTN, MS_U32 u32Mask, MS_BOOL bPSin_Enable, MS_BOOL bPSout_Enable); 233 DRVAESDMA_RESULT _MDrv_AESDMA_PSRelease(void); 234 DRVAESDMA_RESULT _MDrv_AESDMA_SetFileInOut(MS_PHY u32FileinAddr, MS_U32 u32FileInNum, MS_PHY u32FileOutSAddr, MS_PHY u32FileOutEAddr); 235 DRVAESDMA_RESULT _MDrv_AESDMA_Start(MS_BOOL bStart); 236 DRVAESDMA_RESULT _MDrv_AESDMA_Reset(void); 237 DRVAESDMA_RESULT _MDrv_AESDMA_GetStatus(MS_U32 *u32RetVal); 238 DRVAESDMA_RESULT _MDrv_AESDMA_IsFinished(MS_U32 *u32RetVal); 239 MS_U32 _MDrv_AESDMA_GetPSMatchedByteCNT(MS_U32 *u32RetVal); 240 MS_U32 _MDrv_AESDMA_GetPSMatchedPTN(void); 241 DRVAESDMA_RESULT _MDrv_AESDMA_Notify(DrvAESDMA_Event eEvents, P_DrvAESDMA_EvtCallback pfCallback); 242 DRVAESDMA_RESULT _MDrv_AESDMA_SetDbgLevel(DrvAESDMA_DbgLevel DbgLevel); 243 DRVAESDMA_RESULT _MDrv_AESDMA_GetLibVer(const MSIF_Version **ppVersion); 244 DRVAESDMA_RESULT _MDrv_AESDMA_Rand(MS_U32 *u32PABuf, MS_U32 u32Size); 245 DRVAESDMA_RESULT _MDrv_SHA_Calculate(DrvAESDMA_SHAMode eMode, MS_PHY u32PAInBuf, MS_U32 u32Size, MS_PHY u32PAOutBuf); 246 DRVAESDMA_RESULT _MDrv_SHA_CalculateManual(DrvAESDMA_HASHCFG stCfg, DrvAESDMA_HASH_STAGE eStage, MS_U32 u32DoneBytes, MS_U8 *pu8SetIV); 247 DRVAESDMA_RESULT _MDrv_MOBF_DmaOnly(void); 248 DRVAESDMA_RESULT _MDrv_MOBF_Encrypt(MS_U32 u32Key, MS_BOOL bEnable); 249 DRVAESDMA_RESULT _MDrv_MOBF_Decrypt(MS_U32 u32Key, MS_BOOL bEnable); 250 DRVAESDMA_RESULT _MDrv_MOBF_OneWay(void); 251 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_MaskScrmb(MS_BOOL bEnable); 252 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_SetScrmbPattern(DrvAESDMA_ScrmbPattern ePattern); 253 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_SetAddedScrmbPattern(DrvAESDMA_ScrmbPattern ePattern); 254 MS_U8 _MDrv_AESDMA_Parser_QueryPidCount(MS_U8* retCount); 255 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_SetPid(MS_U8 u8Index, MS_U16 u16Pid); 256 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_BypassPid(MS_BOOL bEnable); 257 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_Encrypt(DrvAESDMA_ParserMode eMode); 258 DRVAESDMA_RESULT _MDrv_AESDMA_Parser_Decrypt(DrvAESDMA_ParserMode eMode); 259 MS_BOOL _MDrv_AESDMA_Lock(void); 260 MS_BOOL _MDrv_AESDMA_Unlock(void); 261 DRVAESDMA_RESULT _MDrv_AESDMA_SetDefaultCAVid(MS_U32 u32CAVid); 262 DRVAESDMA_RESULT _MDrv_AESDMA_SetKeyIndex (MS_U32 u32Index, MS_BOOL bIsOddKey); 263 DRVAESDMA_RESULT _MDrv_AESDMA_AllocKeySlot (MS_U32 *pu32Index); 264 DRVAESDMA_RESULT _MDrv_AESDMA_FreeKeySlot (MS_U32 u32Index); 265 DRVAESDMA_RESULT _MDrv_RSA_Calculate(DrvAESDMA_RSASig *pstSign, DrvAESDMA_RSAKey *pstKey, DrvAESDMA_RSAMode eMode); 266 DRVAESDMA_RESULT _MDrv_RSA_Calculate_Hw_Key(DrvAESDMA_RSASig *pstSign, DrvAESDMA_RSAHwKeyMode eMode); 267 DRVAESDMA_RESULT _MDrv_RSA_IsFinished(void); 268 DRVAESDMA_RESULT _MDrv_RSA_Output(DrvAESDMA_RSAMode eMode, DrvAESDMA_RSAOut *pstRSAOut); 269 270 #ifdef __cplusplus 271 } 272 #endif 273 #endif // _DRVAESDMA_PRIV_H_ 274