94207ed3bf5699a242fae0b00c784f2eb41f998d
1 /*
2 * Copyright (c) 2013-2014, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /*
34 * ======== MmServiceMgr.c ========
35 */
37 #include <string.h>
39 #include <xdc/std.h>
40 #include <xdc/runtime/Memory.h>
41 #include <xdc/runtime/System.h>
43 #include <ti/grcm/RcmServer.h>
44 #include <ti/ipc/MultiProc.h>
45 #include <ti/ipc/mm/MmType.h>
46 #include <ti/srvmgr/ServiceMgr.h>
47 #include <ti/srvmgr/omaprpc/OmapRpc.h>
49 #include "MmServiceMgr.h"
51 #define MmServiceMgr_PORT (59)
53 typedef struct {
54 RcmServer_Params rcmParams;
55 Int aryLen;
56 OmapRpc_FuncSignature *sigAry;
57 } MmServiceMgr_Client;
59 static Int MmServiceMgr_ref = 0;
61 /* temporary: needs to be removed */
62 extern Int32 OmapRpc_GetSvrMgrHandle(Void *srvc, Int32 num, Int32 *params);
64 /*
65 * ======== MmServiceMgr_init ========
66 */
67 Int MmServiceMgr_init(Void)
68 {
69 if (MmServiceMgr_ref++ != 0) {
70 return(MmServiceMgr_S_SUCCESS); /* module already initialized */
71 }
73 RcmServer_init();
74 /* ServiceMgr_init(); */
76 return(MmServiceMgr_S_SUCCESS);
77 }
79 /*
80 * ======== MmServiceMgr_exit ========
81 */
82 Void MmServiceMgr_exit(Void)
83 {
84 if (--MmServiceMgr_ref != 0) {
85 return; /* module still in use */
86 }
88 RcmServer_exit();
89 }
91 /*
92 * ======== MmServiceMgr_register ========
93 */
94 Int MmServiceMgr_register(const String name, RcmServer_Params *rcmParams,
95 MmType_FxnSigTab *fxnSigTab, MmServiceMgr_DelFxn delFxn)
96 {
97 Int status = MmServiceMgr_S_SUCCESS;
98 OmapRpc_Handle handle;
100 handle = OmapRpc_createChannel(name, MultiProc_getId("HOST"),
101 MmServiceMgr_PORT, rcmParams, fxnSigTab, delFxn);
103 if (handle == NULL) {
104 status = MmServiceMgr_E_FAIL;
105 }
107 return(status);
108 }
111 /*
112 * ======== MmServiceMgr_register2 ========
113 */
114 Int MmServiceMgr_register2(const String name, RcmServer_Params *rcmParams,
115 MmType_FxnSigTab *fxnSigTab, MmServiceMgr_DelFxn2 delFxn)
116 {
117 Int status = MmServiceMgr_S_SUCCESS;
118 OmapRpc_Handle handle;
120 handle = OmapRpc_createChannel2(name, MultiProc_getId("HOST"),
121 MmServiceMgr_PORT, rcmParams, fxnSigTab, delFxn);
123 if (handle == NULL) {
124 status = MmServiceMgr_E_FAIL;
125 }
127 return(status);
128 }