]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - linux/include/_lad.h
3cffe83a52c14991a06dd9b244c4a68d645694f0
[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 <_Ipc.h>
52 #include <GateHWSpinlock.h>
53 #include <sys/time.h>
54 #include <ti/ipc/namesrv/_NameServerRemoteRpmsg.h>
56 extern Bool logFile;
57 extern FILE *logPtr;
58 extern struct timeval start_tv;
60 /*
61  * Macros for writing to log file.
62  *
63  * For the timestamp prefix, subtract the start time (which is established
64  * when the logFile is opened) so that the massive "since the epoch" value
65  * is not displayed.  For this, subtract only the timeval.tv_sec (seconds)
66  * value so we don't have to worry about the "borrow" that results when
67  * start_tv.tv_usec > tv.tv_usec.
68  */
69 #define LOG0(a)  \
70     if (logFile == TRUE) { \
71         struct timeval tv; \
72         gettimeofday(&tv, NULL); \
73         fprintf(logPtr, "[%d.%06d] " a, \
74                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
75                 (unsigned int)tv.tv_usec); \
76         fflush(logPtr); \
77     }
79 #define LOG1(a, b)  \
80     if (logFile == TRUE) { \
81         struct timeval tv; \
82         gettimeofday(&tv, NULL); \
83         fprintf(logPtr, "[%d.%06d] " a, \
84                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
85                 (unsigned int)tv.tv_usec, b); \
86         fflush(logPtr); \
87     }
89 #define LOG2(a, b, c)  \
90     if (logFile == TRUE) { \
91         struct timeval tv; \
92         gettimeofday(&tv, NULL); \
93         fprintf(logPtr, "[%d.%06d] " a, \
94                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
95                 (unsigned int)tv.tv_usec, b, c); \
96         fflush(logPtr); \
97     }
99 #define LOG3(a, b, c, d)  \
100     if (logFile == TRUE) { \
101         struct timeval tv; \
102         gettimeofday(&tv, NULL); \
103         fprintf(logPtr, "[%d.%06d] " a, \
104                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
105                 (unsigned int)tv.tv_usec, b, c, d); \
106         fflush(logPtr); \
107     }
109 #define LOG4(a, b, c, d, e)  \
110     if (logFile == TRUE) { \
111         struct timeval tv; \
112         gettimeofday(&tv, NULL); \
113         fprintf(logPtr, "[%d.%06d] " a, \
114                 (unsigned int)(tv.tv_sec - start_tv.tv_sec), \
115                 (unsigned int)tv.tv_usec, b, c, d, e); \
116         fflush(logPtr); \
117     }
119 /* macros for generating verbose output: */
120 #define PRINTVERBOSE0(a)  \
121     if (verbose == TRUE) {  printf(a); }
123 #define PRINTVERBOSE1(a, b)  \
124     if (verbose == TRUE) {  printf(a, b); }
126 #define PRINTVERBOSE2(a, b, c)  \
127     if (verbose == TRUE) {  printf(a, b, c); }
129 #define PRINTVERBOSE3(a, b, c, d)  \
130     if (verbose == TRUE) {  printf(a, b, c, d); }
133 /* LAD commmand FIFO strings: */
134 #if defined (IPC_BUILDOS_ANDROID)
135 #define LAD_COMMANDFIFO         "/data/lad/LAD/LADCMDS"
136 #define LAD_ROOTDIR             "/data/lad/"
137 #define LAD_WORKINGDIR          "/data/lad/LAD/"
138 #else
139 #define LAD_COMMANDFIFO         "/tmp/LAD/LADCMDS"
140 #define LAD_ROOTDIR             "/tmp/"
141 #define LAD_WORKINGDIR          "/tmp/LAD/"
142 #endif
144 #define LAD_RESPONSEFIFOPATH    LAD_WORKINGDIR
145 #define LAD_PROTOCOLVERSION     "03000000"    /*  MMSSRRRR */
147 #define LAD_MAXNUMCLIENTS  32      /* max simultaneous clients */
148 #define LAD_CONNECTTIMEOUT 5.0  /* LAD connect response timeout (sec) */
149 #define LAD_DISCONNECTTIMEOUT   5.0  /* LAD disconnect timeout (sec) */
150 #define LAD_MAXLENGTHFIFONAME   128  /* max length client FIFO name */
151 #define LAD_MAXLENGTHCOMMAND    512  /* size limit for LAD command string */
152 #define LAD_MAXLENGTHRESPONSE   512  /* size limit for LAD response string */
153 #define LAD_MAXLENGTHPROTOVERS  16   /* size limit for protocol version */
154 #define LAD_MAXLOGFILEPATH 256  /* size limit for LAD log file path */
155 #define LAD_COMMANDLENGTH       sizeof(struct LAD_CommandObj)
156 #define LAD_RESPONSELENGTH      sizeof(union LAD_ResponseObj)
158 #define LAD_MESSAGEQCREATEMAXNAMELEN 32
160 #define LAD_MAXENTRYNAMELEN  MAXNAMEINCHAR /* max for LAD NameServer name */
161 #define LAD_MAXENTRYVALUELEN 32  /* size limit for LAD NameServer value */
163 typedef enum {
164     LAD_CONNECT = 0,
165     LAD_DISCONNECT,
166     LAD_RPROC_SETID,
167     LAD_IPC_GETCONFIG,
168     LAD_NAMESERVER_SETUP,
169     LAD_NAMESERVER_DESTROY,
170     LAD_NAMESERVER_PARAMS_INIT,
171     LAD_NAMESERVER_CREATE,
172     LAD_NAMESERVER_DELETE,
173     LAD_NAMESERVER_ADD,
174     LAD_NAMESERVER_GET,
175     LAD_NAMESERVER_ADDUINT32,
176     LAD_NAMESERVER_GETUINT32,
177     LAD_NAMESERVER_GETLOCAL,
178     LAD_NAMESERVER_GETLOCALUINT32,
179     LAD_NAMESERVER_REMOVE,
180     LAD_NAMESERVER_REMOVEENTRY,
181     LAD_NAMESERVER_ATTACH,
182     LAD_NAMESERVER_DETACH,
183     LAD_MESSAGEQ_GETCONFIG,
184     LAD_MESSAGEQ_SETUP,
185     LAD_MESSAGEQ_DESTROY,
186     LAD_MESSAGEQ_CREATE,
187     LAD_MESSAGEQ_DELETE,
188     LAD_MESSAGEQ_MSGINIT,
189     LAD_MULTIPROC_GETCONFIG,
190     LAD_GATEMP_START,
191     LAD_GATEMP_GETNUMRESOURCES,
192     LAD_GATEMP_GETFREERESOURCE,
193     LAD_GATEMP_RELEASERESOURCE,
194     LAD_GATEMP_ISSETUP,
195     LAD_GATEHWSPINLOCK_GETCONFIG,
196     LAD_EXIT
197 } _LAD_Command;
199 struct LAD_CommandObj {
200     Int cmd;
201     Int clientId;
202     union {
203         struct {
204             Int pid;
205             Char name[LAD_MAXLENGTHFIFONAME];
206             Char protocol[LAD_MAXLENGTHPROTOVERS];
207         } connect;
208         struct {
209             Int procId;
210             Int rprocId;
211         } rprocSetId;
212         struct {
213             Char name[LAD_MAXENTRYNAMELEN];
214             NameServer_Params params;
215         } create;
216         struct {
217             NameServer_Handle handle;
218         } nsdelete;
219         struct {
220             NameServer_Handle handle;
221             Char name[LAD_MAXENTRYNAMELEN];
222             UInt8 buf[LAD_MAXENTRYVALUELEN];
223             UInt32 len;
224         } add;
225         struct {
226             NameServer_Handle handle;
227             Char name[LAD_MAXENTRYNAMELEN];
228             UInt32 len;
229             UInt16 procId[MultiProc_MAXPROCESSORS];
230         } get;
231         struct {
232             NameServer_Handle handle;
233             Char name[LAD_MAXENTRYNAMELEN];
234             UInt32 val;
235         } addUInt32;
236         struct {
237             NameServer_Handle handle;
238             Char name[LAD_MAXENTRYNAMELEN];
239             UInt16 procId[MultiProc_MAXPROCESSORS];
240         } getUInt32;
241         struct {
242             NameServer_Handle handle;
243             Char name[LAD_MAXENTRYNAMELEN];
244             UInt32 len;
245         } getLocal;
246         struct {
247             NameServer_Handle handle;
248             Char name[LAD_MAXENTRYNAMELEN];
249         } getLocalUInt32;
250         struct {
251             NameServer_Handle handle;
252             Char name[LAD_MAXENTRYNAMELEN];
253         } remove;
254         struct {
255             NameServer_Handle handle;
256             Ptr entryPtr;
257         } removeEntry;
258         struct {
259             UInt16 procId;
260         } attach;
261         struct {
262             UInt16 procId;
263         } detach;
264         struct {
265             MessageQ_Config cfg;
266         } messageQSetup;
267         struct {
268             Char name[LAD_MESSAGEQCREATEMAXNAMELEN];
269             MessageQ_Params params;
270         } messageQCreate;
271         struct {
272             Void *serverHandle;
273         } messageQDelete;
274         struct {
275             GateMP_RemoteProtect type;
276         } gateMPGetNumResources;
277         struct {
278             GateMP_RemoteProtect type;
279         } gateMPGetFreeResource;
280         struct {
281             GateMP_RemoteProtect type;
282             Int32 id;
283         } gateMPReleaseResource;
284         struct {
285             Bool result;
286         } gateMPIsSetup;
287     } args;
288 };
290 union LAD_ResponseObj {
291     struct {
292        Int status;
293        UInt32 len;
294        UInt8 buf[LAD_MAXENTRYVALUELEN];
295     } get;
296     struct {
297        Int status;
298        UInt32 val;
299     } getUInt32;
300     struct {
301        Int status;
302        Int assignedId;
303     } connect;
304     struct {
305        Int status;
306        NameServer_Handle handle;
307     } nsdelete;
308     struct {
309        Int status;
310        NameServer_Handle nameServerHandle;
311     } setup;
312     struct {
313        Int status;
314        Int queueId;
315        Void *serverHandle;
316     } messageQCreate;
317     struct {
318        Int status;
319     } messageQDelete;
320     struct {
321        Int status;
322        MessageQ_MsgHeader msg;
323     } msgInit;
324     struct {
325        Int status;
326        MessageQ_Config cfg;
327     } messageQGetConfig;
328     struct {
329        Int status;
330        MultiProc_Config cfg;
331     } multiprocGetConfig;
332     struct {
333        Int status;
334        NameServer_Handle nameServerHandle;
335     } gateMPStart;
336     struct {
337        Int status;
338        Int32 value;
339     } gateMPGetNumResources;
340     struct {
341        Int status;
342        Int32 id;
343     } gateMPGetFreeResource;
344     struct {
345        Int status;
346     } gateMPReleaseResource;
347     struct {
348        Int status;
349        Bool result;
350     } gateMPIsSetup;
351     struct {
352        Int status;
353        GateHWSpinlock_Config cfgParams;
354     } gateHWSpinlockGetConfig;
355     Ipc_Config ipcConfig;
356     NameServer_Params params;
357     NameServer_Handle handle;
358     Ptr entryPtr;
359     Int status;
360 };
363 #ifdef __cplusplus
365 #endif
367 #endif