Exemplo n.º 1
0
/*
 *  ======== NameServerDrv_ioctl ========
 *
 */
static long NameServerDrv_ioctl(struct file *filp, unsigned int cmd,
                                unsigned long args)
{
    int                         osStatus = 0;
    Int32                       status = NameServer_S_SUCCESS;
    Int32                       ret;
    NameServerDrv_CmdArgs       cargs;
    Osal_Pid                    pid;

    GT_3trace(curTrace, GT_ENTER, "NameServerDrv_ioctl", filp, cmd, args);

    /* save the process id for resource tracking */
    pid = pid_nr(filp->f_owner.pid);

    /* copy the full args from user space */
    ret = copy_from_user(&cargs, (Ptr)args, sizeof(NameServerDrv_CmdArgs));
    GT_assert(curTrace, (ret == 0));

    switch (cmd) {
    case CMD_NAMESERVER_ADD: {
        NameServerDrv_Res * res = NULL;
        Ptr                 buf;

        /* allocate resource tracker object */
        res = Memory_alloc(NULL, sizeof(NameServerDrv_Res), 0, NULL);

        if (res == NULL) {
            status = NameServer_E_MEMORY;
            GT_setFailureReason(curTrace, GT_4CLASS,
                                "NameServerDrv_ioctl", status, "out of memory");
        }

        /* allocate memory for the name */
        if (status == NameServer_S_SUCCESS) {
            res->args.add.len = cargs.args.add.nameLen;
            res->args.add.name = Memory_alloc(NULL,
                                              cargs.args.add.nameLen, 0, NULL);

            if (res->args.add.name == NULL) {
                status = NameServer_E_MEMORY;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status, "out of memory");
            }
        }

        /* copy the name from user memory */
        if (status == NameServer_S_SUCCESS) {
            status = copy_from_user(res->args.add.name,
                                    cargs.args.add.name, cargs.args.add.nameLen);

            if (status != 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "copy_from_user failed");
                status = NameServer_E_OSFAILURE;
                osStatus = -EFAULT;
            }
        }

        /* allocate memory for the buf */
        if (status == NameServer_S_SUCCESS) {
            buf = Memory_alloc(NULL, cargs.args.add.len, 0, NULL);

            if (buf == NULL) {
                status = NameServer_E_MEMORY;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status, "out of memory");
            }
        }

        /* copy the value from user buf */
        if (status == NameServer_S_SUCCESS) {
            status = copy_from_user(buf, cargs.args.add.buf,
                                    cargs.args.add.len);

            if (status != 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "copy_from_user failed");
                status = NameServer_E_OSFAILURE;
                osStatus = -EFAULT;
            }
        }

        /* invoke the module api */
        if (status == NameServer_S_SUCCESS) {
            cargs.args.add.entry = NameServer_add(cargs.args.add.handle,
                                                  res->args.add.name, buf, cargs.args.add.len);

            if (cargs.args.addUInt32.entry == NULL) {
                status = NameServer_E_FAIL;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "NameServer_addUInt32 failed");
            }
        }

        /* track the resource by process id */
        if (status == NameServer_S_SUCCESS) {
            Int rstat;

            res->cmd = CMD_NAMESERVER_ADD; /* use this command for both */
            res->args.add.handle = cargs.args.add.handle;
            res->args.add.entry = cargs.args.add.entry;

            rstat = ResTrack_push(NameServerDrv_state.resTrack, pid,
                                  (List_Elem *)res);

            GT_assert(curTrace, (rstat >= 0));
        }

        /* don't need the buf memory anymore */
        if (buf != NULL) {
            Memory_free(NULL, buf, cargs.args.add.len);
        }

        /* failure cleanup */
        if (status < 0) {
            if ((res != NULL) && (res->args.add.name != NULL)) {
                Memory_free(NULL, res->args.add.name,
                            cargs.args.add.nameLen);
            }
            if (res != NULL) {
                Memory_free(NULL, res, sizeof(NameServerDrv_Res));
            }
        }
    }
    break;

    case CMD_NAMESERVER_ADDUINT32: {
        NameServerDrv_Res * res = NULL;

        /* allocate resource tracker object */
        res = Memory_alloc(NULL, sizeof(NameServerDrv_Res), 0, NULL);

        if (res == NULL) {
            status = NameServer_E_MEMORY;
            GT_setFailureReason(curTrace, GT_4CLASS,
                                "NameServerDrv_ioctl", status, "out of memory");
        }

        /* allocate memory for the name */
        if (status == NameServer_S_SUCCESS) {
            res->args.add.len = cargs.args.addUInt32.nameLen;
            res->args.add.name = Memory_alloc(NULL,
                                              cargs.args.addUInt32.nameLen, 0, NULL);

            if (res->args.add.name == NULL) {
                status = NameServer_E_MEMORY;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status, "out of memory");
            }
        }

        /* copy the name from user memory */
        if (status == NameServer_S_SUCCESS) {
            status = copy_from_user(res->args.add.name,
                                    cargs.args.addUInt32.name,
                                    cargs.args.addUInt32.nameLen);

            if (status != 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "copy_from_user failed");
                status = NameServer_E_OSFAILURE;
                osStatus = -EFAULT;
            }
        }

        /* invoke the module api */
        if (status == NameServer_S_SUCCESS) {
            cargs.args.addUInt32.entry = NameServer_addUInt32(
                                             cargs.args.addUInt32.handle, res->args.add.name,
                                             cargs.args.addUInt32.value);

            if (cargs.args.addUInt32.entry == NULL) {
                status = NameServer_E_FAIL;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "NameServer_addUInt32 failed");
            }
        }

        /* track the resource by process id */
        if (status == NameServer_S_SUCCESS) {
            Int rstat;

            res->cmd = CMD_NAMESERVER_ADD; /* use this command for both */
            res->args.add.handle = cargs.args.addUInt32.handle;
            res->args.add.entry = cargs.args.addUInt32.entry;

            rstat = ResTrack_push(NameServerDrv_state.resTrack, pid,
                                  (List_Elem *)res);

            GT_assert(curTrace, (rstat >= 0));
        }

        /* failure cleanup */
        if (status < 0) {
            if ((res != NULL) && (res->args.add.name != NULL)) {
                Memory_free(NULL, res->args.add.name,
                            cargs.args.addUInt32.nameLen);
            }
            if (res != NULL) {
                Memory_free(NULL, res, sizeof(NameServerDrv_Res));
            }
        }
    }
    break;

    case CMD_NAMESERVER_GET:
    {
        String   name;
        Ptr      value;
        UInt16 * procId = NULL;

        /* Allocate memory for the name */
        name = Memory_alloc (NULL, cargs.args.get.nameLen, 0, NULL);
        GT_assert (curTrace, (name != NULL));
        /* Copy the name */
        ret = copy_from_user (name,
                              cargs.args.get.name,
                              cargs.args.get.nameLen);
        GT_assert (curTrace, (ret == 0));

        /* Allocate memory for the buf */
        value = Memory_alloc (NULL, cargs.args.get.len, 0, NULL);
        GT_assert (curTrace, (value != NULL));

        /* Allocate memory for the procId */
        if (cargs.args.get.procLen > 0) {
            procId = Memory_alloc (NULL,
                                   cargs.args.get.procLen * sizeof(UInt16),
                                   0,
                                   NULL);
            GT_assert (curTrace, (procId != NULL));
        }
        /* Copy the procIds */
        ret = copy_from_user (procId,
                              cargs.args.get.procId,
                              cargs.args.get.procLen);
        GT_assert (curTrace, (ret == 0));

        status = NameServer_get (cargs.args.get.handle,
                                 name,
                                 value,
                                 &cargs.args.get.len,
                                 procId);
        /* Do not assert. This can return NameServer_E_NOTFOUND
         * as a valid runtime failure.
         */

        /* Copy the value */
        ret = copy_to_user (cargs.args.get.value,
                            value,
                            cargs.args.get.len);
        GT_assert (curTrace, (ret == 0));

        /* free the allocated memory */
        Memory_free (NULL, name, cargs.args.get.nameLen);
        Memory_free (NULL, value, cargs.args.get.len);
        if (procId != NULL) {
            Memory_free (NULL,
                         procId,
                         cargs.args.get.procLen *sizeof(UInt16));
        }

    }
    break;

    case CMD_NAMESERVER_GETLOCAL:
    {
        String   name;
        Ptr      value;

        /* Allocate memory for the name */
        name = Memory_alloc (NULL, cargs.args.getLocal.nameLen, 0, NULL);
        GT_assert (curTrace, (name != NULL));
        /* Copy the name */
        ret = copy_from_user (name,
                              cargs.args.getLocal.name,
                              cargs.args.getLocal.nameLen);
        GT_assert (curTrace, (ret == 0));

        /* Allocate memory for the buf */
        value = Memory_alloc (NULL, cargs.args.getLocal.len, 0, NULL);
        GT_assert (curTrace, (value != NULL));

        status = NameServer_getLocal (cargs.args.getLocal.handle,
                                      name,
                                      value,
                                      &cargs.args.getLocal.len);
        GT_assert (curTrace, (status >= 0));

        /* Copy the value */
        ret = copy_to_user (cargs.args.getLocal.value,
                            value,
                            cargs.args.getLocal.len);
        GT_assert (curTrace, (ret == 0));

        /* free the allocated memory */
        Memory_free (NULL, name, cargs.args.getLocal.nameLen);
        Memory_free (NULL, value,  cargs.args.getLocal.len);
    }
    break;

    case CMD_NAMESERVER_MATCH:
    {
        String name;

        /* Allocate memory for the name */
        name = Memory_alloc (NULL, cargs.args.match.nameLen, 0, NULL);
        GT_assert (curTrace, (name != NULL));
        /* Copy the name */
        ret = copy_from_user (name,
                              cargs.args.match.name,
                              cargs.args.match.nameLen);
        GT_assert (curTrace, (ret == 0));

        cargs.args.match.count = NameServer_match (
                                     cargs.args.match.handle,
                                     name,
                                     &cargs.args.match.value);
        GT_assert (curTrace, (cargs.args.match.count >= 0));

        /* free the allocated memory */
        Memory_free (NULL, name, cargs.args.match.nameLen);
    }
    break;

    case CMD_NAMESERVER_REMOVE: {
        NameServerDrv_Res   res;
        List_Elem *         elem;

        /* save for resource untracking */
        res.cmd = CMD_NAMESERVER_ADD;
        res.args.add.entry = NULL;

        /* allocate memory for the name */
        res.args.add.len = cargs.args.remove.nameLen;
        res.args.add.name = Memory_alloc(NULL,
                                         cargs.args.remove.nameLen, 0, NULL);

        if (res.args.add.name == NULL) {
            status = NameServer_E_MEMORY;
            GT_setFailureReason(curTrace, GT_4CLASS,
                                "NameServerDrv_ioctl", status, "out of memory");
        }

        /* copy the name from user memory */
        if (status == NameServer_S_SUCCESS) {
            status = copy_from_user(res.args.add.name,
                                    cargs.args.remove.name, cargs.args.remove.nameLen);

            if (status != 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "copy_from_user failed");
                status = NameServer_E_OSFAILURE;
                osStatus = -EFAULT;
            }
        }

        /* invoke the module api */
        if (status == NameServer_S_SUCCESS) {
            status = NameServer_remove(cargs.args.remove.handle,
                                       res.args.add.name);

            if (status < 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "NameServer_remove failed");
            }
        }

        /* untrack the resource */
        if (status == NameServer_S_SUCCESS) {
            NameServerDrv_Res * resPtr;

            ResTrack_remove(NameServerDrv_state.resTrack, pid,
                            (List_Elem *)(&res), NameServerDrv_resCmpFxn, &elem);

            GT_assert(curTrace, (elem != NULL));

            resPtr = (NameServerDrv_Res *)elem;
            Memory_free(NULL, resPtr->args.add.name, resPtr->args.add.len);
            Memory_free(NULL, elem, sizeof(NameServerDrv_Res));
        }

        /* don't need the name memory anymore */
        if (res.args.add.name != NULL) {
            Memory_free(NULL, res.args.add.name,
                        cargs.args.remove.nameLen);
        }
    }
    break;

    case CMD_NAMESERVER_REMOVEENTRY: {
        NameServerDrv_Res   res;
        List_Elem *         elem;

        /* save for resource untracking */
        res.cmd = CMD_NAMESERVER_ADD;
        res.args.add.name = NULL;
        res.args.add.entry = cargs.args.removeEntry.entry;

        /* invoke the module api */
        status = NameServer_removeEntry(cargs.args.removeEntry.handle,
                                        cargs.args.removeEntry.entry);

        if (status < 0) {
            GT_setFailureReason(curTrace, GT_4CLASS, "NameServerDrv_ioctl",
                                status, "NameServer_remove failed");
        }

        /* untrack the resource */
        if (status == NameServer_S_SUCCESS) {
            NameServerDrv_Res * resPtr;

            ResTrack_remove(NameServerDrv_state.resTrack, pid,
                            (List_Elem *)(&res), NameServerDrv_resCmpFxn, &elem);

            GT_assert(curTrace, (elem != NULL));

            resPtr = (NameServerDrv_Res *)elem;
            Memory_free(NULL, resPtr->args.add.name, resPtr->args.add.len);
            Memory_free(NULL, elem, sizeof(NameServerDrv_Res));
        }
    }
    break;

    case CMD_NAMESERVER_PARAMS_INIT:
    {
        NameServer_Params params;

        NameServer_Params_init (&params);
        ret = copy_to_user (cargs.args.ParamsInit.params,
                            &params,
                            sizeof (NameServer_Params));
        GT_assert (curTrace, (ret == 0));
    }
    break;

    case CMD_NAMESERVER_CREATE: {
        NameServer_Params   params;
        String              name = NULL;
        NameServerDrv_Res * res = NULL;

        /* allocate memory for the name */
        name = Memory_alloc(NULL, cargs.args.create.nameLen, 0, NULL);

        if (name == NULL) {
            status = NameServer_E_MEMORY;
            GT_setFailureReason(curTrace, GT_4CLASS,
                                "NameServerDrv_ioctl", status, "out of memory");
        }

        /* copy the name from user memory */
        if (status == NameServer_S_SUCCESS) {
            status = copy_from_user(name, cargs.args.create.name,
                                    cargs.args.create.nameLen);

            if (status != 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "copy_from_user failed");
                status = NameServer_E_OSFAILURE;
                osStatus = -EFAULT;
            }
        }

        /* copy the params from user memory */
        if (status == NameServer_S_SUCCESS) {
            status = copy_from_user(&params, cargs.args.create.params,
                                    sizeof(NameServer_Params));

            if (status != 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "copy_from_user failed");
                status = NameServer_E_OSFAILURE;
                osStatus = -EFAULT;
            }
        }

        /* allocate resource tracker object */
        if (status == NameServer_S_SUCCESS) {
            res = Memory_alloc(NULL, sizeof(NameServerDrv_Res), 0, NULL);

            if (res == NULL) {
                status = NameServer_E_MEMORY;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status, "out of memory");
            }
        }

        /* invoke the module api */
        if (status == NameServer_S_SUCCESS) {
            cargs.args.create.handle = NameServer_create(name, &params);

            if (cargs.args.create.handle == NULL) {
                status = NameServer_E_FAIL;
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "NameServer_create failed");
            }
        }

        /* track the resource by process id */
        if (status == NameServer_S_SUCCESS) {
            Int rstat;

            res->cmd = cmd;
            res->args.create.handle = cargs.args.create.handle;

            rstat = ResTrack_push(NameServerDrv_state.resTrack, pid,
                                  (List_Elem *)res);

            GT_assert(curTrace, (rstat >= 0));
        }

        /* don't need name memory anymore */
        if (name != NULL) {
            Memory_free(NULL, name, cargs.args.create.nameLen);
        }

        /* failure cleanup */
        if (status < 0) {
            if (res != NULL) {
                Memory_free(NULL, res, sizeof(NameServerDrv_Res));
            }
        }
    }
    break;

    case CMD_NAMESERVER_DELETE: {
        NameServerDrv_Res   res;
        List_Elem *         elem;

        /* save for resource untracking, handle set to null by delete */
        res.cmd = CMD_NAMESERVER_CREATE;
        res.args.create.handle = cargs.args.delete.handle;

        /* common code for delete command */
        status = NameServerDrv_cmd_delete(&cargs.args.delete.handle);

        /* untrack the resource */
        if (status == NameServer_S_SUCCESS) {
            ResTrack_remove(NameServerDrv_state.resTrack, pid,
                            (List_Elem *)(&res), NameServerDrv_resCmpFxn, &elem);

            GT_assert(curTrace, (elem != NULL));
            Memory_free(NULL, elem, sizeof(NameServerDrv_Res));
        }
    }
    break;

    case CMD_NAMESERVER_GETHANDLE:
    {
        String   name;

        /* Allocate memory for the name */
        name = Memory_alloc (NULL, cargs.args.getHandle.nameLen, 0, NULL);
        GT_assert (curTrace, (name != NULL));
        /* Copy the name */
        ret = copy_from_user (name,
                              cargs.args.getHandle.name,
                              cargs.args.getHandle.nameLen);
        GT_assert (curTrace, (ret == 0));

        cargs.args.getHandle.handle = NameServer_getHandle (name);

        /* free the allocated memory */
        Memory_free (NULL, name, cargs.args.getHandle.nameLen);
    }
    break;

    case CMD_NAMESERVER_SETUP: {
        /* register process with resource tracker */
        status = ResTrack_register(NameServerDrv_state.resTrack, pid);

        if (status < 0) {
            GT_setFailureReason(curTrace, GT_4CLASS, "NameServerDrv_ioctl",
                                status, "resource tracker register failed");
            status = NameServer_E_FAIL;
            pid = 0;
        }

        /* setup the module */
        if (status == NameServer_S_SUCCESS) {
            status = NameServer_setup();

            if (status < 0) {
                GT_setFailureReason(curTrace, GT_4CLASS,
                                    "NameServerDrv_ioctl", status,
                                    "kernel-side MessageQ_setup failed");
            }
        }

        /* failure case */
        if (status < 0) {
            if (pid != 0) {
                ResTrack_unregister(NameServerDrv_state.resTrack, pid);
            }
        }
    }
    break;

    case CMD_NAMESERVER_DESTROY: {
        /* unregister process from resource tracker */
        status = ResTrack_unregister(NameServerDrv_state.resTrack, pid);
        GT_assert(curTrace, (status >= 0));

        /* finalize the module */
        status = NameServer_destroy();
        GT_assert(curTrace, (status >= 0));
    }
    break;

    default:
    {
        /* This does not impact return status of this function, so retVal
         * comment is not used.
         */
        status = NameServer_E_INVALIDARG;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "NameServerDrv_ioctl",
                             status,
                             "Unsupported ioctl command specified");
    }
    break;
    }

    cargs.apiStatus = status;

    /* copy the full args back to user space */
    ret = copy_to_user((Ptr)args, &cargs, sizeof(NameServerDrv_CmdArgs));
    GT_assert (curTrace, (ret == 0));

    GT_1trace (curTrace, GT_LEAVE, "NameServerDrv_ioctl", osStatus);

    /*! @retval 0 Operation successfully completed. */
    return osStatus;
}
Exemplo n.º 2
0
/* Function to setup the System. */
Int
Ipc_setup (const Ipc_Config * cfg)
{
    Int            status = Ipc_S_SUCCESS;
    Ipc_Config *   config = NULL;
    Ipc_Config     tConfig;
    IpcKnl_Config  kConfig;
    IpcDrv_CmdArgs cmdArgs;

    GT_1trace (curTrace, GT_ENTER, "Ipc_setup", cfg);

    if (cfg == NULL) {
        Ipc_getConfig (&tConfig);
        config = &tConfig;
    }
    else {
        config = (Ipc_Config *) cfg;
    }

    /* TBD: Protect from multiple threads. */
    Ipc_state.setupRefCount++;
    /* This is needed at runtime so should not be in SYSLINK_BUILD_OPTIMIZE. */
    if (Ipc_state.setupRefCount > 1) {
        /*! @retval Ipc_S_ALREADYSETUP Success: Ipc module has been
                                           already setup in this process */
        status = Ipc_S_ALREADYSETUP;
        GT_1trace (curTrace,
                   GT_1CLASS,
                   "Ipc module has been already setup in this process.\n"
                   "    RefCount: [%d]\n",
                   Ipc_state.setupRefCount);
    }
    else {
        /* Call the kernel Ipc_setup to allow configuration from user-space */
        /* Open the driver handle. */
        status = IpcDrv_open ();
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "Failed to open driver handle!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            /* Configure the ipcSyncConfig as PAIR always */
            kConfig.ipcSyncConfig = Ipc_ProcSync_PAIR;

            cmdArgs.args.setup.config = (IpcKnl_Config *) &kConfig;
            status = IpcDrv_ioctl (CMD_IPC_SETUP, &cmdArgs);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
            if (status < 0) {
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "Ipc_setup",
                                     status,
                                     "API (through IOCTL) failed on kernel-side!");
            }
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    if (status >= 0) {
        UsrUtilsDrv_setup ();
    }

    if (status >= 0) {
        status = MultiProc_setup (&(config->multiProcConfig));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "MultiProc_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.multiProcInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

#if 0 /* TBD:Temporarily comment. */
    if (status >= 0) {
        status = SysMemMgr_setup (&(config->sysMemMgrConfig));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "SysMemMgr_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.sysMemMgrInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }
#endif /* TBD: Temporarily comment. */

    /* Initialize NAMESERVER */
    if (status >= 0) {
        status = NameServer_setup ();
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "NameServer_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.nameServerInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Initialize PROCMGR */
    if (status >= 0) {
        status = ProcMgr_setup (&(config->procMgrConfig));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "ProcMgr_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.procMgrInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Initialize SharedRegion */
    if (status >= 0) {
        status = SharedRegion_setup (&config->sharedRegionConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "SharedRegion_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.sharedRegionInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Initialize GateMP */
    if (status >= 0) {
        status = GateMP_setup (&config->gateMPConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "GateMP_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.gateMPInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Initialize NOTIFY */
    if (status >= 0) {
        status = Notify_setup (&config->notifyConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "Notify_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.notifyInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Intialize MESSAGEQ */
    if (status >= 0) {
        status = MessageQ_setup (&config->messageQConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "MessageQ_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.messageQInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Intialize HeapBufMP */
    if (status >= 0) {
        status = HeapBufMP_setup (&config->heapBufMPConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "HeapBufMP_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.heapBufMPInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Intialize HeapMemMP */
    if (status >= 0) {
        status = HeapMemMP_setup (&config->heapMemMPConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "HeapMemMP_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.heapMemMPInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

#if 0 /* TBD:Temporarily comment. */
    /* Intialize HeapMultiBuf */
    if (status >= 0) {
        status = HeapMultiBuf_setup (&config->heapMultiBufConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "HeapMultiBuf_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.heapMultiBufInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }
#endif /* TBD: Temporarily comment. */

    /* Get the LISTMP default config */
    if (status >= 0) {
        status = ListMP_setup (&config->listMPConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "ListMP_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.listMPInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

#if 0 /* TBD:Temporarily comment. */
    /* Get the ClientNotifyMgr default config */
    if (status >= 0) {
        status = ClientNotifyMgr_setup ( &config->cliNotifyMgrCfgParams);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                     status,
                                     "ClientNotifyMgr_setup failed!");
            }
            else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
                Ipc_state.clientNotifyMgrInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
            }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Get the FrameQBufMgr default config */
    if (status >= 0) {
        status = FrameQBufMgr_setup ( &config->frameQBufMgrCfgParams);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "FrameQBufMgr_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.frameQBufMgrInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    /* Get the FrameQ default config */
    if (status >= 0) {
        status = FrameQ_setup ( &config->frameQCfgParams);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Ipc_setup",
                                 status,
                                 "FrameQ_setup failed!");
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Ipc_state.frameQInitFlag = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }
#endif /* TBD: Temporarily comment. */

    GT_1trace (curTrace, GT_LEAVE, "Ipc_setup", status);

    /*! @retval Ipc_S_SUCCESS Operation successful */
    return status;
}