blob: 6fa04a4f0a130978395d74680c7f590a5cc4c32a [file] [log] [blame]
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001/****************************************************************************
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
Daniel Krueger9d7164c2008-12-19 11:41:57 -080089#if ((DEV_SYSTEM & _DEV_64BIT_SUPPORT_) == 0)
90// #ifdef USE_VAR64
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -080091#error 'ERROR: development system does not support 64 bit operations!'
Daniel Krueger9d7164c2008-12-19 11:41:57 -080092// #endif
93#endif
94
Daniel Krueger9d7164c2008-12-19 11:41:57 -080095//---------------------------------------------------------------------------
96// types
97//---------------------------------------------------------------------------
98
Daniel Krueger9d7164c2008-12-19 11:41:57 -080099//---------------------------------------------------------------------------
100// Prototypen
101//---------------------------------------------------------------------------
102
103#ifdef __cplusplus
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800104extern "C" {
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800105#endif
106
107#if (TARGET_SYSTEM == _WIN32_)
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800108#if defined(INLINE_FUNCTION_DEF)
109#undef INLINE_FUNCTION
110#define INLINE_FUNCTION INLINE_FUNCTION_DEF
111#define INLINE_ENABLED TRUE
112#define EPL_AMI_INLINED
113#include "../EplStack/amix86.c"
114#endif
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800115
116#elif (TARGET_SYSTEM == _LINUX_)
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800117#if defined(__m68k__) // it is an big endian machine
118#if defined(INLINE_FUNCTION_DEF)
119#undef INLINE_FUNCTION
120#define INLINE_FUNCTION INLINE_FUNCTION_DEF
121#define INLINE_ENABLED TRUE
122#define EPL_AMI_INLINED
123#include "../EplStack/amibe.c"
124#endif
125#endif
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800126#endif
127
128//---------------------------------------------------------------------------
129//
130// write functions
131//
132// To save code space the function AmiSetByte is replaced by
133// an macro.
134// void PUBLIC AmiSetByte (void FAR* pAddr_p, BYTE bByteVal_p);
135
136#define AmiSetByteToBe(pAddr_p, bByteVal_p) {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
137#define AmiSetByteToLe(pAddr_p, bByteVal_p) {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
138
139#if !defined(INLINE_ENABLED)
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800140 void PUBLIC AmiSetWordToBe(void FAR * pAddr_p, WORD wWordVal_p);
141 void PUBLIC AmiSetDwordToBe(void FAR * pAddr_p, DWORD dwDwordVal_p);
142 void PUBLIC AmiSetWordToLe(void FAR * pAddr_p, WORD wWordVal_p);
143 void PUBLIC AmiSetDwordToLe(void FAR * pAddr_p, DWORD dwDwordVal_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800144#endif
145
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800146//---------------------------------------------------------------------------
147//
148// read functions
149//
150// To save code space the function AmiGetByte is replaced by
151// an macro.
152// BYTE PUBLIC AmiGetByte (void FAR* pAddr_p);
153
154#define AmiGetByteFromBe(pAddr_p) (*(BYTE FAR*)(pAddr_p))
155#define AmiGetByteFromLe(pAddr_p) (*(BYTE FAR*)(pAddr_p))
156
157#if !defined(INLINE_ENABLED)
158
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800159 WORD PUBLIC AmiGetWordFromBe(void FAR * pAddr_p);
160 DWORD PUBLIC AmiGetDwordFromBe(void FAR * pAddr_p);
161 WORD PUBLIC AmiGetWordFromLe(void FAR * pAddr_p);
162 DWORD PUBLIC AmiGetDwordFromLe(void FAR * pAddr_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800163
164//---------------------------------------------------------------------------
165//
166// Function: AmiSetDword24()
167//
168// Description: sets a 24 bit value to a buffer
169//
170// Parameters: pAddr_p = pointer to destination buffer
171// dwDwordVal_p = value to set
172//
173// Return: void
174//
175//---------------------------------------------------------------------------
176
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800177 void PUBLIC AmiSetDword24ToBe(void FAR * pAddr_p, DWORD dwDwordVal_p);
178 void PUBLIC AmiSetDword24ToLe(void FAR * pAddr_p, DWORD dwDwordVal_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800179
180//---------------------------------------------------------------------------
181//
182// Function: AmiGetDword24()
183//
184// Description: reads a 24 bit value from a buffer
185//
186// Parameters: pAddr_p = pointer to source buffer
187//
188// Return: DWORD = read value
189//
190//---------------------------------------------------------------------------
191
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800192 DWORD PUBLIC AmiGetDword24FromBe(void FAR * pAddr_p);
193 DWORD PUBLIC AmiGetDword24FromLe(void FAR * pAddr_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800194
195//#ifdef USE_VAR64
196
197//---------------------------------------------------------------------------
198//
199// Function: AmiSetQword40()
200//
201// Description: sets a 40 bit value to a buffer
202//
203// Parameters: pAddr_p = pointer to destination buffer
204// qwQwordVal_p = quadruple word value
205//
206// Return: void
207//
208//---------------------------------------------------------------------------
209
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800210 void PUBLIC AmiSetQword40ToBe(void FAR * pAddr_p, QWORD qwQwordVal_p);
211 void PUBLIC AmiSetQword40ToLe(void FAR * pAddr_p, QWORD qwQwordVal_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800212
213//---------------------------------------------------------------------------
214//
215// Function: AmiGetQword40()
216//
217// Description: reads a 40 bit value from a buffer
218//
219// Parameters: pAddr_p = pointer to source buffer
220//
221// Return: QWORD
222//
223//---------------------------------------------------------------------------
224
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800225 QWORD PUBLIC AmiGetQword40FromBe(void FAR * pAddr_p);
226 QWORD PUBLIC AmiGetQword40FromLe(void FAR * pAddr_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800227
228//---------------------------------------------------------------------------
229//
230// Function: AmiSetQword48()
231//
232// Description: sets a 48 bit value to a buffer
233//
234// Parameters: pAddr_p = pointer to destination buffer
235// qwQwordVal_p = quadruple word value
236//
237// Return: void
238//
239//---------------------------------------------------------------------------
240
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800241 void PUBLIC AmiSetQword48ToBe(void FAR * pAddr_p, QWORD qwQwordVal_p);
242 void PUBLIC AmiSetQword48ToLe(void FAR * pAddr_p, QWORD qwQwordVal_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800243
244//---------------------------------------------------------------------------
245//
246// Function: AmiGetQword48()
247//
248// Description: reads a 48 bit value from a buffer
249//
250// Parameters: pAddr_p = pointer to source buffer
251//
252// Return: QWORD
253//
254//---------------------------------------------------------------------------
255
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800256 QWORD PUBLIC AmiGetQword48FromBe(void FAR * pAddr_p);
257 QWORD PUBLIC AmiGetQword48FromLe(void FAR * pAddr_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800258
259//---------------------------------------------------------------------------
260//
261// Function: AmiSetQword56()
262//
263// Description: sets a 56 bit value to a buffer
264//
265// Parameters: pAddr_p = pointer to destination buffer
266// qwQwordVal_p = quadruple word value
267//
268// Return: void
269//
270//---------------------------------------------------------------------------
271
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800272 void PUBLIC AmiSetQword56ToBe(void FAR * pAddr_p, QWORD qwQwordVal_p);
273 void PUBLIC AmiSetQword56ToLe(void FAR * pAddr_p, QWORD qwQwordVal_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800274
275//---------------------------------------------------------------------------
276//
277// Function: AmiGetQword56()
278//
279// Description: reads a 56 bit value from a buffer
280//
281// Parameters: pAddr_p = pointer to source buffer
282//
283// Return: QWORD
284//
285//---------------------------------------------------------------------------
286
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800287 QWORD PUBLIC AmiGetQword56FromBe(void FAR * pAddr_p);
288 QWORD PUBLIC AmiGetQword56FromLe(void FAR * pAddr_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800289
290//---------------------------------------------------------------------------
291//
292// Function: AmiSetQword64()
293//
294// Description: sets a 64 bit value to a buffer
295//
296// Parameters: pAddr_p = pointer to destination buffer
297// qwQwordVal_p = quadruple word value
298//
299// Return: void
300//
301//---------------------------------------------------------------------------
302
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800303 void PUBLIC AmiSetQword64ToBe(void FAR * pAddr_p, QWORD qwQwordVal_p);
304 void PUBLIC AmiSetQword64ToLe(void FAR * pAddr_p, QWORD qwQwordVal_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800305
306//---------------------------------------------------------------------------
307//
308// Function: AmiGetQword64()
309//
310// Description: reads a 64 bit value from a buffer
311//
312// Parameters: pAddr_p = pointer to source buffer
313//
314// Return: void
315//
316//---------------------------------------------------------------------------
317
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800318 QWORD PUBLIC AmiGetQword64FromBe(void FAR * pAddr_p);
319 QWORD PUBLIC AmiGetQword64FromLe(void FAR * pAddr_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800320
321//---------------------------------------------------------------------------
322//
323// Function: AmiSetTimeOfDay()
324//
325// Description: sets a TIME_OF_DAY (CANopen) value to a buffer
326//
327// Parameters: pAddr_p = pointer to destination buffer
328// pTimeOfDay_p = pointer to struct TIME_OF_DAY
329//
330// Return: void
331//
332//---------------------------------------------------------------------------
333
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800334 void PUBLIC AmiSetTimeOfDay(void FAR * pAddr_p,
335 tTimeOfDay FAR * pTimeOfDay_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800336
337//---------------------------------------------------------------------------
338//
339// Function: AmiGetTimeOfDay()
340//
341// Description: reads a TIME_OF_DAY (CANopen) value from a buffer
342//
343// Parameters: pAddr_p = pointer to source buffer
344// pTimeOfDay_p = pointer to struct TIME_OF_DAY
345//
346// Return: void
347//
348//---------------------------------------------------------------------------
349
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800350 void PUBLIC AmiGetTimeOfDay(void FAR * pAddr_p,
351 tTimeOfDay FAR * pTimeOfDay_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800352
353#endif
354
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800355#undef INLINE_ENABLED // disable actual inlining of functions
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800356#define EPL_AMI_INCLUDED
357
358#ifdef __cplusplus
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800359}
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800360#endif
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800361#endif // ifndef _EPLAMI_H_
362// 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).