1/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of The Linux Foundation nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "rpc/rpc.h"
30
31/* Include RPC headers */
32#ifdef USE_LOCAL_RPC
33#include "rpc_inc/loc_api_common.h"
34#include "rpc_inc/loc_api.h"
35#include "rpc_inc/loc_api_cb.h"
36#endif
37
38#ifdef USE_QCOM_AUTO_RPC
39#include "loc_api_rpcgen_rpc.h"
40#include "loc_api_rpcgen_common_rpc.h"
41#include "loc_api_rpcgen_cb_rpc.h"
42#endif
43
44#include "rpc_inc/loc_api_fixup.h"
45#include "loc_apicb_appinit.h"
46
47#define RPC_FUNC_VERSION_BASE(a,b) a ## b
48#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)
49
50static SVCXPRT* svrPort = NULL;
51
52extern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);
53
54int loc_apicb_app_init(void)
55{
56
57  /* Register a callback server to use the loc_apicbprog_* function  */
58  if (svrPort == NULL) {
59        svrPort = svcrtr_create();
60  }
61  if (!svrPort) return -1;
62
63  xprt_register(svrPort);
64  if(svc_register(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))
65  {
66     return 0;
67  }
68  else
69  {
70    return -1;
71  }
72}
73
74void loc_apicb_app_deinit(void)
75{
76   if (svrPort == NULL)
77   {
78      return;
79   }
80
81   svc_unregister(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001);
82   xprt_unregister(svrPort);
83   svc_destroy(svrPort);
84   svrPort = NULL;
85}
86
87