Staging: add epl stack
[firefly-linux-kernel-4.4.55.git] / drivers / staging / epl / EplAmi.h
1 /****************************************************************************
2
3   (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4       www.systec-electronic.com
5
6   Project:      openPOWERLINK
7
8   Description:  Definitions for Abstract Memory Interface
9
10   License:
11
12     Redistribution and use in source and binary forms, with or without
13     modification, are permitted provided that the following conditions
14     are met:
15
16     1. Redistributions of source code must retain the above copyright
17        notice, this list of conditions and the following disclaimer.
18
19     2. Redistributions in binary form must reproduce the above copyright
20        notice, this list of conditions and the following disclaimer in the
21        documentation and/or other materials provided with the distribution.
22
23     3. Neither the name of SYSTEC electronic GmbH nor the names of its
24        contributors may be used to endorse or promote products derived
25        from this software without prior written permission. For written
26        permission, please contact info@systec-electronic.com.
27
28     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32     COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39     POSSIBILITY OF SUCH DAMAGE.
40
41     Severability Clause:
42
43         If a provision of this License is or becomes illegal, invalid or
44         unenforceable in any jurisdiction, that shall not affect:
45         1. the validity or enforceability in that jurisdiction of any other
46            provision of this License; or
47         2. the validity or enforceability in other jurisdictions of that or
48            any other provision of this License.
49
50   -------------------------------------------------------------------------
51
52                 $RCSfile: EplAmi.h,v $
53
54                 $Author: D.Krueger $
55
56                 $Revision: 1.2 $  $Date: 2008/04/17 21:36:32 $
57
58                 $State: Exp $
59
60                 Build Environment:
61                 GCC
62
63   -------------------------------------------------------------------------
64
65   Revision History:
66
67    06.03.2000  -rs
68                Implementation
69
70    16.09.2002  -as
71                To save code space the functions AmiSetByte and AmiGetByte
72                are replaced by macros. For targets which assign BYTE by
73                an 16Bit type, the definition of macros must changed to
74                functions.
75
76    23.02.2005  r.d.:
77                Functions included for extended data types such as UNSIGNED24,
78                UNSIGNED40, ...
79
80    13.06.2006  d.k.:
81                Extended the interface for EPL with the different functions
82                for little endian and big endian
83
84 ****************************************************************************/
85
86 #ifndef _EPLAMI_H_
87 #define _EPLAMI_H_
88
89
90 #if ((DEV_SYSTEM & _DEV_64BIT_SUPPORT_) == 0)
91 //    #ifdef USE_VAR64
92         #error 'ERROR: development system does not support 64 bit operations!'
93 //    #endif
94 #endif
95
96
97 //---------------------------------------------------------------------------
98 //  types
99 //---------------------------------------------------------------------------
100
101
102 //---------------------------------------------------------------------------
103 //  Prototypen
104 //---------------------------------------------------------------------------
105
106 #ifdef __cplusplus
107     extern "C" {
108 #endif
109
110 #if (TARGET_SYSTEM == _WIN32_)
111     #if defined(INLINE_FUNCTION_DEF)
112         #undef  INLINE_FUNCTION
113         #define INLINE_FUNCTION     INLINE_FUNCTION_DEF
114         #define INLINE_ENABLED      TRUE
115         #define EPL_AMI_INLINED
116         #include "../EplStack/amix86.c"
117     #endif
118
119 #elif (TARGET_SYSTEM == _LINUX_)
120     #if defined(__m68k__)   // it is an big endian machine
121         #if defined(INLINE_FUNCTION_DEF)
122             #undef  INLINE_FUNCTION
123             #define INLINE_FUNCTION     INLINE_FUNCTION_DEF
124             #define INLINE_ENABLED      TRUE
125             #define EPL_AMI_INLINED
126             #include "../EplStack/amibe.c"
127         #endif
128     #endif
129 #endif
130
131 //---------------------------------------------------------------------------
132 //
133 // write functions
134 //
135 // To save code space the function AmiSetByte is replaced by
136 // an macro.
137 // void   PUBLIC  AmiSetByte  (void FAR* pAddr_p, BYTE bByteVal_p);
138
139 #define AmiSetByteToBe(pAddr_p, bByteVal_p)  {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
140 #define AmiSetByteToLe(pAddr_p, bByteVal_p)  {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
141
142 #if !defined(INLINE_ENABLED)
143 void   PUBLIC  AmiSetWordToBe  (void FAR* pAddr_p, WORD wWordVal_p);
144 void   PUBLIC  AmiSetDwordToBe (void FAR* pAddr_p, DWORD dwDwordVal_p);
145 void   PUBLIC  AmiSetWordToLe  (void FAR* pAddr_p, WORD wWordVal_p);
146 void   PUBLIC  AmiSetDwordToLe (void FAR* pAddr_p, DWORD dwDwordVal_p);
147 #endif
148
149
150 //---------------------------------------------------------------------------
151 //
152 // read functions
153 //
154 // To save code space the function AmiGetByte is replaced by
155 // an macro.
156 // BYTE   PUBLIC  AmiGetByte  (void FAR* pAddr_p);
157
158 #define AmiGetByteFromBe(pAddr_p)  (*(BYTE FAR*)(pAddr_p))
159 #define AmiGetByteFromLe(pAddr_p)  (*(BYTE FAR*)(pAddr_p))
160
161 #if !defined(INLINE_ENABLED)
162
163 WORD   PUBLIC  AmiGetWordFromBe  (void FAR* pAddr_p);
164 DWORD  PUBLIC  AmiGetDwordFromBe (void FAR* pAddr_p);
165 WORD   PUBLIC  AmiGetWordFromLe  (void FAR* pAddr_p);
166 DWORD  PUBLIC  AmiGetDwordFromLe (void FAR* pAddr_p);
167
168 //---------------------------------------------------------------------------
169 //
170 // Function:    AmiSetDword24()
171 //
172 // Description: sets a 24 bit value to a buffer
173 //
174 // Parameters:  pAddr_p         = pointer to destination buffer
175 //              dwDwordVal_p    = value to set
176 //
177 // Return:      void
178 //
179 //---------------------------------------------------------------------------
180
181 void PUBLIC AmiSetDword24ToBe (void FAR* pAddr_p, DWORD dwDwordVal_p);
182 void PUBLIC AmiSetDword24ToLe (void FAR* pAddr_p, DWORD dwDwordVal_p);
183
184
185 //---------------------------------------------------------------------------
186 //
187 // Function:    AmiGetDword24()
188 //
189 // Description: reads a 24 bit value from a buffer
190 //
191 // Parameters:  pAddr_p         = pointer to source buffer
192 //
193 // Return:      DWORD           = read value
194 //
195 //---------------------------------------------------------------------------
196
197 DWORD PUBLIC AmiGetDword24FromBe (void FAR* pAddr_p);
198 DWORD PUBLIC AmiGetDword24FromLe (void FAR* pAddr_p);
199
200
201 //#ifdef USE_VAR64
202
203 //---------------------------------------------------------------------------
204 //
205 // Function:    AmiSetQword40()
206 //
207 // Description: sets a 40 bit value to a buffer
208 //
209 // Parameters:  pAddr_p         = pointer to destination buffer
210 //              qwQwordVal_p    = quadruple word value
211 //
212 // Return:      void
213 //
214 //---------------------------------------------------------------------------
215
216 void PUBLIC AmiSetQword40ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
217 void PUBLIC AmiSetQword40ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
218
219
220 //---------------------------------------------------------------------------
221 //
222 // Function:    AmiGetQword40()
223 //
224 // Description: reads a 40 bit value from a buffer
225 //
226 // Parameters:  pAddr_p         = pointer to source buffer
227 //
228 // Return:      QWORD
229 //
230 //---------------------------------------------------------------------------
231
232 QWORD PUBLIC AmiGetQword40FromBe (void FAR* pAddr_p);
233 QWORD PUBLIC AmiGetQword40FromLe (void FAR* pAddr_p);
234
235
236 //---------------------------------------------------------------------------
237 //
238 // Function:    AmiSetQword48()
239 //
240 // Description: sets a 48 bit value to a buffer
241 //
242 // Parameters:  pAddr_p         = pointer to destination buffer
243 //              qwQwordVal_p    = quadruple word value
244 //
245 // Return:      void
246 //
247 //---------------------------------------------------------------------------
248
249 void PUBLIC AmiSetQword48ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
250 void PUBLIC AmiSetQword48ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
251
252
253 //---------------------------------------------------------------------------
254 //
255 // Function:    AmiGetQword48()
256 //
257 // Description: reads a 48 bit value from a buffer
258 //
259 // Parameters:  pAddr_p         = pointer to source buffer
260 //
261 // Return:      QWORD
262 //
263 //---------------------------------------------------------------------------
264
265 QWORD PUBLIC AmiGetQword48FromBe (void FAR* pAddr_p);
266 QWORD PUBLIC AmiGetQword48FromLe (void FAR* pAddr_p);
267
268
269 //---------------------------------------------------------------------------
270 //
271 // Function:    AmiSetQword56()
272 //
273 // Description: sets a 56 bit value to a buffer
274 //
275 // Parameters:  pAddr_p         = pointer to destination buffer
276 //              qwQwordVal_p    = quadruple word value
277 //
278 // Return:      void
279 //
280 //---------------------------------------------------------------------------
281
282 void PUBLIC AmiSetQword56ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
283 void PUBLIC AmiSetQword56ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
284
285
286 //---------------------------------------------------------------------------
287 //
288 // Function:    AmiGetQword56()
289 //
290 // Description: reads a 56 bit value from a buffer
291 //
292 // Parameters:  pAddr_p         = pointer to source buffer
293 //
294 // Return:      QWORD
295 //
296 //---------------------------------------------------------------------------
297
298 QWORD PUBLIC AmiGetQword56FromBe (void FAR* pAddr_p);
299 QWORD PUBLIC AmiGetQword56FromLe (void FAR* pAddr_p);
300
301
302 //---------------------------------------------------------------------------
303 //
304 // Function:    AmiSetQword64()
305 //
306 // Description: sets a 64 bit value to a buffer
307 //
308 // Parameters:  pAddr_p         = pointer to destination buffer
309 //              qwQwordVal_p    = quadruple word value
310 //
311 // Return:      void
312 //
313 //---------------------------------------------------------------------------
314
315 void PUBLIC AmiSetQword64ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
316 void PUBLIC AmiSetQword64ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
317
318
319 //---------------------------------------------------------------------------
320 //
321 // Function:    AmiGetQword64()
322 //
323 // Description: reads a 64 bit value from a buffer
324 //
325 // Parameters:  pAddr_p         = pointer to source buffer
326 //
327 // Return:      void
328 //
329 //---------------------------------------------------------------------------
330
331 QWORD PUBLIC AmiGetQword64FromBe (void FAR* pAddr_p);
332 QWORD PUBLIC AmiGetQword64FromLe (void FAR* pAddr_p);
333
334
335 //---------------------------------------------------------------------------
336 //
337 // Function:    AmiSetTimeOfDay()
338 //
339 // Description: sets a TIME_OF_DAY (CANopen) value to a buffer
340 //
341 // Parameters:  pAddr_p         = pointer to destination buffer
342 //              pTimeOfDay_p    = pointer to struct TIME_OF_DAY
343 //
344 // Return:      void
345 //
346 //---------------------------------------------------------------------------
347
348 void PUBLIC AmiSetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p);
349
350
351 //---------------------------------------------------------------------------
352 //
353 // Function:    AmiGetTimeOfDay()
354 //
355 // Description: reads a TIME_OF_DAY (CANopen) value from a buffer
356 //
357 // Parameters:  pAddr_p         = pointer to source buffer
358 //              pTimeOfDay_p    = pointer to struct TIME_OF_DAY
359 //
360 // Return:      void
361 //
362 //---------------------------------------------------------------------------
363
364 void PUBLIC AmiGetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p);
365
366 #endif
367
368
369 #undef  INLINE_ENABLED              // disable actual inlining of functions
370 #define EPL_AMI_INCLUDED
371
372 #ifdef __cplusplus
373     }
374 #endif
375
376
377 #endif  // ifndef _EPLAMI_H_
378
379 // Die letzte Zeile muß unbedingt eine leere Zeile sein, weil manche Compiler
380 // damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder).