]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - linux/include/_lad.h
SDOCM00114745 Ipc_transportConfig has race window
[ipc/ipcdev.git] / linux / include / _lad.h
1 /*
2  * Copyright (c) 2012-2015 Texas Instruments Incorporated - http://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  *  ======== _lad.h ========
34  */
36 #ifndef _lad_
37 #define _lad_
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 #include <ti/ipc/MessageQ.h>
44 #include <_MessageQ.h>
45 #include <ti/ipc/NameServer.h>
46 #include <ti/ipc/MultiProc.h>
47 #include <_MultiProc.h>
48 #include <stdio.h>
49 #include <ti/ipc/GateMP.h>
50 #include <_GateMP.h>
51 #include <GateHWSpinlock.h>
52 #include <sys/time.h>
53 #include <ti/ipc/namesrv/_NameServerRemoteRpmsg.h>
55 extern Bool logFile;
56 extern FILE *logPtr;
57 extern struct timeval start_tv;
59 /*
60  * Macros for writing to log file.
61  *
62  * For the timestamp prefix, subtract the start time (which is established
63  * when the logFile is opened) so that the massive "since the epoch" value
64  * is not displayed.  For this, subtract only the timeval.tv_sec (seconds)
65  * value so we don't have to worry about the "borrow" that results when
66  * start_tv.tv_usec > tv.tv_usec.
67  */
68 #define LOG0(a)  \
69     if (logFile == TRUE) { \
70         struct timeval tv; \
71         gettimeofday(&tv, NULL); \
72         fprintf(logPtr, "[%d.%06d] " a, \
73                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
74                 (unsigned int)tv.tv_usec); \
75         fflush(logPtr); \
76     }
78 #define LOG1(a, b)  \
79     if (logFile == TRUE) { \
80         struct timeval tv; \
81         gettimeofday(&tv, NULL); \
82         fprintf(logPtr, "[%d.%06d] " a, \
83                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
84                 (unsigned int)tv.tv_usec, b); \
85         fflush(logPtr); \
86     }
88 #define LOG2(a, b, c)  \
89     if (logFile == TRUE) { \
90         struct timeval tv; \
91         gettimeofday(&tv, NULL); \
92         fprintf(logPtr, "[%d.%06d] " a, \
93                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
94                 (unsigned int)tv.tv_usec, b, c); \
95         fflush(logPtr); \
96     }
98 #define LOG3(a, b, c, d)  \
99     if (logFile == TRUE) { \
100         struct timeval tv; \
101         gettimeofday(&tv, NULL); \
102         fprintf(logPtr, "[%d.%06d] " a, \
103                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
104                 (unsigned int)tv.tv_usec, b, c, d); \
105         fflush(logPtr); \
106     }
108 /* macros for generating verbose output: */
109 #define PRINTVERBOSE0(a)  \
110     if (verbose == TRUE) {  printf(a); }
112 #define PRINTVERBOSE1(a, b)  \
113     if (verbose == TRUE) {  printf(a, b); }
115 #define PRINTVERBOSE2(a, b, c)  \
116     if (verbose == TRUE) {  printf(a, b, c); }
118 #define PRINTVERBOSE3(a, b, c, d)  \
119     if (verbose == TRUE) {  printf(a, b, c, d); }
122 /* LAD commmand FIFO strings: */
123 #if defined (IPC_BUILDOS_ANDROID)
124 #define LAD_COMMANDFIFO         "/data/lad/LAD/LADCMDS"
125 #define LAD_ROOTDIR             "/data/lad/"
126 #define LAD_WORKINGDIR          "/data/lad/LAD/"
127 #else
128 #define LAD_COMMANDFIFO         "/tmp/LAD/LADCMDS"
129 #define LAD_ROOTDIR             "/tmp/"
130 #define LAD_WORKINGDIR          "/tmp/LAD/"
131 #endif
133 #define LAD_RESPONSEFIFOPATH    LAD_WORKINGDIR
134 #define LAD_PROTOCOLVERSION     "03000000"    /*  MMSSRRRR */
136 #define LAD_MAXNUMCLIENTS  32      /* max simultaneous clients */
137 #define LAD_CONNECTTIMEOUT 5.0  /* LAD connect response timeout (sec) */
138 #define LAD_DISCONNECTTIMEOUT   5.0  /* LAD disconnect timeout (sec) */
139 #define LAD_MAXLENGTHFIFONAME   128  /* max length client FIFO name */
140 #define LAD_MAXLENGTHCOMMAND    512  /* size limit for LAD command string */
141 #define LAD_MAXLENGTHRESPONSE   512  /* size limit for LAD response string */
142 #define LAD_MAXLENGTHPROTOVERS  16   /* size limit for protocol version */
143 #define LAD_MAXLOGFILEPATH 256  /* size limit for LAD log file path */
144 #define LAD_COMMANDLENGTH       sizeof(struct LAD_CommandObj)
145 #define LAD_RESPONSELENGTH      sizeof(union LAD_ResponseObj)
147 #define LAD_MESSAGEQCREATEMAXNAMELEN 32
149 #define LAD_MAXENTRYNAMELEN  MAXNAMEINCHAR /* max for LAD NameServer name */
150 #define LAD_MAXENTRYVALUELEN 32  /* size limit for LAD NameServer value */
152 typedef enum {
153     LAD_CONNECT = 0,
154     LAD_DISCONNECT,
155     LAD_NAMESERVER_SETUP,
156     LAD_NAMESERVER_DESTROY,
157     LAD_NAMESERVER_PARAMS_INIT,
158     LAD_NAMESERVER_CREATE,
159     LAD_NAMESERVER_DELETE,
160     LAD_NAMESERVER_ADD,
161     LAD_NAMESERVER_GET,
162     LAD_NAMESERVER_ADDUINT32,
163     LAD_NAMESERVER_GETUINT32,
164     LAD_NAMESERVER_REMOVE,
165     LAD_NAMESERVER_REMOVEENTRY,
166     LAD_MESSAGEQ_GETCONFIG,
167     LAD_MESSAGEQ_SETUP,
168     LAD_MESSAGEQ_DESTROY,
169     LAD_MESSAGEQ_CREATE,
170     LAD_MESSAGEQ_DELETE,
171     LAD_MESSAGEQ_MSGINIT,
172     LAD_MULTIPROC_GETCONFIG,
173     LAD_GATEMP_START,
174     LAD_GATEMP_GETNUMRESOURCES,
175     LAD_GATEMP_GETFREERESOURCE,
176     LAD_GATEMP_RELEASERESOURCE,
177     LAD_GATEMP_ISSETUP,
178     LAD_GATEHWSPINLOCK_GETCONFIG,
179     LAD_EXIT
180 } _LAD_Command;
182 struct LAD_CommandObj {
183     Int cmd;
184     Int clientId;
185     union {
186         struct {
187             Int pid;
188             Char name[LAD_MAXLENGTHFIFONAME];
189             Char protocol[LAD_MAXLENGTHPROTOVERS];
190         } connect;
191         struct {
192             Char name[LAD_MAXENTRYNAMELEN];
193             NameServer_Params params;
194         } create;
195         struct {
196             NameServer_Handle handle;
197         } delete;
198         struct {
199             NameServer_Handle handle;
200             Char name[LAD_MAXENTRYNAMELEN];
201             UInt8 buf[LAD_MAXENTRYVALUELEN];
202             UInt32 len;
203         } add;
204         struct {
205             NameServer_Handle handle;
206             Char name[LAD_MAXENTRYNAMELEN];
207             UInt32 len;
208             UInt16 procId[MultiProc_MAXPROCESSORS];
209         } get;
210         struct {
211             NameServer_Handle handle;
212             Char name[LAD_MAXENTRYNAMELEN];
213             UInt32 val;
214         } addUInt32;
215         struct {
216             NameServer_Handle handle;
217             Char name[LAD_MAXENTRYNAMELEN];
218             UInt16 procId[MultiProc_MAXPROCESSORS];
219         } getUInt32;
220         struct {
221             NameServer_Handle handle;
222             Char name[LAD_MAXENTRYNAMELEN];
223         } remove;
224         struct {
225             NameServer_Handle handle;
226             Ptr entryPtr;
227         } removeEntry;
228         struct {
229             MessageQ_Config cfg;
230         } messageQSetup;
231         struct {
232             Char name[LAD_MESSAGEQCREATEMAXNAMELEN];
233             MessageQ_Params params;
234         } messageQCreate;
235         struct {
236             Void *serverHandle;
237         } messageQDelete;
238         struct {
239             GateMP_RemoteProtect type;
240         } gateMPGetNumResources;
241         struct {
242             GateMP_RemoteProtect type;
243         } gateMPGetFreeResource;
244         struct {
245             GateMP_RemoteProtect type;
246             Int32 id;
247         } gateMPReleaseResource;
248         struct {
249             Bool result;
250         } gateMPIsSetup;
251     } args;
252 };
254 union LAD_ResponseObj {
255     struct {
256        Int status;
257        UInt32 len;
258        UInt8 buf[LAD_MAXENTRYVALUELEN];
259     } get;
260     struct {
261        Int status;
262        UInt32 val;
263     } getUInt32;
264     struct {
265        Int status;
266        Int assignedId;
267     } connect;
268     struct {
269        Int status;
270        NameServer_Handle handle;
271     } delete;
272     struct {
273        Int status;
274        NameServer_Handle nameServerHandle;
275     } setup;
276     struct {
277        Int status;
278        Int queueId;
279        Void *serverHandle;
280     } messageQCreate;
281     struct {
282        Int status;
283     } messageQDelete;
284     struct {
285        Int status;
286        MessageQ_MsgHeader msg;
287     } msgInit;
288     struct {
289        Int status;
290        MessageQ_Config cfg;
291     } messageQGetConfig;
292     struct {
293        Int status;
294        MultiProc_Config cfg;
295     } multiprocGetConfig;
296     struct {
297        Int status;
298        NameServer_Handle nameServerHandle;
299     } gateMPStart;
300     struct {
301        Int status;
302        Int32 value;
303     } gateMPGetNumResources;
304     struct {
305        Int status;
306        Int32 id;
307     } gateMPGetFreeResource;
308     struct {
309        Int status;
310     } gateMPReleaseResource;
311     struct {
312        Int status;
313        Bool result;
314     } gateMPIsSetup;
315     struct {
316        Int status;
317        GateHWSpinlock_Config cfgParams;
318     } gateHWSpinlockGetConfig;
319     NameServer_Params params;
320     NameServer_Handle handle;
321     Ptr entryPtr;
322     Int status;
323 };
326 #ifdef __cplusplus
328 #endif
330 #endif