]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_devctl.c
036e793dd6f21c15f02b3728c3e2500bad4d637f
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / build / Qnx / resmgr / syslink_devctl.c
1 /*
2  *  @file       syslink_devctl.c
3  *
4  *  @brief      devctl handler for the ipc resource manager
5  *
6  *
7  *  @ver        02.00.00.46_alpha1
8  *
9  *  ============================================================================
10  *
11  *  Copyright (c) 2010-2015, Texas Instruments Incorporated
12  *
13  *  Redistribution and use in source and binary forms, with or without
14  *  modification, are permitted provided that the following conditions
15  *  are met:
16  *
17  *  *  Redistributions of source code must retain the above copyright
18  *     notice, this list of conditions and the following disclaimer.
19  *
20  *  *  Redistributions in binary form must reproduce the above copyright
21  *     notice, this list of conditions and the following disclaimer in the
22  *     documentation and/or other materials provided with the distribution.
23  *
24  *  *  Neither the name of Texas Instruments Incorporated nor the names of
25  *     its contributors may be used to endorse or promote products derived
26  *     from this software without specific prior written permission.
27  *
28  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
32  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
35  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *  Contact information for paper mail:
40  *  Texas Instruments
41  *  Post Office Box 655303
42  *  Dallas, Texas 75265
43  *  Contact information:
44  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
45  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
46  *  ============================================================================
47  *
48  */
50 #include "proto.h"
51 #include <stdio.h>
52 #include <pthread.h>
53 #include <fcntl.h>
54 #include <errno.h>
55 #include <stdint.h>
56 #include <stdlib.h>
57 #include <string.h>
58 #include <unistd.h>
59 #include <sys/procmgr.h>
60 #include <sys/neutrino.h>
61 #include <sys/siginfo.h>
62 #include <sys/mman.h>
63 #include <signal.h>
64 #include <sys/iofunc.h>
65 #include <sys/dispatch.h>
66 #include <ti/syslink/Std.h>
67 #include "MessageQCopyDrvDefs.h"
68 #include "HwSpinLockCmdBase.h"
69 #include "NameServerDrvDefs.h"
70 #include "MessageQDrvDefs.h"
71 #include "MultiProcDrvDefs.h"
72 #include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
74 #include <ti/syslink/utils/Trace.h>
76 extern Int MessageQCopyDrv_devctl (resmgr_context_t *ctp, io_devctl_t *msg,
77                                    ipc_ocb_t *ocb);
78 extern Int GateHWSpinlockDrv_devctl (resmgr_context_t * ctp, io_devctl_t * msg,
79                                      ipc_ocb_t * ocb);
80 extern int ipc_messageq_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
81                                    ipc_ocb_t *ocb);
82 extern int ipc_nameserver_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
83                                      ipc_ocb_t * ocb);
84 extern int ipc_multiproc_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
85                                      ipc_ocb_t * ocb);
86 extern int ipc_gatemp_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
87                                  ipc_ocb_t * ocb);
89 /**
90  * Handler for devctl() messages.
91  *
92  * Handles special devctl() messages that we export for control.
93  *
94  * \param ctp    Thread's associated context information.
95  * \param msg    The actual devctl() message.
96  * \param ocb    OCB associated with client's session.
97  *
98  * \return POSIX errno value.
99  *
100  * \retval EOK        Success.
101  * \retval ENOTSUP    Unsupported devctl().
102  */
103 int ipc_devctl(resmgr_context_t *ctp, io_devctl_t *msg, ipc_ocb_t *ocb)
105     int status = 0;
106     int commandClass = 0;
108     if ((status = iofunc_devctl_default(ctp, msg, &(ocb->ocb))) !=
109          _RESMGR_DEFAULT) {
110         return(status);
111     }
112     status = 0;
114     commandClass = (unsigned char)(msg->i.dcmd >> 8);
116     iofunc_unlock_ocb_default(ctp, msg, &(ocb->ocb));
118     switch (commandClass)
119     {
120         case MESSAGEQCOPY_BASE_CMD:
121             status = MessageQCopyDrv_devctl( ctp, msg, ocb);
122             break;
123 #ifndef IPC_PLATFORM_VAYU
124         case HWSPINLOCKDRV_BASE_CMD:
125             status = GateHWSpinlockDrv_devctl(ctp, msg, ocb);
126             break;
127 #endif
128         case _DCMD_IPC_NAMESERVER:
129             status = ipc_nameserver_devctl(ctp, msg, ocb);
130             break;
131         case _DCMD_IPC_MESSAGEQ:
132             status = ipc_messageq_devctl(ctp, msg, ocb);
133             break;
134         case _DCMD_IPC_MULTIPROC:
135             status = ipc_multiproc_devctl(ctp, msg, ocb);
136             break;
137 #ifdef IPC_PLATFORM_VAYU
138         case _DCMD_IPC_GATEMP:
139             status = ipc_gatemp_devctl(ctp, msg, ocb);
140             break;
141 #endif
142         default:
143             status = _RESMGR_ERRNO(ENOSYS);
144             GT_1trace( curTrace, GT_3CLASS,
145                       "Command Class not supported 0x%x",
146                       (unsigned int)commandClass);
147             break;
148     }
150     iofunc_lock_ocb_default(ctp, msg, &(ocb->ocb));
152     return status;