1 /*
2 * @file MultiProcDrv.c
3 *
4 * @brief OS-specific implementation of MultiProc driver for Qnx
5 *
6 *
7 * ============================================================================
8 *
9 * Copyright (c) 2013-2014, Texas Instruments Incorporated
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * * Neither the name of Texas Instruments Incorporated nor the names of
23 * its contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
36 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
40 /* Standard headers */
41 #include <ti/syslink/Std.h>
43 /* OSAL & Utils headers */
44 #include <ti/syslink/utils/Trace.h>
45 #include <ti/ipc/MultiProc.h>
46 #include <ti/syslink/inc/MultiProcDrvDefs.h>
47 #include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
49 /* QNX specific header files */
50 #include <sys/types.h>
51 #include <unistd.h>
53 /** ============================================================================
54 * Globals
55 * ============================================================================
56 */
57 /*!
58 * @brief Driver handle for MultiProc in this process.
59 */
60 extern Int32 IpcDrv_handle;
62 /** ============================================================================
63 * Functions
64 * ============================================================================
65 */
66 /*!
67 * @brief Function to invoke the APIs through ioctl.
68 *
69 * @param cmd Command for driver ioctl
70 * @param args Arguments for the ioctl command
71 *
72 * @sa
73 */
74 Int
75 MultiProcDrv_ioctl (UInt32 cmd, Ptr args)
76 {
77 Int status = MultiProc_S_SUCCESS;
78 int osStatus = -1;
80 GT_2trace (curTrace, GT_ENTER, "MultiProcDrv_ioctl", cmd, args);
82 switch (cmd) {
83 case CMD_MULTIPROC_GETCONFIG:
84 {
85 MultiProcDrv_CmdArgs *cargs = (MultiProcDrv_CmdArgs *)args;
86 iov_t mpgetconfig_iov[2];
88 SETIOV(&mpgetconfig_iov[0], cargs, sizeof(MultiProcDrv_CmdArgs));
89 SETIOV(&mpgetconfig_iov[1], cargs->args.getConfig.config,
90 sizeof(MultiProc_Config));
91 osStatus = devctlv(IpcDrv_handle, DCMD_MULTIPROC_GETCONFIG, 2, 2,
92 mpgetconfig_iov, mpgetconfig_iov, NULL);
93 }
94 break;
96 default:
97 {
98 /* This does not impact return status of this function, so retVal
99 * comment is not used.
100 */
101 status = MultiProc_E_INVALIDARG;
102 GT_setFailureReason (curTrace,
103 GT_4CLASS,
104 "MultiProcDrv_ioctl",
105 status,
106 "Unsupported ioctl command specified");
107 }
108 break;
109 }
112 if (osStatus != 0) {
113 /*! @retval MultiProc_E_OSFAILURE Driver ioctl failed */
114 status = MultiProc_E_OSFAILURE;
115 GT_setFailureReason (curTrace,
116 GT_4CLASS,
117 "MultiProcDrv_ioctl",
118 status,
119 "Driver ioctl failed!");
120 }
121 else {
122 /* First field in the structure is the API status. */
123 status = ((MultiProcDrv_CmdArgs *) args)->apiStatus;
124 }
126 GT_1trace (curTrace, GT_LEAVE, "MultiProcDrv_ioctl", status);
128 return status;
129 }