1 /*
2 * Copyright (c) 2013 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 * ======== GateMPDrv.c ========
35 *
36 */
38 /* Standard headers */
39 #include <ti/syslink/Std.h>
41 /* OSAL & Utils headers */
42 #include <ti/syslink/utils/Trace.h>
43 #include <ti/ipc/GateMP.h>
44 #include <_MultiProc.h>
45 #include <ti/syslink/inc/GateMPDrvDefs.h>
47 #include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
49 /** ============================================================================
50 * Globals
51 * ============================================================================
52 */
54 extern Int32 IpcDrv_handle;
57 /** ============================================================================
58 * Functions
59 * ============================================================================
60 */
61 /*!
62 * @brief Function to open the GateMP driver.
63 *
64 * @sa GateMPDrv_close
65 */
66 Int GateMPDrv_open (Void)
67 {
68 Int status = GateMP_S_SUCCESS;
70 return status;
71 }
74 /*!
75 * @brief Function to close the GateMP driver.
76 *
77 * @sa GateMPDrv_open
78 */
79 Int GateMPDrv_close (Void)
80 {
81 Int status = GateMP_S_SUCCESS;
83 return status;
84 }
87 /*!
88 * @brief Function to invoke the APIs through ioctl.
89 *
90 * @param cmd Command for driver ioctl
91 * @param args Arguments for the ioctl command
92 *
93 * @sa
94 */
95 Int GateMPDrv_ioctl(UInt32 cmd, Ptr args)
96 {
97 Int status = GateMP_S_SUCCESS;
98 Int osStatus = 0;
99 GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)args;
101 GT_2trace (curTrace, GT_ENTER, "GateMPDrv_ioctl", cmd, args);
103 switch (cmd) {
105 case CMD_GATEMP_GETFREERES:
106 {
107 osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_GETFREERES, cargs,
108 sizeof(GateMPDrv_CmdArgs), NULL);
110 if (osStatus != 0) {
111 status = GateMP_E_OSFAILURE;
112 }
113 }
114 break;
116 case CMD_GATEMP_RELRES:
117 {
118 osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_RELRES, cargs,
119 sizeof(GateMPDrv_CmdArgs), NULL);
121 if (osStatus != 0) {
122 status = GateMP_E_OSFAILURE;
123 }
124 }
125 break;
127 case CMD_GATEMP_GETNUMRES:
128 {
129 osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_GETNUMRES, cargs,
130 sizeof(GateMPDrv_CmdArgs), NULL);
132 if (osStatus != 0) {
133 status = GateMP_E_OSFAILURE;
134 }
135 }
136 break;
138 case CMD_GATEMP_START:
139 {
140 osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_START, cargs,
141 sizeof(GateMPDrv_CmdArgs), NULL);
143 if (osStatus != 0) {
144 status = GateMP_E_OSFAILURE;
145 }
146 }
147 break;
149 case CMD_GATEMP_ISSETUP:
150 {
151 osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_ISSETUP, cargs,
152 sizeof(GateMPDrv_CmdArgs), NULL);
154 if (osStatus != 0) {
155 status = GateMP_E_OSFAILURE;
156 }
157 }
158 break;
160 default:
161 {
162 status = GateMP_E_INVALIDARG;
163 GT_setFailureReason (curTrace,
164 GT_4CLASS,
165 "GateMPDrv_ioctl",
166 status,
167 "Unsupported ioctl command specified");
168 }
169 break;
170 }
172 if (status == GateMP_S_SUCCESS) {
173 status = cargs->apiStatus;
174 }
176 GT_1trace(curTrace, GT_LEAVE, "GateMPDrv_ioctl", status);
178 return (status);
179 }