]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/gatemp_devctl.c
3bd559fc9dfb6497c890dd1226acadb78f552ecc
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / ipc / hlos / knl / Qnx / gatemp_devctl.c
1 /*
2  * Copyright (c) 2013-2015 Texas Instruments Incorporated - http://www.ti.com
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  *   Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  *
11  *   Redistributions in binary form must reproduce the above copyright
12  *   notice, this list of conditions and the following disclaimer in the
13  *   documentation and/or other materials provided with the
14  *   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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
33 /*
34  *  ======== gatemp_devctl.c ========
35  *
36  */
38 /* Standard headers */
39 #include <ti/syslink/Std.h>
41 /* QNX specific header include */
42 #include <ti/syslink/build/Qnx/resmgr/proto.h>
43 #include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
45 /* Module specific header files */
46 #include <ti/ipc/GateMP.h>
47 #include <ti/syslink/inc/_GateMP_daemon.h>
48 #include <ti/syslink/inc/GateMPDrvDefs.h>
50 /* Function prototypes */
51 int ipc_gatemp_getFreeResource(resmgr_context_t *ctp, io_devctl_t *msg,
52     ipc_ocb_t *ocb);
53 int ipc_gatemp_releaseResource(resmgr_context_t *ctp, io_devctl_t *msg,
54     ipc_ocb_t *ocb);
55 int ipc_gatemp_getNumResources(resmgr_context_t *ctp, io_devctl_t *msg,
56     ipc_ocb_t *ocb);
57 int ipc_gatemp_start(resmgr_context_t *ctp, io_devctl_t *msg,
58     ipc_ocb_t *ocb);
59 int ipc_gatemp_isSetup(resmgr_context_t *ctp, io_devctl_t *msg,
60     ipc_ocb_t *ocb);
62 /**
63  * Handler for devctl() messages for GateMP module.
64  *
65  * Handles special devctl() messages that we export for control.
66  *
67  * \param ctp   Thread's associated context information.
68  * \param msg   The actual devctl() message.
69  * \param ocb   OCB associated with client's session.
70  *
71  * \return POSIX errno value.
72  *
73  * \retval EOK      Success.
74  * \retval ENOTSUP  Unsupported devctl().
75  */
76 int ipc_gatemp_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
77     ipc_ocb_t *ocb)
78 {
80     switch (msg->i.dcmd)
81     {
82       case DCMD_GATEMP_GETFREERES:
83       {
84           return ipc_gatemp_getFreeResource(ctp, msg, ocb);
85       }
86       break;
88       case DCMD_GATEMP_RELRES:
89       {
90           return ipc_gatemp_releaseResource(ctp, msg, ocb);
91       }
92       break;
94       case DCMD_GATEMP_GETNUMRES:
95       {
96           return ipc_gatemp_getNumResources(ctp, msg, ocb);
97       }
98       break;
100       case DCMD_GATEMP_START:
101       {
102           return ipc_gatemp_start(ctp, msg, ocb);
103       }
104       break;
106       case DCMD_GATEMP_STOP:
107       {
108           return ipc_gatemp_stop(ctp, msg, ocb);
109       }
110       break;
112       case DCMD_GATEMP_ISSETUP:
113       {
114           return ipc_gatemp_isSetup(ctp, msg, ocb);
115       }
116       break;
118       default:
119           fprintf(stderr, "Invalid DEVCTL for gatemp 0x%x\n", msg->i.dcmd);
120           break;
122     }
124     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
125         sizeof(GateMPDrv_CmdArgs)));
129 /**
130  * Handler for gatemp getFreeResource API.
131  *
132  * \param ctp   Thread's associated context information.
133  * \param msg   The actual devctl() message.
134  * \param ocb   OCB associated with client's session.
135  *
136  * \return POSIX errno value.
137  *
138  * \retval EOK      Success.
139  * \retval ENOTSUP  Unsupported devctl().
140  */
141 int ipc_gatemp_getFreeResource(resmgr_context_t *ctp, io_devctl_t *msg,
142     ipc_ocb_t *ocb)
144     GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
145         (_DEVCTL_DATA (msg->i));
146     GateMPDrv_CmdArgs * out  = (GateMPDrv_CmdArgs *)
147         (_DEVCTL_DATA (msg->o));
149     out->apiStatus = GateMP_getFreeResource(cargs->args.getFreeResource.type);
150     out->args.getFreeResource.id = out->apiStatus;
152     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
153         sizeof(GateMPDrv_CmdArgs)));
156 /**
157  * Handler for gatemp releaseResource API.
158  *
159  * \param ctp   Thread's associated context information.
160  * \param msg   The actual devctl() message.
161  * \param ocb   OCB associated with client's session.
162  *
163  * \return POSIX errno value.
164  *
165  * \retval EOK      Success.
166  * \retval ENOTSUP  Unsupported devctl().
167  */
168 int ipc_gatemp_releaseResource(resmgr_context_t *ctp, io_devctl_t *msg,
169     ipc_ocb_t *ocb)
171     GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
172         (_DEVCTL_DATA (msg->i));
173     GateMPDrv_CmdArgs * out  = (GateMPDrv_CmdArgs *)
174         (_DEVCTL_DATA (msg->o));
176     out->apiStatus = GateMP_releaseResource(cargs->args.releaseResource.id,
177         cargs->args.releaseResource.type);
179     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
180         sizeof(GateMPDrv_CmdArgs)));
183 /**
184  * Handler for gatemp getNumResources API.
185  *
186  * \param ctp   Thread's associated context information.
187  * \param msg   The actual devctl() message.
188  * \param ocb   OCB associated with client's session.
189  *
190  * \return POSIX errno value.
191  *
192  * \retval EOK      Success.
193  * \retval ENOTSUP  Unsupported devctl().
194  */
195 int ipc_gatemp_getNumResources(resmgr_context_t *ctp, io_devctl_t *msg,
196     ipc_ocb_t *ocb)
198     GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
199         (_DEVCTL_DATA (msg->i));
200     GateMPDrv_CmdArgs * out  = (GateMPDrv_CmdArgs *)
201         (_DEVCTL_DATA (msg->o));
203     out->apiStatus = GateMP_getNumResources(cargs->args.getNumResources.type);
204     cargs->args.getNumResources.value = out->apiStatus;
206     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
207         sizeof(GateMPDrv_CmdArgs)));
210 /**
211  * Handler for gatemp start API.
212  *
213  * \param ctp   Thread's associated context information.
214  * \param msg   The actual devctl() message.
215  * \param ocb   OCB associated with client's session.
216  *
217  * \return POSIX errno value.
218  *
219  * \retval EOK      Success.
220  * \retval ENOTSUP  Unsupported devctl().
221  */
222 int ipc_gatemp_start(resmgr_context_t *ctp, io_devctl_t *msg,
223     ipc_ocb_t *ocb)
225     GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
226         (_DEVCTL_DATA (msg->i));
227     GateMPDrv_CmdArgs * out  = (GateMPDrv_CmdArgs *)
228         (_DEVCTL_DATA (msg->o));
230     cargs->args.start.nameServerHandle = GateMP_getNameServer();
231     out->apiStatus = GateMP_start();
233     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
234         sizeof(GateMPDrv_CmdArgs)));
237 /**
238  * Handler for gatemp stop API.
239  *
240  * \param ctp   Thread's associated context information.
241  * \param msg   The actual devctl() message.
242  * \param ocb   OCB associated with client's session.
243  *
244  * \return POSIX errno value.
245  *
246  * \retval EOK      Success.
247  * \retval ENOTSUP  Unsupported devctl().
248  */
249 int ipc_gatemp_stop(resmgr_context_t *ctp, io_devctl_t *msg,
250     ipc_ocb_t *ocb)
252     GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
253         (_DEVCTL_DATA (msg->i));
254     GateMPDrv_CmdArgs * out  = (GateMPDrv_CmdArgs *)
255         (_DEVCTL_DATA (msg->o));
257     out->apiStatus = GateMP_stop();
259     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
260         sizeof(GateMPDrv_CmdArgs)));
263 /**
264  * Handler for gatemp isSetup API.
265  *
266  * \param ctp   Thread's associated context information.
267  * \param msg   The actual devctl() message.
268  * \param ocb   OCB associated with client's session.
269  *
270  * \return POSIX errno value.
271  *
272  * \retval EOK      Success.
273  * \retval ENOTSUP  Unsupported devctl().
274  */
275 int ipc_gatemp_isSetup(resmgr_context_t *ctp, io_devctl_t *msg,
276     ipc_ocb_t *ocb)
278     GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
279         (_DEVCTL_DATA (msg->i));
280     GateMPDrv_CmdArgs * out  = (GateMPDrv_CmdArgs *)
281         (_DEVCTL_DATA (msg->o));
283     cargs->args.isSetup.result = GateMP_isSetup();
284     out->apiStatus = GateMP_S_SUCCESS;
286     return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
287         sizeof(GateMPDrv_CmdArgs)));