296b0200e1f7b1e00ccf197c20f22a4f5dadf3ac
[safe/jmp/linux-2.6] / 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 #if ((DEV_SYSTEM & _DEV_64BIT_SUPPORT_) == 0)
90 //    #ifdef USE_VAR64
91 #error 'ERROR: development system does not support 64 bit operations!'
92 //    #endif
93 #endif
94
95 //---------------------------------------------------------------------------
96 //  types
97 //---------------------------------------------------------------------------
98
99 //---------------------------------------------------------------------------
100 //  Prototypen
101 //---------------------------------------------------------------------------
102
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106
107 //---------------------------------------------------------------------------
108 //
109 // write functions
110 //
111 // To save code space the function AmiSetByte is replaced by
112 // an macro.
113 // void  AmiSetByte  (void FAR* pAddr_p, BYTE bByteVal_p);
114
115 #define AmiSetByteToBe(pAddr_p, bByteVal_p)  {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
116 #define AmiSetByteToLe(pAddr_p, bByteVal_p)  {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
117
118 void AmiSetWordToBe(void FAR *pAddr_p, WORD wWordVal_p);
119 void AmiSetDwordToBe(void FAR *pAddr_p, DWORD dwDwordVal_p);
120 void AmiSetWordToLe(void FAR *pAddr_p, WORD wWordVal_p);
121 void AmiSetDwordToLe(void FAR *pAddr_p, DWORD dwDwordVal_p);
122
123 //---------------------------------------------------------------------------
124 //
125 // read functions
126 //
127 // To save code space the function AmiGetByte is replaced by
128 // an macro.
129 // BYTE   AmiGetByte  (void FAR* pAddr_p);
130
131 #define AmiGetByteFromBe(pAddr_p)  (*(BYTE FAR*)(pAddr_p))
132 #define AmiGetByteFromLe(pAddr_p)  (*(BYTE FAR*)(pAddr_p))
133
134 WORD AmiGetWordFromBe(void FAR *pAddr_p);
135 DWORD AmiGetDwordFromBe(void FAR *pAddr_p);
136 WORD AmiGetWordFromLe(void FAR *pAddr_p);
137 DWORD AmiGetDwordFromLe(void FAR *pAddr_p);
138
139 //---------------------------------------------------------------------------
140 //
141 // Function:    AmiSetDword24()
142 //
143 // Description: sets a 24 bit value to a buffer
144 //
145 // Parameters:  pAddr_p         = pointer to destination buffer
146 //              dwDwordVal_p    = value to set
147 //
148 // Return:      void
149 //
150 //---------------------------------------------------------------------------
151
152 void AmiSetDword24ToBe(void FAR *pAddr_p, DWORD dwDwordVal_p);
153 void AmiSetDword24ToLe(void FAR *pAddr_p, DWORD dwDwordVal_p);
154
155 //---------------------------------------------------------------------------
156 //
157 // Function:    AmiGetDword24()
158 //
159 // Description: reads a 24 bit value from a buffer
160 //
161 // Parameters:  pAddr_p         = pointer to source buffer
162 //
163 // Return:      DWORD           = read value
164 //
165 //---------------------------------------------------------------------------
166
167 DWORD AmiGetDword24FromBe(void FAR *pAddr_p);
168 DWORD AmiGetDword24FromLe(void FAR *pAddr_p);
169
170 //#ifdef USE_VAR64
171
172 //---------------------------------------------------------------------------
173 //
174 // Function:    AmiSetQword40()
175 //
176 // Description: sets a 40 bit value to a buffer
177 //
178 // Parameters:  pAddr_p         = pointer to destination buffer
179 //              qwQwordVal_p    = quadruple word value
180 //
181 // Return:      void
182 //
183 //---------------------------------------------------------------------------
184
185 void AmiSetQword40ToBe(void FAR *pAddr_p, QWORD qwQwordVal_p);
186 void AmiSetQword40ToLe(void FAR *pAddr_p, QWORD qwQwordVal_p);
187
188 //---------------------------------------------------------------------------
189 //
190 // Function:    AmiGetQword40()
191 //
192 // Description: reads a 40 bit value from a buffer
193 //
194 // Parameters:  pAddr_p         = pointer to source buffer
195 //
196 // Return:      QWORD
197 //
198 //---------------------------------------------------------------------------
199
200 QWORD AmiGetQword40FromBe(void FAR *pAddr_p);
201 QWORD AmiGetQword40FromLe(void FAR *pAddr_p);
202
203 //---------------------------------------------------------------------------
204 //
205 // Function:    AmiSetQword48()
206 //
207 // Description: sets a 48 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 AmiSetQword48ToBe(void FAR *pAddr_p, QWORD qwQwordVal_p);
217 void AmiSetQword48ToLe(void FAR *pAddr_p, QWORD qwQwordVal_p);
218
219 //---------------------------------------------------------------------------
220 //
221 // Function:    AmiGetQword48()
222 //
223 // Description: reads a 48 bit value from a buffer
224 //
225 // Parameters:  pAddr_p         = pointer to source buffer
226 //
227 // Return:      QWORD
228 //
229 //---------------------------------------------------------------------------
230
231 QWORD AmiGetQword48FromBe(void FAR *pAddr_p);
232 QWORD AmiGetQword48FromLe(void FAR *pAddr_p);
233
234 //---------------------------------------------------------------------------
235 //
236 // Function:    AmiSetQword56()
237 //
238 // Description: sets a 56 bit value to a buffer
239 //
240 // Parameters:  pAddr_p         = pointer to destination buffer
241 //              qwQwordVal_p    = quadruple word value
242 //
243 // Return:      void
244 //
245 //---------------------------------------------------------------------------
246
247 void AmiSetQword56ToBe(void FAR *pAddr_p, QWORD qwQwordVal_p);
248 void AmiSetQword56ToLe(void FAR *pAddr_p, QWORD qwQwordVal_p);
249
250 //---------------------------------------------------------------------------
251 //
252 // Function:    AmiGetQword56()
253 //
254 // Description: reads a 56 bit value from a buffer
255 //
256 // Parameters:  pAddr_p         = pointer to source buffer
257 //
258 // Return:      QWORD
259 //
260 //---------------------------------------------------------------------------
261
262 QWORD AmiGetQword56FromBe(void FAR *pAddr_p);
263 QWORD AmiGetQword56FromLe(void FAR *pAddr_p);
264
265 //---------------------------------------------------------------------------
266 //
267 // Function:    AmiSetQword64()
268 //
269 // Description: sets a 64 bit value to a buffer
270 //
271 // Parameters:  pAddr_p         = pointer to destination buffer
272 //              qwQwordVal_p    = quadruple word value
273 //
274 // Return:      void
275 //
276 //---------------------------------------------------------------------------
277
278 void AmiSetQword64ToBe(void FAR *pAddr_p, QWORD qwQwordVal_p);
279 void AmiSetQword64ToLe(void FAR *pAddr_p, QWORD qwQwordVal_p);
280
281 //---------------------------------------------------------------------------
282 //
283 // Function:    AmiGetQword64()
284 //
285 // Description: reads a 64 bit value from a buffer
286 //
287 // Parameters:  pAddr_p         = pointer to source buffer
288 //
289 // Return:      void
290 //
291 //---------------------------------------------------------------------------
292
293 QWORD AmiGetQword64FromBe(void FAR *pAddr_p);
294 QWORD AmiGetQword64FromLe(void FAR *pAddr_p);
295
296 //---------------------------------------------------------------------------
297 //
298 // Function:    AmiSetTimeOfDay()
299 //
300 // Description: sets a TIME_OF_DAY (CANopen) value to a buffer
301 //
302 // Parameters:  pAddr_p         = pointer to destination buffer
303 //              pTimeOfDay_p    = pointer to struct TIME_OF_DAY
304 //
305 // Return:      void
306 //
307 //---------------------------------------------------------------------------
308 void AmiSetTimeOfDay(void FAR *pAddr_p, tTimeOfDay FAR *pTimeOfDay_p);
309
310 //---------------------------------------------------------------------------
311 //
312 // Function:    AmiGetTimeOfDay()
313 //
314 // Description: reads a TIME_OF_DAY (CANopen) value from a buffer
315 //
316 // Parameters:  pAddr_p         = pointer to source buffer
317 //              pTimeOfDay_p    = pointer to struct TIME_OF_DAY
318 //
319 // Return:      void
320 //
321 //---------------------------------------------------------------------------
322 void AmiGetTimeOfDay(void FAR *pAddr_p, tTimeOfDay FAR *pTimeOfDay_p);
323
324 #ifdef __cplusplus
325 }
326 #endif
327 #endif                          // ifndef _EPLAMI_H_
328 // Die letzte Zeile muß unbedingt eine leere Zeile sein, weil manche Compiler// damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder).