1bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo/* -------------------------------------------------------------------------------
2bfff6343845ad9ff062c5fd97bb3b9be1053340eDante RussoCopyright (c) 2009, QUALCOMM USA, INC.
3bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
4bfff6343845ad9ff062c5fd97bb3b9be1053340eDante RussoAll rights reserved.
5bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
6bfff6343845ad9ff062c5fd97bb3b9be1053340eDante RussoRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
8bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo�         Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
10bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo�         Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
12bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo�         Neither the name of the QUALCOMM USA, INC.  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
14bfff6343845ad9ff062c5fd97bb3b9be1053340eDante RussoTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo -------------------------------------------------------------------------------
16bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo */
17bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include "rpc/rpc.h"
18bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include "loc_api_common.h"
19bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include "loc_api.h"
20bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include "loc_api_cb.h"
21bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include "loc_api_fixup.h"
22bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
23bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#include "loc_apicb_appinit.h"
24bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
25bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#define RPC_FUNC_VERSION_BASE(a,b) a ## b
26bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)
27bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
28bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russostatic SVCXPRT* svrPort = NULL;
29bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
30bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russoextern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);
31bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
32bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russoint loc_apicb_app_init(void)
33bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo{
34bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    /* Register a callback server to use the loc_apicbprog_* function  */
35bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    if (svrPort == NULL) {
36bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        svrPort = svcrtr_create();
37bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
38bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    if (!svrPort) return -1;
39bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
40bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    xprt_register(svrPort);
41bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    if(svc_register(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))
42bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    {
43bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        return 0;
44bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
45bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    else
46bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    {
47bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        return -1;
48bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
49bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo}
50bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo
51bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russovoid loc_apicb_app_deinit(void)
52bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo{
53bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    if (svrPort == NULL)
54bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    {
55bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo        return;
56bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    }
57bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    xprt_unregister(svrPort);
58bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    svc_destroy(svrPort);
59bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    //svc_unregister(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001);
60bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo    svrPort = NULL;
61bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo}
62