]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - packages/ti/ipc/mm/MmServiceMgr.c
Support in QNX MmRpc/MmServiceMgr to identify deleted instance during cleanup
[ipc/ipcdev.git] / packages / ti / ipc / mm / MmServiceMgr.c
index 042b08da2dfbe9b090e6a963082e3f34eb2e48fd..94207ed3bf5699a242fae0b00c784f2eb41f998d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Texas Instruments Incorporated
+ * Copyright (c) 2013-2014, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -71,7 +71,7 @@ Int MmServiceMgr_init(Void)
     }
 
     RcmServer_init();
-//  ServiceMgr_init();
+/*  ServiceMgr_init(); */
 
     return(MmServiceMgr_S_SUCCESS);
 }
@@ -94,7 +94,6 @@ Void MmServiceMgr_exit(Void)
 Int MmServiceMgr_register(const String name, RcmServer_Params *rcmParams,
         MmType_FxnSigTab *fxnSigTab, MmServiceMgr_DelFxn delFxn)
 {
-#if 1
     Int status = MmServiceMgr_S_SUCCESS;
     OmapRpc_Handle handle;
 
@@ -106,114 +105,24 @@ Int MmServiceMgr_register(const String name, RcmServer_Params *rcmParams,
     }
 
     return(status);
-#else
-    Int status = MmServiceMgr_S_SUCCESS;
-    MmServiceMgr_Client *obj;
-    RcmServer_FxnDesc *fxnAry;
-    Int func;
-
-    System_printf("MmServiceMgr_register: -->\n");
-
-    obj = Memory_calloc(NULL, sizeof(MmServiceMgr_Client), 0, NULL);
-
-    if (obj == NULL) {
-        System_printf("MmServiceMgr_register: Error: out of memory\n");
-        status = MmServiceMgr_E_FAIL;
-        goto leave;
-    }
-
-    /* Temporary: make a local copy of server create params in order
-     * to add one more function to the function table. Will be removed.
-     */
-    memcpy(&obj->rcmParams, rcmParams, sizeof(RcmServer_Params));
-    obj->rcmParams.fxns.length = rcmParams->fxns.length + 1;
-
-    obj->rcmParams.fxns.elem = Memory_calloc(NULL, obj->rcmParams.fxns.length *
-            sizeof(RcmServer_FxnDesc), 0, NULL);
-
-    if (obj->rcmParams.fxns.elem == NULL) {
-        System_printf("MmServiceMgr_register: Error: out of memory\n");
-        status = MmServiceMgr_E_FAIL;
-        goto leave;
-    }
-
-    /* Temporary: make a local copy of signature array in order
-     * to add the "first function" signature. Will be removed.
-     */
-    obj->aryLen = aryLen + 1;
-
-    obj->sigAry = Memory_calloc(NULL, obj->aryLen *
-            sizeof(OmapRpc_FuncSignature), 0, NULL);
-
-    if (obj->sigAry == NULL) {
-        System_printf("MmServiceMgr_register: Error: out of memory\n");
-        status = MmServiceMgr_E_FAIL;
-        goto leave;
-    }
-
-    /* Temporary: insert the "first function" in slot 0, then copy
-     * in the caller's functions. Eventually, the create function will be
-     * removed.
-     */
-    obj->rcmParams.fxns.elem[0].name =
-            OmapRpc_Stringerize(OmapRpc_GetSvrMgrHandle);
-    obj->rcmParams.fxns.elem[0].addr.createFxn =
-            (RcmServer_MsgCreateFxn)OmapRpc_GetSvrMgrHandle;
-    strncpy(obj->sigAry[0].name, obj->rcmParams.fxns.elem[0].name,
-            OMAPRPC_MAX_CHANNEL_NAMELEN);
-    obj->sigAry[0].numParam = 0;
-
-    fxnAry = rcmParams->fxns.elem;
-
-    for (func = 0; func < rcmParams->fxns.length; func++) {
-        obj->rcmParams.fxns.elem[func+1].name = fxnAry[func].name;
-        obj->rcmParams.fxns.elem[func+1].addr.fxn = fxnAry[func].addr.fxn;
-
-        memcpy(&obj->sigAry[func+1], &sigAry[func],
-                sizeof(OmapRpc_FuncSignature));
-    }
-
-    if (!ServiceMgr_register(name, &obj->rcmParams)) {
-        System_printf("MmServiceMgr_register: Error: service register failed, "
-                "status=%d\n");
-        status = MmServiceMgr_E_FAIL;
-        goto leave;
-    }
-
-leave:
-    if (status < 0) {
-        if ((obj != NULL) && (obj->sigAry != NULL)) {
-            Memory_free(NULL, obj->sigAry,
-                    obj->aryLen * sizeof(OmapRpc_FuncDeclaration));
-        }
-        if ((obj != NULL) && (obj->rcmParams.fxns.elem != NULL)) {
-            Memory_free(NULL, obj->rcmParams.fxns.elem,
-                    obj->rcmParams.fxns.length * sizeof(RcmServer_FxnDesc));
-        }
-        if (obj != NULL) {
-            Memory_free(NULL, obj, sizeof(MmServiceMgr_Client));
-        }
-    }
-
-    System_printf("MmServiceMgr_register: <--, status=%d\n", status);
-    return(status);
-#endif
 }
 
-#if 0
+
 /*
- *  ======== MmServiceMgr_start ========
+ *  ======== MmServiceMgr_register2 ========
  */
-Int MmServiceMgr_start(const String name, Int aryLen,
-        OmapRpc_FuncSignature *sigAry)
+Int MmServiceMgr_register2(const String name, RcmServer_Params *rcmParams,
+        MmType_FxnSigTab *fxnSigTab, MmServiceMgr_DelFxn2 delFxn)
 {
-    extern Int OmapRpc_start(const String name, Int port, Int aryLen,
-        OmapRpc_FuncSignature *sigAry);
-
     Int status = MmServiceMgr_S_SUCCESS;
+    OmapRpc_Handle handle;
+
+    handle = OmapRpc_createChannel2(name, MultiProc_getId("HOST"),
+            MmServiceMgr_PORT, rcmParams, fxnSigTab, delFxn);
 
-    OmapRpc_start(name, MmServiceMgr_PORT, aryLen, sigAry);
+    if (handle == NULL) {
+        status = MmServiceMgr_E_FAIL;
+    }
 
     return(status);
 }
-#endif