/** * Handler for messageq setup API. * * \param ctp Thread's associated context information. * \param msg The actual devctl() message. * \param ocb OCB associated with client's session. * * \return POSIX errno value. * * \retval EOK Success. * \retval ENOTSUP Unsupported devctl(). */ int syslink_messageq_setup(resmgr_context_t *ctp, io_devctl_t *msg, syslink_ocb_t *ocb) { MessageQDrv_CmdArgs * cargs = (MessageQDrv_CmdArgs *) (_DEVCTL_DATA (msg->i)); MessageQDrv_CmdArgs * out = (MessageQDrv_CmdArgs *) (_DEVCTL_DATA (msg->o)); MessageQ_Config *local_setupconfig; local_setupconfig = (MessageQ_Config *)(cargs+1); out->apiStatus = MessageQ_setup (local_setupconfig); GT_assert (curTrace, (out->apiStatus >= 0)); if (out->apiStatus >= 0) { /* Add this call to the list to be cleaned-up */ add_ocb_res(ocb, DCMD_MESSAGEQ_DESTROY, NULL, NULL); } SETIOV(&ctp->iov[0], &msg->o, sizeof(msg->o) + sizeof(MessageQDrv_CmdArgs)); return _RESMGR_NPARTS(1); }
/* 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; }