Int RcmClient_create(String server, const RcmClient_Params *params, RcmClient_Handle *handle) { RcmClient_Object *obj; Error_Block eb; Int status = RcmClient_S_SUCCESS; Log_print1(Diags_ENTRY, "--> %s: ()", (IArg)FXNN); /* initialize the error block */ Error_init(&eb); *handle = (RcmClient_Handle)NULL; /* TODO: add check that params was initialized correctly */ /* allocate the object */ obj = (RcmClient_Handle)xdc_runtime_Memory_calloc(RcmClient_Module_heap(), sizeof(RcmClient_Object), sizeof(Int), &eb); if (NULL == obj) { Log_error2(FXNN": out of memory: heap=0x%x, size=%u", (IArg)RcmClient_Module_heap(), sizeof(RcmClient_Object)); status = RcmClient_E_NOMEMORY; goto leave; } Log_print1(Diags_LIFECYCLE, FXNN": instance create: 0x%x", (IArg)obj); /* object-specific initialization */ status = RcmClient_Instance_init(obj, server, params); if (status < 0) { RcmClient_Instance_finalize(obj); xdc_runtime_Memory_free(RcmClient_Module_heap(), (Ptr)obj, sizeof(RcmClient_Object)); goto leave; } /* success, return opaque pointer */ *handle = (RcmClient_Handle)obj; leave: Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status); return(status); }
Int SystemCfg_create(const SystemCfg_Params *params, SystemCfg_Handle *handleP) { Int status, bufSize; Error_Block eb; SystemCfg_Object * obj; Semaphore_Params semParams; Log_print0(Diags_ENTRY, "--> "FXNN": ()"); /* initialize local vars */ status = 0; Error_init(&eb); *handleP = (SystemCfg_Handle)NULL; /* allocate the object */ obj = (SystemCfg_Handle)xdc_runtime_Memory_calloc(NULL, sizeof(SystemCfg_Object), sizeof(Int), &eb); if (obj == NULL) { Log_error1(FXNN": out of memory: size=%u", sizeof(SystemCfg_Object)); status = SystemCfg_E_NOMEMORY; goto leave; } /* object-specific initialization */ obj->remoteProcName = NULL; obj->remoteProcId = MultiProc_INVALIDID; obj->semH = NULL; obj->rcmHeapH = NULL; /* initialize structures to zero */ memset((Void *)&obj->semObj, 0, sizeof(Semaphore_Struct)); /* store the remote processor name */ bufSize = strlen(params->remoteProcName) + 1; obj->remoteProcName = (String)xdc_runtime_Memory_calloc(NULL, bufSize, sizeof(String), &eb); if (obj == NULL) { Log_error1(FXNN": out of memory: size=%u", bufSize); status = SystemCfg_E_NOMEMORY; goto leave; } strcpy(obj->remoteProcName, params->remoteProcName); /* lookup the remote processor id */ obj->remoteProcId = MultiProc_getId(obj->remoteProcName); /* create sync object used for synchronizing with remote core */ Semaphore_Params_init(&semParams); semParams.mode = Semaphore_Mode_COUNTING; Semaphore_construct(&obj->semObj, 0, &semParams); obj->semH = Semaphore_handle(&obj->semObj); /* add object to module list for register hook */ List_putHead(Mod_objList, &obj->link); /* success, return opaque pointer */ *handleP = (SystemCfg_Handle)obj; leave: Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status); return(status); }