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-2007 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_v2.h 98 /// @brief AESDMA Driver Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 #ifndef _DRV_AESDMA_V2_H_ 103 #define _DRV_AESDMA_V2_H_ 104 105 #include "UFO.h" 106 107 #ifdef __cplusplus 108 extern "C" 109 { 110 #endif 111 112 //------------------------------------------------------------------------------------------------- 113 // Defines 114 //------------------------------------------------------------------------------------------------- 115 // below for utopia20 structure 116 117 118 typedef enum { 119 MDrv_CMD_AESDMA_Init, 120 MDrv_CMD_AESDMA_SetIV, 121 MDrv_CMD_AESDMA_Reset, 122 MDrv_CMD_AESDMA_SetFileInOut, 123 MDrv_CMD_AESDMA_SetKey, 124 MDrv_CMD_AESDMA_SelEng, 125 MDrv_CMD_AESDMA_Start, 126 MDrv_CMD_AESDMA_GetStatus, 127 MDrv_CMD_AESDMA_IsFinished, 128 MDrv_CMD_AESDMA_SetClk, 129 MDrv_CMD_AESDMA_SetSecureKey, 130 MDrv_CMD_AESDMA_SetPS, 131 MDrv_CMD_AESDMA_PSRelease, 132 MDrv_CMD_AESDMA_GetPSMatchedByteCNT, 133 MDrv_CMD_AESDMA_GetPSMatchedPTN, 134 MDrv_CMD_AESDMA_Notify, 135 MDrv_CMD_AESDMA_Rand, 136 MDrv_CMD_RSA_Calculate, 137 MDrv_CMD_RSA_IsFinished, 138 MDrv_CMD_RSA_Output, 139 MDrv_CMD_SHA_Calculate, 140 MDrv_CMD_AESDMA_Memcpy, 141 MDrv_CMD_SHA_CalculateManual, 142 MDrv_CMD_AESDMA_PARSER_MASKSCRMB, 143 MDrv_CMD_AESDMA_PARSER_SETSCRMBPATTERN, 144 MDrv_CMD_AESDMA_PARSER_BYPASSPID, 145 MDrv_CMD_AESDMA_PARSER_SETPID, 146 MDrv_CMD_AESDMA_PARSER_ENCRYPT, 147 MDrv_CMD_AESDMA_PARSER_DECRYPT, 148 MDrv_CMD_AESDMA_PARSER_Start, 149 MDrv_CMD_AESDMA_PARSER_SETADDEDSCRMBPATTERN, 150 MDrv_CMD_AESDMA_PARSER_QUERYPIDCOUNT, 151 MDrv_CMD_AESDMA_ENABLE_Two_Key, 152 MDrv_CMD_AESDMA_SetOddKey, 153 MDrv_CMD_AESDMA_SetOddIV, 154 MDrv_CMD_IS_SECRETKEY_IN_NORMAL_BLANK, 155 MDrv_CMD_AESDMA_SetKey_Ex, 156 MDrv_CMD_AESDMA_SetIV_Ex, 157 MDrv_CMD_HDCP_MDrv_PROCESSCIPHER, 158 MDrv_CMD_AESDMA_Set_Efuse_Key_Index, 159 MDrv_CMD_HDCP_GetHdcpCipherState, 160 MDrv_CMD_AESDMA_Set_Key_Index, 161 MDrv_CMD_AESDMA_Set_AES_CTR64_En, 162 MDrv_CMD_AESDMA_SetDefaultCAVid, 163 MDrv_CMD_AESDMA_GetConfig, 164 MDrv_CMD_AESDMA_AllocKeySlot, 165 MDrv_CMD_AESDMA_FreeKeySlot, 166 } eAesdmaIoctlOpt; 167 168 //------------------------------------------------------------------------------------------------- 169 // Macros 170 //------------------------------------------------------------------------------------------------- 171 172 173 //------------------------------------------------------------------------------------------------- 174 // Type and Structure Declaration 175 //------------------------------------------------------------------------------------------------- 176 177 #ifdef BIFROST_32BIT_MODE 178 typedef struct DLL_PACKED _AESDMA_INIT 179 { 180 MS_U32 u32miu0addr; 181 MS_U32 u32miu1addr; 182 MS_U32 u32miunum; 183 }AESDMA_INIT, *PAESDMA_INIT; 184 185 typedef struct DLL_PACKED _AESDMA_FILE_INOUT 186 { 187 MS_U32 u32FileinAddr; 188 MS_U32 u32FileInNum; 189 MS_U32 u32FileOutSAddr; 190 MS_U32 u32FileOutEAddr; 191 }AESDMA_FILE_INOUT, *PAESDMA_FILE_INOUT; 192 #else 193 typedef struct DLL_PACKED _AESDMA_INIT 194 { 195 MS_PHY u32miu0addr; 196 MS_PHY u32miu1addr; 197 MS_U32 u32miunum; 198 }AESDMA_INIT, *PAESDMA_INIT; 199 200 typedef struct DLL_PACKED _AESDMA_FILE_INOUT 201 { 202 MS_PHY u32FileinAddr; 203 MS_U32 u32FileInNum; 204 MS_PHY u32FileOutSAddr; 205 MS_PHY u32FileOutEAddr; 206 }AESDMA_FILE_INOUT, *PAESDMA_FILE_INOUT; 207 #endif 208 209 typedef struct DLL_PACKED _AESDMA_SEL_ENG 210 { 211 DrvAESDMA_CipherMode eMode; 212 MS_BOOL bDescrypt; 213 }AESDMA_SEL_ENG, *PAESDMA_SEL_ENG; 214 215 typedef struct DLL_PACKED _AESDMA_SET_IV 216 { 217 MS_U32 *pInitVector; 218 }AESDMA_SET_IV, *PAESDMA_SET_IV; 219 220 typedef struct DLL_PACKED _AESDMA_SET_KEY 221 { 222 MS_U32 *pCipherKey; 223 }AESDMA_SET_KEY, *PAESDMA_SET_KEY; 224 225 typedef struct DLL_PACKED _AESDMA_SET_KEY_EX 226 { 227 const MS_U8 *pu8Key; 228 MS_U32 u32Len; 229 }AESDMA_SET_KEY_EX, *PAESDMA_SET_KEY_EX; 230 231 typedef struct DLL_PACKED _AESDMA_SET_IV_EX 232 { 233 const MS_U8 *pu8IV; 234 MS_U32 u32Len; 235 }AESDMA_SET_IV_EX, *PAESDMA_SET_IV_EX; 236 237 238 typedef struct DLL_PACKED _AESDMA_SET_PS 239 { 240 MS_U32 u32PTN; 241 MS_U32 u32Mask; 242 MS_BOOL bPSin_Enable; 243 MS_BOOL bPSout_Enable; 244 }AESDMA_SET_PS, *PAESDMA_SET_PS; 245 246 typedef struct DLL_PACKED _AESDMA_START 247 { 248 MS_BOOL bStart; 249 }AESDMA_START, *PAESDMA_START; 250 251 252 typedef struct DLL_PACKED _AESDMA_NOTIFY 253 { 254 DrvAESDMA_Event eEvents; 255 P_DrvAESDMA_EvtCallback pfCallback; 256 }AESDMA_NOTIFY, *PAESDMA_NOTIFY; 257 258 typedef struct DLL_PACKED _AESDMA_RAND 259 { 260 MS_U32 *u32PABuf; 261 MS_U32 u32Size; 262 }AESDMA_RAND, *PAESDMA_RAND; 263 264 typedef struct DLL_PACKED _RSA_CALCULATE 265 { 266 DrvAESDMA_RSASig *pstSign; 267 DrvAESDMA_RSAKey *pstKey; 268 DrvAESDMA_RSAMode eMode; 269 }RSA_CALCULATE, *PRSA_CALCULATE; 270 271 typedef struct DLL_PACKED _RSA_OUTPUT 272 { 273 DrvAESDMA_RSAMode eMode; 274 DrvAESDMA_RSAOut *pstRSAOut; 275 }RSA_OUTPUT, *PRSA_OUTPUT; 276 277 #ifdef BIFROST_32BIT_MODE 278 typedef struct DLL_PACKED _SHA_CALCULATE 279 { 280 DrvAESDMA_SHAMode eMode; 281 MS_U32 u32PAInBuf; 282 MS_U32 u32Size; 283 MS_U32 u32PAOutBuf; 284 }SHA_CALCULATE, *PSHA_CALCULATE; 285 #else 286 typedef struct DLL_PACKED _SHA_CALCULATE 287 { 288 DrvAESDMA_SHAMode eMode; 289 MS_PHY u32PAInBuf; 290 MS_U32 u32Size; 291 MS_PHY u32PAOutBuf; 292 }SHA_CALCULATE, *PSHA_CALCULATE; 293 #endif 294 295 typedef struct DLL_PACKED _SHA_CALCULATE_MANUAL 296 { 297 DrvAESDMA_HASHCFG stCfg; 298 DrvAESDMA_HASH_STAGE eStage; 299 MS_U32 u32DoneBytes; 300 MS_U8 *pu8SetIV; 301 }SHA_CALCULATE_MANUAL, *PSHA_CALCULATE_MANUAL; 302 303 typedef struct DLL_PACKED _AESDMA_PARSER_CONFIGURATIONS 304 { 305 DrvAESDMA_ScrmbPattern eScrmbPattern; 306 DrvAESDMA_ParserMode eParserMode; 307 DrvAESDMA_ScrmbPattern eAddedScrmbPattern; 308 }AESDMA_PARSER_CONFIGURATIONS, *PAESDMA_PARSER_CONFIGURATIONS; 309 310 typedef struct DLL_PACKED _AESDMA_PARSER_PID_CONFIGURATIONS 311 { 312 //Don't care PidIndex and Pid if BypassPid is true; 313 MS_BOOL bBypassPid; 314 MS_U8 u8PidIndex; 315 MS_U16 u16Pid; 316 }AESDMA_PARSER_PID_CONFIGURATIONS, *PAESDMA_PARSER_PID_CONFIGURATIONS; 317 318 typedef struct DLL_PACKED _AESDMA_CAVID 319 { 320 MS_U32 u32CAVid; 321 }AESDMA_CAVID, *PAESDMA_CAVID; 322 323 typedef struct DLL_PACKED _HDCP_CIPHER 324 { 325 MS_U8 u8Idx; 326 MS_U8 pu8Riv[8]; 327 MS_U8 pu8ContentKey[16]; 328 }HDCP_CIPHER, *PHDCP_CIPHER; 329 330 typedef struct DLL_PACKED _HDCP_CIPHER_STATE 331 { 332 MS_U8 u8Idx; //Port Index. 333 MS_U8 *pu8State; //For return Status. 334 }HDCP_CIPHER_STATE, *PHDCP_CIPHER_STATE; 335 336 typedef struct DLL_PACKED _AESDMA_KEY_INDEX 337 { 338 MS_BOOL bOddKeyEn; //FALSE: Default/Even Key, TRUE: Odd Key 339 MS_U32 u32KeyIndex; //Key Index 340 }AESDMA_KEY_INDEX, *PAESDMA_KEY_INDEX; 341 342 typedef struct DLL_PACKED _AESDMA_ALLOC_KEY_SLOT 343 { 344 MS_U32 *pu32KeyIndex; //For return Key Index 345 }AESDMA_ALLOC_KEY_SLOT, *PAESDMA_ALLOC_KEY_SLOT; 346 347 //------------------------------------------------------------------------------------------------- 348 // Extern Global Variabls 349 //------------------------------------------------------------------------------------------------- 350 351 //------------------------------------------------------------------------------------------------- 352 // Extern Functions 353 //------------------------------------------------------------------------------------------------- 354 355 ////////////////////////////////////////////////////////////// 356 357 #ifdef __cplusplus 358 } 359 #endif 360 361 #endif // _DRV_AESDMA_V2_H_ 362 363