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 "drvAESDMA.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_SETCLK)(MS_BOOL); 116 typedef MS_U32 (*IOCTL_AESDMA_SETSECUREKEY)(void); 117 typedef MS_U32 (*IOCTL_AESDMA_SETPS)(MS_U32, MS_U32, MS_BOOL, MS_BOOL); 118 typedef MS_U32 (*IOCTL_AESDMA_PSRELEASE)(void); 119 typedef MS_U32 (*IOCTL_AESDMA_GETPSMATCHEDBYTECNT)(MS_U32 *); 120 typedef MS_U32 (*IOCTL_AESDMA_GETPSMATCHEDPTN)(void); 121 typedef MS_U32 (*IOCTL_AESDMA_NOTIFY)(DrvAESDMA_Event, P_DrvAESDMA_EvtCallback); 122 typedef MS_U32 (*IOCTL_AESDMA_RAND)(MS_U32 *, MS_U32); 123 typedef MS_U32 (*IOCTL_AESDMA_GET_RAND_NUM)(MS_U8 *); 124 typedef MS_U32 (*IOCTL_RSA_CALCULATE)(DrvAESDMA_RSASig *, DrvAESDMA_RSAKey *, DrvAESDMA_RSAMode); 125 typedef MS_U32 (*IOCTL_RSA_ISFINISHED)(void); 126 typedef MS_U32 (*IOCTL_RSA_OUTPUT)(DrvAESDMA_RSAMode, DrvAESDMA_RSAOut *); 127 typedef MS_U32 (*IOCTL_SHA_CALCULATE)(DrvAESDMA_SHAMode, MS_PHY, MS_U32, MS_PHY); 128 typedef MS_U32 (*IOCTL_SHA_CALCULATE_MANUAL)(DrvAESDMA_HASHCFG, DrvAESDMA_HASH_STAGE, MS_U32, MS_U8 *); 129 typedef MS_U32 (*IOCTL_AESDMA_PARSER_MASKSCRMB)(MS_BOOL); 130 typedef MS_U32 (*IOCTL_AESDMA_PARSER_SETSCRMBPATTERN)(DrvAESDMA_ScrmbPattern); 131 typedef MS_U32 (*IOCTL_AESDMA_PARSER_SETADDEDSCRMBPATTERN)(DrvAESDMA_ScrmbPattern); 132 typedef MS_U32 (*IOCTL_AESDMA_PARSER_BYPASSPID)(MS_BOOL); 133 typedef MS_U32 (*IOCTL_AESDMA_PARSER_SETPID)(MS_U8, MS_U16); 134 typedef MS_U32 (*IOCTL_AESDMA_PARSER_ENCRYPT)(DrvAESDMA_ParserMode); 135 typedef MS_U32 (*IOCTL_AESDMA_PARSER_DECRYPT)(DrvAESDMA_ParserMode); 136 typedef MS_U8 (*IOCTL_AESDMA_QUERYPIDCOUNT)(MS_U8 *); 137 typedef MS_U32 (*IOCTL_AESDMA_SETKEYSEL)(MS_U32 *pCipherKey, DrvAESDMA_KEY_TYPE stKeyType); 138 typedef MS_U32 (*IOCTL_AESDMA_SETODDIV)(MS_U32 *pInitVector); 139 typedef MS_U32 (*IOCTL_IS_SECRETKEYINNORMALBLANK)(MS_U8 *); 140 141 typedef MS_U32 (*IOCTL_HDCP_PROCESSCIPHER)(MS_U8 , MS_U8*, MS_U8*); 142 143 typedef MS_U32 (*IOCTL_HDCP_GETHDCPCIPHERSTATE)(MS_U8 , MS_U8*); 144 145 typedef MS_U32 (*IOCTL_AESDMA_SETKEYINDEX)(MS_U32, MS_BOOL); 146 147 typedef MS_U32 (*IOCTL_AESDMA_SETAESCTR64)(MS_BOOL); 148 149 typedef MS_U32 (*IOCTL_AESDMA_SETSECUREKEYINDEX)(MS_U8); 150 151 typedef struct _AESDMA_RESOURCE_PRIVATE 152 { 153 MS_U32 AES_Dummy; 154 }AESDMA_RESOURCE_PRIVATE; 155 156 typedef struct _SHA_RESOURCE_PRIVATE 157 { 158 MS_U32 SHA_Dummy; 159 }SHA_RESOURCE_PRIVATE; 160 161 typedef struct _RSA_RESOURCE_PRIVATE 162 { 163 MS_U32 RSA_Dummy; 164 }RSA_RESOURCE_PRIVATE; 165 166 typedef struct _AESDMA_RESOURCE_SHARED 167 { 168 void* pAESResource; 169 }AESDMA_RESOURCE_SHARED; 170 171 typedef struct _RSA_RESOURCE_SHARED 172 { 173 void* pRSAResource; 174 }RSA_RESOURCE_SHARED; 175 176 typedef struct _AESDMA_INSTANT_PRIVATE 177 { 178 MS_U8 InitVector[16]; 179 MS_PHY u32FileinAddr; 180 MS_U32 u32FileInNum; 181 MS_PHY u32FileOutSAddr; 182 MS_PHY u32FileOutEAddr; 183 MS_U8 CipherKey[16]; 184 DrvAESDMA_CipherMode eMode; 185 MS_BOOL bDescrypt; 186 MS_BOOL bSecretKey; 187 IOCTL_AESDMA_INIT fpAESDMAInit; 188 IOCTL_AESDMA_SETIV fpAESDMASetIV; 189 IOCTL_AESDMA_RESET fpAESDMAReset; 190 IOCTL_AESDMA_SETFILEINOUT fpAESDMASetFileInOut; 191 IOCTL_AESDMA_SETKEY fpAESDMASetKey; 192 IOCTL_AESDMA_SELENG fpAESDMASelEng; 193 IOCTL_AESDMA_START fpAESDMAStart; 194 IOCTL_AESDMA_GETSTATUS fpAESDMAGetStatus; 195 IOCTL_AESDMA_ISFINISHED fpAESDMAIsFinished; 196 IOCTL_AESDMA_SETCLK fpAESDMASetClk; 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_AESDMA_GET_RAND_NUM fpAESDMAGetRandNum; 205 IOCTL_RSA_CALCULATE fpRSACalculate; 206 IOCTL_RSA_ISFINISHED fpRSAIsFinished; 207 IOCTL_RSA_OUTPUT fpRSAOutput; 208 IOCTL_SHA_CALCULATE fpSHACalculate; 209 IOCTL_SHA_CALCULATE_MANUAL fpSHACalculateManual; 210 211 DrvAESDMA_ScrmbPattern eScrmbPattern; 212 DrvAESDMA_ScrmbPattern eAddedScrmbPattern; 213 DrvAESDMA_ParserMode eParserMode; 214 MS_BOOL bParserDecrypt; 215 MS_BOOL bMaskScrmb; 216 MS_BOOL bBypassPid; 217 MS_U8 u8PidIndex; //1st PID, 0x122C_01 218 MS_U32 u16Pid; //1st PID, 0x122C_01 219 220 IOCTL_AESDMA_PARSER_MASKSCRMB fpAESDMAParserMaskscrmb; 221 IOCTL_AESDMA_PARSER_SETSCRMBPATTERN fpAESDMAParserSetScrmbPatten; 222 IOCTL_AESDMA_PARSER_BYPASSPID fpAESDMAParserBypassPid; 223 IOCTL_AESDMA_PARSER_SETPID fpAESDMAParserSetPid; 224 IOCTL_AESDMA_PARSER_ENCRYPT fpAESDMAParserEncrypt; 225 IOCTL_AESDMA_PARSER_DECRYPT fpAESDMAParserDecrypt; 226 IOCTL_AESDMA_QUERYPIDCOUNT fpAESDMAParserQueryPidCount; 227 IOCTL_AESDMA_PARSER_SETADDEDSCRMBPATTERN fpAESDMAParserSetAddedScrmbPattern; 228 MS_BOOL bEnableTwoKey; 229 MS_U8 InitVectorOdd[16]; 230 MS_U8 CipherOddKey[16]; 231 IOCTL_AESDMA_SETKEYSEL fpAESDMASetKeySel; 232 IOCTL_AESDMA_SETODDIV fpAESDMASetOddIv; 233 MS_U8 u8PidIndex1; //2nd PID, 0x122C_02 234 MS_U32 u16Pid1; //2nd PID, 0x122C_02 235 IOCTL_IS_SECRETKEYINNORMALBLANK fpAESDMAIsSecretKeyInNormalBlank; 236 IOCTL_HDCP_PROCESSCIPHER fpHDCPHDCPProcessCipher; 237 238 IOCTL_AESDMA_RESET fpAESDMANormalReset; 239 MS_BOOL bEvenScrmbPatternEn; 240 MS_BOOL bOddScrmbPatternEn; 241 IOCTL_HDCP_GETHDCPCIPHERSTATE fpGetHDCPCipherState; 242 MS_BOOL bSetEng; 243 MS_BOOL bSetKey; 244 MS_BOOL bSetIV; 245 MS_BOOL bHwParserEn; 246 MS_BOOL bPid0En; 247 MS_BOOL bPid1En; 248 MS_BOOL bMaskScrmbEn; 249 250 IOCTL_AESDMA_SETKEYINDEX fpAESDMAKeyIndex; 251 MS_U32 u32KeyIndexEven; 252 MS_U32 u32KeyIndexOdd; 253 MS_BOOL bEnableKeyIndexEvenKey; 254 MS_BOOL bEnableKeyIndexOddKey; 255 IOCTL_AESDMA_SETAESCTR64 fpAesCtr64; 256 MS_BOOL bEnableAesCtr64; 257 258 IOCTL_AESDMA_SETSECUREKEYINDEX fpAESDMASecureKeyIdx; 259 MS_U8 u8SecureKeyIndex; 260 261 MS_PHY u32miu0addr; 262 MS_PHY u32miu1addr; 263 MS_U32 u32miunum; 264 }AESDMA_INSTANT_PRIVATE; 265 266 void AESDMARegisterToUtopia(FUtopiaOpen ModuleType); 267 MS_U32 AESDMAOpen(void** pInstantTmp, MS_U32 u32ModuleVersion, void* pAttribute); 268 MS_U32 AESDMAClose(void* pInstantTmp); 269 MS_U32 AESDMAIoctl(void* pInstantTmp, MS_U32 u32Cmd, void* pArgs); 270 MS_U32 AESDMAStr(MS_U32 u32PowerState, void* pModule); 271 272 DRVAESDMA_RESULT _MDrv_AESDMA_SetKeyIndex (MS_U32 u32Index, MS_BOOL bIsOddKey); 273 DRVAESDMA_RESULT _MDrv_AESDMA_SetAesCtr64 (MS_BOOL bCtr64En); 274 DRVAESDMA_RESULT _MDrv_AESDMA_SetSecuredKeyIndex (MS_U8 u8KeyIdx); 275 276 #ifdef __cplusplus 277 } 278 #endif 279 #endif // _DRVAESDMA_PRIV_H_ 280