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-2010 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 mdrvDSCMB.c
98 /// @brief API Interface
99 /// @author MStar Semiconductor,Inc.
100 /// @attention
101 ///////////////////////////////////////////////////////////////////////////////////////////////////
102
103
104 //-------------------------------------------------------------------------------------------------
105 // Include Files
106 //-------------------------------------------------------------------------------------------------
107 #ifdef MSOS_TYPE_LINUX_KERNEL
108 #include <linux/string.h>
109 #include <linux/uaccess.h>
110 #include <linux/compat.h>
111 #else
112 #include <stdio.h>
113 #include <string.h>
114 #endif
115
116 #include "MsTypes.h"
117
118 #include "drvCA_v2.h"
119 #include "drvCA_private.h"
120
121 #include "utopia.h"
122 #include "utopia_dapi.h"
123 #include "MsOS.h"
124
125 //-------------------------------------------------------------------------------------------------
126 // Driver Compiler Options
127 //-------------------------------------------------------------------------------------------------
128
129 //-------------------------------------------------------------------------------------------------
130 // Global Variables
131 //-------------------------------------------------------------------------------------------------
132 void* pModuleCA = NULL;
133
134 //-------------------------------------------------------------------------------------------------
135 // Local Defines
136 //-------------------------------------------------------------------------------------------------
137
138 //-------------------------------------------------------------------------------------------------
139 // Local Structures
140 //-------------------------------------------------------------------------------------------------
141
142 //-------------------------------------------------------------------------------------------------
143 // Local Variables
144 //-------------------------------------------------------------------------------------------------
145
146 //-------------------------------------------------------------------------------------------------
147 // Global Functions
148 //-------------------------------------------------------------------------------------------------
CARegisterToUtopia(void)149 void CARegisterToUtopia(void)
150 {
151 CA_RESOURCE_PRIVATE * pResPri = NULL;
152 void* psResource = NULL;
153
154 // 1. deal with module
155
156 // create a CA module
157 // a. size = 8
158 // b. Dst: pModuleDscmb
159 UtopiaModuleCreate(MODULE_CA, 8, &pModuleCA);
160 // register a dscmb module
161 UtopiaModuleRegister(pModuleCA);
162 //setup module functions
163 UtopiaModuleSetupFunctionPtr(pModuleCA, (FUtopiaOpen)CAOpen, (FUtopiaClose)CAClose, (FUtopiaIOctl)CAIoctl);
164
165 // 2. deal with resource
166 // create and allocate resource private data(drv Global shared data)
167 UtopiaResourceCreate("CA", sizeof(CA_RESOURCE_PRIVATE), &psResource);
168 UtopiaResourceRegister(pModuleCA, psResource, E_CA_RESOURCE);
169 UtopiaModuleAddResourceEnd(pModuleCA, E_CA_RESOURCE);
170
171 if(UtopiaResourceObtain(pModuleCA, E_CA_RESOURCE, &psResource) != UTOPIA_STATUS_SUCCESS)
172 {
173 MS_DEBUG_MSG(printf("[%s][%d] UtopiaResourceObtain fail\n", __FUNCTION__, __LINE__));
174 return ;
175 }
176 UtopiaResourceGetPrivate(psResource, (void**)&pResPri);
177
178 UtopiaResourceRelease(psResource);
179 }
180
CAOpen(void ** ppInstance,MS_U32 u32ModuleVersion,void * pAttribute)181 MS_U32 CAOpen(void** ppInstance, MS_U32 u32ModuleVersion, void* pAttribute)
182 {
183 MS_DEBUG_MSG(printf("[%s][%d] DSCMB open \n", __FUNCTION__, __LINE__));
184
185 if(ppInstance == 0)
186 {
187 return UTOPIA_STATUS_PARAMETER_ERROR;
188 }
189
190 CA_INSTANT_PRIVATE* psCAInstPri = NULL;
191
192 //create instance
193 //1. Allocate instant private data, prepare argument variable.
194 //2. Dst: ppInstance
195 UtopiaInstanceCreate(sizeof(CA_INSTANT_PRIVATE), ppInstance);
196
197 //get instant private data pointer
198 // 1. Dst: psDscmbInstPri
199 UtopiaInstanceGetPrivate(*ppInstance, (void**)&psCAInstPri);
200
201 return UTOPIA_STATUS_SUCCESS;
202 }
203
CAIoctl(void * pInstance,MS_U32 u32Cmd,void * pu32Args)204 MS_U32 CAIoctl(void* pInstance, MS_U32 u32Cmd, void* pu32Args)
205 {
206 void* pstRes = NULL;
207 MS_U32 u32Ret = UTOPIA_STATUS_FAIL;
208 CA_RESOURCE_PRIVATE* pstResPri = NULL;
209
210 if(UtopiaResourceObtain(pModuleCA, E_CA_RESOURCE, &pstRes) != UTOPIA_STATUS_SUCCESS)
211 {
212 MS_DEBUG_MSG(printf("[%s][%d] UtopiaResourceObtain fail\n", __FUNCTION__, __LINE__));
213 return UTOPIA_STATUS_ERR_RESOURCE;
214 }
215 UtopiaResourceGetPrivate(pstRes, (void**)&pstResPri);
216
217 switch(u32Cmd)
218 {
219 case E_MDRV_CMD_CA_Init:
220 {
221 if(TRUE == _MDrv_CA_Init())
222 {
223 u32Ret = UTOPIA_STATUS_SUCCESS;
224 }
225 else
226 {
227 u32Ret = UTOPIA_STATUS_FAIL;
228 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_Init fail\n", __FUNCTION__, __LINE__));
229 }
230 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_Init\n", __FUNCTION__, __LINE__));
231 }
232 break;
233
234 case E_MDRV_CMD_CA_OTP_EnableSecureBoot:
235 {
236
237 if(TRUE == _MDrv_CA_OTP_EnableSecureBoot())
238 {
239 u32Ret = UTOPIA_STATUS_SUCCESS;
240 }
241 else
242 {
243 u32Ret = UTOPIA_STATUS_FAIL;
244 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_EnableSecureBoot fail\n", __FUNCTION__, __LINE__));
245 }
246 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_EnableSecureBoot\n", __FUNCTION__, __LINE__));
247 }
248 break;
249
250 case E_MDRV_CMD_CA_OTP_IsSecureBootEnabled:
251 {
252
253 if(TRUE == _MDrv_CA_OTP_IsSecureBootEnabled())
254 {
255 u32Ret = UTOPIA_STATUS_SUCCESS;
256 }
257 else
258 {
259 u32Ret = UTOPIA_STATUS_FAIL;
260 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_IsSecureBootEnabled fail\n", __FUNCTION__, __LINE__));
261 }
262 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_IsSecureBootEnabled\n", __FUNCTION__, __LINE__));
263 }
264 break;
265
266 case E_MDRV_CMD_CA_OTP_SetBlockLock:
267 {
268 CA_OTP_SETBLOCKLOCK* pSetBlockLock = (CA_OTP_SETBLOCKLOCK*)pu32Args;
269
270 if(TRUE == _MDrv_CA_OTP_SetBlockLock(pSetBlockLock->u32Start, pSetBlockLock->u32End, pSetBlockLock->eLockType))
271 {
272 u32Ret = UTOPIA_STATUS_SUCCESS;
273 }
274 else
275 {
276 u32Ret = UTOPIA_STATUS_FAIL;
277 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetBlockLock fail\n", __FUNCTION__, __LINE__));
278 }
279 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetBlockLock\n", __FUNCTION__, __LINE__));
280 }
281 break;
282
283 case E_MDRV_CMD_CA_OTP_IsBlank:
284 {
285 CA_OTP_ISBLANK* pIsBlank = (CA_OTP_ISBLANK*)pu32Args;
286 if(TRUE == _MDrv_CA_OTP_IsBlank(pIsBlank->u32addr))
287 {
288 u32Ret = UTOPIA_STATUS_SUCCESS;
289 }
290 else
291 {
292 u32Ret = UTOPIA_STATUS_FAIL;
293 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_IsBlank fail\n", __FUNCTION__, __LINE__));
294 }
295 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_IsBlank\n", __FUNCTION__, __LINE__));
296 }
297 break;
298
299 case E_MDRV_CMD_CA_OTP_Read:
300 {
301 CA_OTP_READ* pRead = (CA_OTP_READ*)pu32Args;
302
303 pRead->u32OTPValue = _MDrv_CA_OTP_Read(pRead->u32Addr);
304
305 u32Ret = UTOPIA_STATUS_SUCCESS;
306
307 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_Read\n", __FUNCTION__, __LINE__));
308 }
309 break;
310
311 case E_MDRV_CMD_CA_OTP_Write:
312 {
313 CA_OTP_WRITE* pWrite = (CA_OTP_WRITE*)pu32Args;
314 if(TRUE == _MDrv_CA_OTP_Write(pWrite->u32Addr, pWrite->u32value))
315 {
316 u32Ret = UTOPIA_STATUS_SUCCESS;
317 }
318 else
319 {
320 u32Ret = UTOPIA_STATUS_FAIL;
321 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_Write fail\n", __FUNCTION__, __LINE__));
322 }
323 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_Write\n", __FUNCTION__, __LINE__));
324 }
325 break;
326
327 case E_MDRV_CMD_CA_Locked:
328 {
329 CA_OTP_LOCK20* pLock = (CA_OTP_LOCK20*)pu32Args;
330 if(TRUE == _MDrv_CA_Locked(pLock->eLock))
331 {
332 u32Ret = UTOPIA_STATUS_SUCCESS;
333 }
334 else
335 {
336 u32Ret = UTOPIA_STATUS_FAIL;
337 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_Locked fail\n", __FUNCTION__, __LINE__));
338 }
339 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_Locked\n", __FUNCTION__, __LINE__));
340 }
341 break;
342
343 case E_MDRV_CMD_CA_OTP_Lock:
344 {
345 CA_OTP_LOCK20* pLock = (CA_OTP_LOCK20*)pu32Args;
346 if(TRUE == _MDrv_CA_OTP_Lock(pLock->eLock))
347 {
348 u32Ret = UTOPIA_STATUS_SUCCESS;
349 }
350 else
351 {
352 u32Ret = UTOPIA_STATUS_FAIL;
353 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_Lock fail\n", __FUNCTION__, __LINE__));
354 }
355 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_Lock\n", __FUNCTION__, __LINE__));
356 }
357 break;
358
359 case E_MDRV_CMD_CA_OTP_SetRSAextID:
360 {
361 CA_OTP_SETRSAEXTID* pSetRsaextID = (CA_OTP_SETRSAEXTID*)pu32Args;
362 if(TRUE == _MDrv_CA_OTP_SetRSAextID(pSetRsaextID->u32value))
363 {
364 u32Ret = UTOPIA_STATUS_SUCCESS;
365 }
366 else
367 {
368 u32Ret = UTOPIA_STATUS_FAIL;
369 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetRSAextID fail\n", __FUNCTION__, __LINE__));
370 }
371 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetRSAextID\n", __FUNCTION__, __LINE__));
372 }
373 break;
374
375 case E_MDRV_CMD_CA_OTP_GetRSAextID:
376 {
377 CA_OTP_GETRSAEXTID* pGetRsaextID = (CA_OTP_GETRSAEXTID*)pu32Args;
378 pGetRsaextID->u32value = _MDrv_CA_OTP_GetRSAextID();
379
380 u32Ret = UTOPIA_STATUS_SUCCESS;
381
382 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetRSAextID\n", __FUNCTION__, __LINE__));
383 }
384 break;
385
386 case E_MDRV_CMD_CA_OTP_SetHASH1_REF_VER:
387 {
388 CA_OTP_SETHASH1REFVER* pSetHash1RefVer = (CA_OTP_SETHASH1REFVER*)pu32Args;
389 if(TRUE == _MDrv_CA_OTP_SetHASH1_REF_VER(pSetHash1RefVer->u32HASH1_REF_VER))
390 {
391 u32Ret = UTOPIA_STATUS_SUCCESS;
392 }
393 else
394 {
395 u32Ret = UTOPIA_STATUS_FAIL;
396 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetHASH1_REF_VER fail\n", __FUNCTION__, __LINE__));
397 }
398 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetHASH1_REF_VER\n", __FUNCTION__, __LINE__));
399 }
400 break;
401
402 case E_MDRV_CMD_CA_OTP_GetHASH1_REF_VER:
403 {
404 CA_OTP_GETHASH1REFVER* pGetHash1RefVer = (CA_OTP_GETHASH1REFVER*)pu32Args;
405 if(TRUE == _MDrv_CA_OTP_GetHASH1_REF_VER(pGetHash1RefVer->pu32HASH1_REF_VER))
406 {
407 u32Ret = UTOPIA_STATUS_SUCCESS;
408 }
409 else
410 {
411 u32Ret = UTOPIA_STATUS_FAIL;
412 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetHASH1_REF_VER fail\n", __FUNCTION__, __LINE__));
413 }
414 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetHASH1_REF_VER\n", __FUNCTION__, __LINE__));
415 }
416 break;
417
418 case E_MDRV_CMD_CA_OTP_SetHASH_REF_VER:
419 {
420 CA_OTP_SETHASHREFVER* pSetHashRefVer = (CA_OTP_SETHASHREFVER*)pu32Args;
421 if(TRUE == _MDrv_CA_OTP_SetHASH_REF_VER(pSetHashRefVer->u32HASH0_REF_VER, pSetHashRefVer->u32HASH2_REF_VER))
422 {
423 u32Ret = UTOPIA_STATUS_SUCCESS;
424 }
425 else
426 {
427 u32Ret = UTOPIA_STATUS_FAIL;
428 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetHASH_REF_VER fail\n", __FUNCTION__, __LINE__));
429 }
430 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetHASH_REF_VER\n", __FUNCTION__, __LINE__));
431 }
432 break;
433
434 case E_MDRV_CMD_CA_OTP_GetHASH_REF_VER:
435 {
436 CA_OTP_GETHASHREFVER* pGetHashRefVer = (CA_OTP_GETHASHREFVER*)pu32Args;
437 if(TRUE == _MDrv_CA_OTP_GetHASH_REF_VER(pGetHashRefVer->pu32HASH0_REF_VER, pGetHashRefVer->pu32HASH2_REF_VER))
438 {
439 u32Ret = UTOPIA_STATUS_SUCCESS;
440 }
441 else
442 {
443 u32Ret = UTOPIA_STATUS_FAIL;
444 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetHASH_REF_VER fail\n", __FUNCTION__, __LINE__));
445 }
446 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetHASH_REF_VER\n", __FUNCTION__, __LINE__));
447 }
448 break;
449
450 case E_MDRV_CMD_CA_OTP_SetDebugPortMode:
451 {
452 CA_OTP_SETDEBUGPORTMODE* pSetDebugPortMode = (CA_OTP_SETDEBUGPORTMODE*)pu32Args;
453 if(TRUE == _MDrv_CA_OTP_SetDebugPortMode(pSetDebugPortMode->eDebugPort, pSetDebugPortMode->eMode))
454 {
455 u32Ret = UTOPIA_STATUS_SUCCESS;
456 }
457 else
458 {
459 u32Ret = UTOPIA_STATUS_FAIL;
460 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetDebugPortMode fail\n", __FUNCTION__, __LINE__));
461 }
462 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetDebugPortMode\n", __FUNCTION__, __LINE__));
463 }
464 break;
465
466 case E_MDRV_CMD_CA_OTP_GetDebugPortMode:
467 {
468 CA_OTP_GETDEBUGPORTMODE* pGetDebugPortMode = (CA_OTP_GETDEBUGPORTMODE*)pu32Args;
469 if(TRUE == _MDrv_CA_OTP_GetDebugPortMode(pGetDebugPortMode->eDebugPort, pGetDebugPortMode->eMode))
470 {
471 u32Ret = UTOPIA_STATUS_SUCCESS;
472 }
473 else
474 {
475 u32Ret = UTOPIA_STATUS_FAIL;
476 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetDebugPortMode fail\n", __FUNCTION__, __LINE__));
477 }
478 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetDebugPortMode\n", __FUNCTION__, __LINE__));
479 }
480 break;
481
482 case E_MDRV_CMD_CA_OTP_SetDeviceId:
483 {
484 CA_OTP_SETDEVICEID* pDeviceId = (CA_OTP_SETDEVICEID*)pu32Args;
485 if(TRUE == _MDrv_CA_OTP_SetDeviceId(pDeviceId->pu8Did, pDeviceId->u32Size))
486 {
487 u32Ret = UTOPIA_STATUS_SUCCESS;
488 }
489 else
490 {
491 u32Ret = UTOPIA_STATUS_FAIL;
492 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetDeviceId fail\n", __FUNCTION__, __LINE__));
493 }
494 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_SetDeviceId\n", __FUNCTION__, __LINE__));
495 }
496 break;
497
498 case E_MDRV_CMD_CA_OTP_GetDeviceId:
499 {
500 CA_OTP_GETDEVICEID* pDeviceId = (CA_OTP_GETDEVICEID*)pu32Args;
501 if(TRUE == _MDrv_CA_OTP_GetDeviceId(pDeviceId->pu8Did, pDeviceId->u32Size))
502 {
503 u32Ret = UTOPIA_STATUS_SUCCESS;
504 }
505 else
506 {
507 u32Ret = UTOPIA_STATUS_FAIL;
508 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetDeviceId fail\n", __FUNCTION__, __LINE__));
509 }
510 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_GetDeviceId\n", __FUNCTION__, __LINE__));
511 }
512 break;
513
514 case E_MDRV_CMD_CA_MaxDeviceIdSize:
515 {
516 CA_MAXDEVICEIDSIZE* pMaxDeviceIdSize = (CA_MAXDEVICEIDSIZE*)pu32Args;
517
518 pMaxDeviceIdSize->u32MaxDeviceIdSize = _MDrv_CA_MaxDeviceIdSize();
519 if(FALSE != pMaxDeviceIdSize->u32MaxDeviceIdSize)
520 {
521 u32Ret = UTOPIA_STATUS_SUCCESS;
522 }
523 else
524 {
525 u32Ret = UTOPIA_STATUS_FAIL;
526 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_MaxDeviceIdSize fail\n", __FUNCTION__, __LINE__));
527 }
528 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_MaxDeviceIdSize\n", __FUNCTION__, __LINE__));
529 }
530 break;
531
532 case E_MDRV_CMD_CA_OTP_EnableSecureCWMode:
533 {
534 if(FALSE != _MDrv_CA_OTP_EnableSecureCWMode())
535 {
536 u32Ret = UTOPIA_STATUS_SUCCESS;
537 }
538 else
539 {
540 u32Ret = UTOPIA_STATUS_FAIL;
541 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_EnableSecureCWMode fail\n", __FUNCTION__, __LINE__));
542 }
543 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_EnableSecureCWMode\n", __FUNCTION__, __LINE__));
544 }
545 break;
546
547 case E_MDRV_CMD_CA_OTP_IsSecureCWMode:
548 {
549 if(FALSE != _MDrv_CA_OTP_IsSecureCWMode())
550 {
551 u32Ret = UTOPIA_STATUS_SUCCESS;
552 }
553 else
554 {
555 u32Ret = UTOPIA_STATUS_FAIL;
556 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_IsSecureCWMode fail\n", __FUNCTION__, __LINE__));
557 }
558 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_IsSecureCWMode\n", __FUNCTION__, __LINE__));
559 }
560 break;
561
562 case E_MDRV_CMD_CA_Random:
563 {
564 CA_RANDOM* pRandom = (CA_RANDOM*)pu32Args;
565
566 pRandom->u32Random = _MDrv_CA_Random();
567 if(FALSE != pRandom->u32Random)
568 {
569 u32Ret = UTOPIA_STATUS_SUCCESS;
570 }
571 else
572 {
573 u32Ret = UTOPIA_STATUS_FAIL;
574 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_Random fail\n", __FUNCTION__, __LINE__));
575 }
576 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_Random\n", __FUNCTION__, __LINE__));
577 }
578 break;
579
580 case E_MDRV_CMD_CA_OTP_ReadCAVendor:
581 {
582 CA_RANDOM* pRandom = (CA_RANDOM*)pu32Args;
583
584 pRandom->u32Random = _MDrv_CA_OTP_ReadCAVendor();
585 if(FALSE != pRandom->u32Random)
586 {
587 u32Ret = UTOPIA_STATUS_SUCCESS;
588 }
589 else
590 {
591 u32Ret = UTOPIA_STATUS_FAIL;
592 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_ReadCAVendor fail\n", __FUNCTION__, __LINE__));
593 }
594 MS_DEBUG_MSG(printf("[%s][%d] E_MDRV_CMD_CA_OTP_ReadCAVendor\n", __FUNCTION__, __LINE__));
595 }
596 break;
597
598 default:
599 MS_DEBUG_MSG(printf("[%s][%d] DSCMBIoctl - Unknown commend 0x%x!!!\n", __FUNCTION__, __LINE__));
600 return UTOPIA_STATUS_FAIL;
601 }
602
603 UtopiaResourceRelease(pstRes);
604
605 return u32Ret;
606 }
607
CAClose(void * pInstance)608 MS_U32 CAClose(void* pInstance)
609 {
610
611 UtopiaInstanceDelete(pInstance);
612
613 return UTOPIA_STATUS_SUCCESS;
614 }
615