/* * ======== Loader_init ======== */ Void Loader_init(Void) { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_osal_Loader_desc, Loader_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Loader_MODNAME); } regInit = 1; } if (curInit++ == 0) { Global_atexit((Fxn)cleanup); } }
/* * ======== Algorithm_init ======== */ Void Algorithm_init() { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_algorithm_desc, Algorithm_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Algorithm_MODNAME); } regInit = 1; } if (curInit != TRUE) { curInit = TRUE; RMAN_init(); Global_atexit((Fxn)Algorithm_exit); } }
/* * ======== Global_init ======== */ Void Global_init(Void) { Int i; Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_osal_Global_desc, Global_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Global_MODNAME); } regInit = 1; } if (curInit != TRUE) { curInit = TRUE; Log_print0(Diags_USER4, "[+4] Global_init> " "This program was built with the following packages:" ); for (i = 0; Global_buildInfo[i] != NULL; i++) { Log_print1(Diags_USER4, "[+4] %s", (IArg)(Global_buildInfo[i])); } } }
/* * ======== VIDDEC1_create ======== */ VIDDEC1_Handle VIDDEC1_create(Engine_Handle engine, String name, VIDDEC1_Params *params) { Registry_Result result; VIDDEC1_Handle visa; /* TODO:M Race here! Do we need ATM_Increment in our OSAL? */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_video1_viddec1_desc, MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(MODNAME); } regInit = 1; } Log_print3(Diags_ENTRY, "[+E] VIDDEC1_create> " "Enter (engine=0x%x, name='%s', params=0x%x)", (IArg)engine, (IArg)name, (IArg)params); visa = VISA_create(engine, name, (IALG_Params *)params, sizeof (_VIDDEC1_Msg), VIDDEC1_VISATYPE); Log_print1(Diags_EXIT, "[+X] VIDDEC1_create> return (0x%x)", (IArg)visa); return (visa); }
/* * ======== Comm_init ======== */ Bool Comm_init(Void) { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_ipc_comm_desc, Comm_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Comm_MODNAME); } regInit = 1; } if (curInit++ == 0) { /* TODO:M not process safe (right?) */ userName = getenv("LOGNAME"); if (userName == NULL) { userName = ""; } } return (TRUE); }
/* * ======== VIDENCCOPY_TI_alloc ======== */ Int VIDENCCOPY_TI_alloc(const IALG_Params *algParams, IALG_Fxns **pf, IALG_MemRec memTab[]) { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_examples_codecs_videnc_copy_desc, MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(MODNAME); } regInit = 1; } Log_print3(Diags_ENTRY, "[+E] VIDENCCOPY_TI_alloc(0x%x, 0x%x, 0x%x)", (IArg)algParams, (IArg)pf, (IArg)memTab); /* Request memory for my object */ memTab[0].size = sizeof(VIDENCCOPY_TI_Obj); memTab[0].alignment = 0; memTab[0].space = IALG_EXTERNAL; memTab[0].attrs = IALG_PERSIST; // ADD BY ZHENGHANG memTab[1].size = sizeof(char)*25000 * 1024; memTab[1].alignment = 0; memTab[1].space = IALG_EXTERNAL;//IALG_DARAM0; memTab[1].attrs = IALG_PERSIST; // ADD BY ZHOULU memTab[2].size = sizeof(char) * 150000 * 1024; memTab[2].alignment = 0; memTab[2].space = IALG_EXTERNAL; memTab[2].attrs = IALG_PERSIST; memTab[3].size = sizeof(char) * 127*1024; memTab[3].alignment = 0; memTab[3].space = IALG_DARAM0; memTab[3].attrs = IALG_PERSIST; //IALG_DARAM0; return (4); }
/* * ======== Memory_init ======== */ Bool Memory_init(Void) { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_osal_Memory_desc, Memory_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Memory_MODNAME); } regInit = 1; } if (curInit != TRUE) { curInit = TRUE; moduleLock = Lock_create(NULL); if (moduleLock == NULL) { Log_print0(Diags_USER7, "[+7] Memory_init> " "ERROR: could not create pthread mutex."); assert(FALSE); } if (CMEM_init() == -1) { Log_print0(Diags_USER7, "[+7] Memory_init> " "ERROR: Failed to initialize CMEM"); } else { cmemInitialized = TRUE; } Global_atexit((Fxn)cleanup); } return (cmemInitialized); }
/* * ======== Processor_init ======== */ Void Processor_init(Void) { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_ipc_processor_desc, Processor_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Processor_MODNAME); } regInit = 1; } }
/* * ======== Algorithm_init ======== */ Void Algorithm_init() { Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_algorithm_desc, Algorithm_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Algorithm_MODNAME); } regInit = 1; } if (curInit++ == 0) { RMAN_init(); DMAN3_CE_init(); /* * NOTE: We are calling ALG_init() here rather than calling it in * CERuntime_init(). This simplifies the auto-generation of * CERuntime_init(), since ALG is not used in Algorithm_BIOS.c. * Since ALG_init() is called here, to keep the symmetry, we will * also call ALG_exit() from Algorithm_exit(), rather than having * ALG_init() register its exit function through Global_atexit(). */ ALG_init(); Global_atexit((Fxn)Algorithm_exit); } }
/* * ======== Memory_init ======== */ Bool Memory_init(Void) { Registry_Result result; Int i; Memory_Stat stat; static Bool curInit = FALSE; if (curInit != TRUE) { curInit = TRUE; Memory_DEFAULTPARAMS.seg = (UInt)xdc_runtime_Memory_defaultHeapInstance; /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_osal_Memory_desc, Memory_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Memory_MODNAME); } ti_sdo_ce_osal_Memory_cfgInit(); /* * Note: Memory_originalBase and Memory_originalSize are only * accessed through the RMS server thread, so we don't need to * alloc these buffers inside a Gate_enter() call. */ if ((Memory_numHeaps > 0) && (Memory_originalBase == NULL)) { Memory_originalBase = xdc_runtime_Memory_alloc(NULL, Memory_numHeaps * sizeof(Uint32), 0, NULL); if (Memory_originalBase == NULL) { Log_print0(Diags_USER7, "Memory_init> Memory_alloc() failed"); return (FALSE); } } if ((Memory_numHeaps > 0) && (Memory_originalSize == NULL)) { Memory_originalSize = xdc_runtime_Memory_alloc(NULL, Memory_numHeaps * sizeof(Uint32), 0, NULL); if (Memory_originalSize == NULL) { xdc_runtime_Memory_free(NULL, Memory_originalBase, sizeof(Uint32) * Memory_numHeaps); Log_print0(Diags_USER7, "Memory_init> Memory_alloc() failed"); return (FALSE); } } /* * Keep track of original size and base of memory heaps in case * someone does a Memory_redefine() then a Memory_restoreHeap(). */ for (i = 0; i < Memory_numHeaps; i++) { if (!Memory_segStat(i, &stat)) { Log_print1(Diags_USER7, "Memory_init> Memory_segStat(%d) " "failed!", (IArg)i); Memory_originalBase[i] = (UInt32)-1; Memory_originalSize[i] = 0; } else { Memory_originalBase[i] = stat.base; Memory_originalSize[i] = stat.size; } } } return (TRUE); }
/* * ======== Processor_init ======== */ Void Processor_init(Void) { GateThread_Params params; Registry_Result result; /* * No need to reference count for Registry_addModule(), since there * is no way to remove the module. */ if (regInit == 0) { /* Register this module for logging */ result = Registry_addModule(&ti_sdo_ce_ipc_processor_desc, Processor_MODNAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); if (result == Registry_SUCCESS) { /* Set the diags mask to the CE default */ CESettings_init(); CESettings_setDiags(Processor_MODNAME); } regInit = 1; } if (curInit != TRUE) { curInit = TRUE; /* Semaphore with count 0, will be posted when a command is present */ dcmd.cmdPresent = SemThread_create(0, NULL, NULL); /* Semaphore with count 0, will be posted when reply is ready */ dcmd.replyPresent = SemThread_create(0, NULL, NULL); /* * Create lock to allow only one thread at a time to send command * to the daemon. */ GateThread_Params_init(¶ms); dcmd.gate = GateThread_create(¶ms, NULL); if ((dcmd.cmdPresent == NULL) || (dcmd.replyPresent == NULL) || (dcmd.gate == NULL)) { // TODO: Shouldn't we abort? Log_print0(Diags_USER7, "[+7] Processor_init> ERROR: cannot" " create semaphores or lock"); } Log_print0(Diags_USER2, "[+2] Processor_init> SysLink_setup()..."); SysLink_setup(); Log_print0(Diags_USER2, "[+2] Processor_init> " "... SysLink_setup() done"); if ((dcmd.dproc = Thread_create((Thread_RunFxn)daemon, NULL, NULL)) == NULL) { Log_print0(Diags_USER7, "[+7] Processor_init> " "ERROR: cannot create DSP daemon"); } if (Thread_start(NULL) != TRUE) { Log_print0(Diags_USER7, "[+7] Processor_init> " "ERROR: cannot start threads"); } Global_atexit((Fxn)cleanup); } }