34 #include "libIARMCore.h"
36 #include "mfrCrypto.h"
38 #include <sys/types.h>
40 #include "safec_lib.h"
42 static char writeImageCbModule[MAX_BUF] =
"";
43 static char cliName[32];
46 static void _eventHandler(
const char *owner, IARM_EventId_t eventId,
void *data,
size_t len)
48 errno_t safec_rc = -1;
60 cb_notify.cb(param->
status, cb_notify.cbData);
67 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
68 printf(
"Initializing MFR module \n");
70 (
char *)IARM_BUS_MFRLIB_API_Init,
74 if (IARM_RESULT_SUCCESS == rpcRet)
76 printf(
"Iarm call returned success in %s \n",__func__);
81 return mfrERR_GENERAL;
86 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
88 (
char *)IARM_BUS_MFRLIB_API_Shutdown,
91 if (IARM_RESULT_SUCCESS == rpcRet)
95 return mfrERR_GENERAL;
100 IARM_Result_t rpcRet;
102 errno_t safec_rc = -1;
113 safec_rc = strcpy_s(param.crypto,
sizeof(param.crypto),
"mfrCrypto_Encrypt");
117 safec_rc = strcpy_s(param.crypto,
sizeof(param.crypto),
"");
122 return mfrERR_GENERAL;
126 printf(
"%s: Calling Get Serialized..\n",__func__);
132 if (IARM_RESULT_SUCCESS != rpcRet)
134 printf(
"%s: failed while trying to get size of param..\n",__func__);
138 data->buf = (
char *) malloc (param.bufLen);
139 safec_rc = memcpy_s(data->buf, param.bufLen, (
char *)param.buffer, param.bufLen);
145 return mfrERR_GENERAL;
147 data->bufLen = param.bufLen;
148 data->freeBuf = free;
152 if(rpcRet == IARM_RESULT_SUCCESS)
155 return mfrERR_GENERAL;
160 IARM_Result_t rpcRet;
162 errno_t safec_rc = -1;
164 param.
bufLen = (data->bufLen < MAX_SERIALIZED_BUF)?data->bufLen:MAX_SERIALIZED_BUF;
168 safec_rc = strcpy_s(param.crypto,
sizeof(param.crypto),
"mfrCrypto_Decrypt");
172 safec_rc = strcpy_s(param.crypto,
sizeof(param.crypto),
"");
177 return mfrERR_GENERAL;
180 safec_rc = memcpy_s(((
char*)param.buffer),
sizeof(param.buffer), data->buf, param.
bufLen);
184 return mfrERR_GENERAL;
188 (
char *)IARM_BUS_MFRLIB_API_SetSerializedData,
192 if (IARM_RESULT_SUCCESS != rpcRet)
194 printf(
"%s: failed while trying to write param..\n",__func__);
195 rpcRet = IARM_RESULT_IPCCORE_FAIL;
201 if(rpcRet == IARM_RESULT_SUCCESS)
203 return mfrERR_GENERAL;
208 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
210 errno_t safec_rc = -1;
212 safec_rc = strcpy_s(param.
name,
sizeof(param.
name), name);
216 return mfrERR_GENERAL;
219 safec_rc = strcpy_s(param.
path,
sizeof(param.
path), path);
223 return mfrERR_GENERAL;
234 if(IARM_RESULT_SUCCESS == rpcRet)
239 return mfrERR_GENERAL;
245 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
247 errno_t safec_rc = -1;
249 safec_rc = strcpy_s(param.imageName,
sizeof(param.imageName), imageName);
253 return mfrERR_GENERAL;
256 param.imageType = imageType;
257 param.progress = progress;
260 (
char *)IARM_BUS_MFRLIB_API_SetImageWriteProgress,
264 if(IARM_RESULT_SUCCESS == rpcRet)
268 return mfrERR_GENERAL;
275 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
277 errno_t safec_rc = -1;
279 printf(
"Inside %s \n",__func__);
280 safec_rc = strcpy_s(param.imageName,
sizeof(param.imageName), imageName);
284 return mfrERR_GENERAL;
287 param.imageType = imageType;
289 (
char *)IARM_BUS_MFRLIB_API_GetImageWriteProgress,
293 if(IARM_RESULT_SUCCESS == rpcRet)
295 *progress = param.progress;
298 return mfrERR_GENERAL;
304 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
309 if(IARM_RESULT_SUCCESS == rpcRet)
313 return mfrERR_GENERAL;
318 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
323 if(IARM_RESULT_SUCCESS == rpcRet)
327 return mfrERR_GENERAL;
334 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
336 errno_t safec_rc = -1;
338 safec_rc = strcpy_s(param.imageName,
sizeof(param.imageName), imageName);
342 return mfrERR_GENERAL;
347 (
char *)IARM_BUS_MFRLIB_API_Reboot,
351 if(IARM_RESULT_SUCCESS == rpcRet)
355 return mfrERR_GENERAL;
362 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
368 (
char *)IARM_BUS_MFRLIB_API_SetCableCardType,
372 if(IARM_RESULT_SUCCESS == rpcRet)
376 return mfrERR_GENERAL;
382 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
384 errno_t safec_rc = -1;
386 safec_rc = strcpy_s(param.version,
sizeof(param.version), firmwareInfo->firmwareVersion);
390 return mfrERR_GENERAL;
393 param.day = firmwareInfo-> firmwareDay;
394 param.month = firmwareInfo->firmwareMonth;
395 param.year = firmwareInfo->firmwareYear;
398 (
char *)IARM_BUS_MFRLIB_API_SetHostFirmwareInfo,
402 if(IARM_RESULT_SUCCESS == rpcRet)
406 return mfrERR_GENERAL;
409 mfrError_t
mfrGetBootImageName(
int bootInstance,
char *bootImageName,
int *len, mfrImageType_t bootImageType)
412 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
414 errno_t safec_rc = -1;
417 param.bootInstance = bootInstance;
419 param.type = bootImageType;
421 (
char *)IARM_BUS_MFRLIB_API_GetBootImageName,
425 if(IARM_RESULT_SUCCESS == rpcRet)
428 safec_rc = memcpy_s(bootImageName,
sizeof(param.imageName), param.imageName, param.len);
432 return mfrERR_GENERAL;
437 return mfrERR_GENERAL;
442 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
444 errno_t safec_rc = -1;
450 (
char *)IARM_BUS_MFRLIB_API_GetPathConfiguration,
454 if(IARM_RESULT_SUCCESS == rpcRet)
459 safec_rc = memcpy_s(path,
sizeof(param.path), param.path, param.len);
463 return mfrERR_GENERAL;
469 return mfrERR_GENERAL;
475 IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
477 errno_t safec_rc = -1;
479 safec_rc = memcpy_s(param.seedIn,
sizeof(param.seedIn), params->seedIn,
sizeof(param.seedIn));
483 return mfrERR_GENERAL;
486 safec_rc = memcpy_s(param.keyOut,
sizeof(param.keyOut), params->keyOut,
sizeof(param.keyOut));
490 return mfrERR_GENERAL;
494 (
char *)IARM_BUS_MFRLIB_API_GetDFAST2Data,
498 if(IARM_RESULT_SUCCESS == rpcRet)
502 return mfrERR_GENERAL;