iwlwifi: 3945 remove iwl-3945-commands.h
[safe/jmp/linux-2.6] / drivers / staging / epl / EplObd.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:  include file for api function of EplOBD-Module
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: EplObd.h,v $
53
54                 $Author: D.Krueger $
55
56                 $Revision: 1.5 $  $Date: 2008/04/17 21:36:32 $
57
58                 $State: Exp $
59
60                 Build Environment:
61                 Microsoft VC7
62
63   -------------------------------------------------------------------------
64
65   Revision History:
66
67   2006/06/02 k.t.:   start of the implementation, version 1.00
68
69 ****************************************************************************/
70
71 #include "EplInc.h"
72
73 #ifndef _EPLOBD_H_
74 #define _EPLOBD_H_
75
76 // ============================================================================
77 // defines
78 // ============================================================================
79
80 #define EPL_OBD_TABLE_INDEX_END     0xFFFF
81
82 // for the usage of BOOLEAN in OD
83 #define OBD_TRUE    0x01
84 #define OBD_FALSE   0x00
85
86 // default OD index for Node id
87 #define EPL_OBD_NODE_ID_INDEX               0x1F93
88 // default subindex for NodeId in OD
89 #define EPL_OBD_NODE_ID_SUBINDEX            0x01
90 // default subindex for NodeIDByHW_BOOL
91 #define EPL_OBD_NODE_ID_HWBOOL_SUBINDEX     0x02
92
93 // ============================================================================
94 // enums
95 // ============================================================================
96
97 // directions for access to object dictionary
98 typedef enum {
99         kEplObdDirInit = 0x00,  // initialising after power on
100         kEplObdDirStore = 0x01, // store all object values to non volatile memory
101         kEplObdDirLoad = 0x02,  // load all object values from non volatile memory
102         kEplObdDirRestore = 0x03,       // deletes non volatile memory (restore)
103         kEplObdDirOBKCheck = 0xFF       // reserved
104 } tEplObdDir;
105
106 // commands for store
107 typedef enum {
108         kEplObdCommNothing = 0x00,
109         kEplObdCommOpenWrite = 0x01,
110         kEplObdCommWriteObj = 0x02,
111         kEplObdCommCloseWrite = 0x03,
112         kEplObdCommOpenRead = 0x04,
113         kEplObdCommReadObj = 0x05,
114         kEplObdCommCloseRead = 0x06,
115         kEplObdCommClear = 0x07,
116         kEplObdCommUnknown = 0xFF
117 } tEplObdCommand;
118
119 //-----------------------------------------------------------------------------------------------------------
120 // events of object callback function
121 typedef enum {
122 //                                                                                                      m_pArg points to
123 //                                                                                                    ---------------------
124         kEplObdEvCheckExist = 0x06,     // checking if object does exist (reading and writing)    NULL
125         kEplObdEvPreRead = 0x00,        // before reading an object                               source data buffer in OD
126         kEplObdEvPostRead = 0x01,       // after reading an object                                destination data buffer from caller
127         kEplObdEvWrStringDomain = 0x07, // event for changing string/domain data pointer or size  struct tEplObdVStringDomain in RAM
128         kEplObdEvInitWrite = 0x04,      // initializes writing an object (checking object size)   size of object in OD (tEplObdSize)
129         kEplObdEvPreWrite = 0x02,       // before writing an object                               source data buffer from caller
130         kEplObdEvPostWrite = 0x03,      // after writing an object                                destination data buffer in OD
131 //    kEplObdEvAbortSdo              = 0x05     // after an abort of an SDO transfer
132
133 } tEplObdEvent;
134
135 // part of OD (bit oriented)
136 typedef unsigned int tEplObdPart;
137
138 #define kEplObdPartNo          0x00     // nothing
139 #define kEplObdPartGen         0x01     //  part      (0x1000 - 0x1FFF)
140 #define kEplObdPartMan         0x02     // manufacturer part (0x2000 - 0x5FFF)
141 #define kEplObdPartDev         0x04     // device part       (0x6000 - 0x9FFF)
142 #define kEplObdPartUsr         0x08     // dynamic part e.g. for ICE61131-3
143
144 // combinations
145 #define kEplObdPartApp         (              kEplObdPartMan | kEplObdPartDev | kEplObdPartUsr) // manufacturer and device part (0x2000 - 0x9FFF) and user OD
146 #define kEplObdPartAll         (kEplObdPartGen | kEplObdPartMan | kEplObdPartDev | kEplObdPartUsr)      // whole OD
147
148 //-----------------------------------------------------------------------------------------------------------
149 // access types for objects
150 // must be a difine because bit-flags
151 typedef unsigned int tEplObdAccess;
152
153 #define kEplObdAccRead         0x01     // object can be read
154 #define kEplObdAccWrite        0x02     // object can be written
155 #define kEplObdAccConst        0x04     // object contains a constant value
156 #define kEplObdAccPdo          0x08     // object can be mapped in a PDO
157 #define kEplObdAccArray        0x10     // object contains an array of numerical values
158 #define kEplObdAccRange        0x20     // object contains lower and upper limit
159 #define kEplObdAccVar          0x40     // object data is placed in application
160 #define kEplObdAccStore        0x80     // object data can be stored to non volatile memory
161
162 // combinations (not all combinations are required)
163 #define kEplObdAccR            (0            | 0          | 0            | 0          | 0            | 0            | kEplObdAccRead)
164 #define kEplObdAccW            (0            | 0          | 0            | 0          | 0            | kEplObdAccWrite | 0          )
165 #define kEplObdAccRW           (0            | 0          | 0            | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
166 #define kEplObdAccCR           (0            | 0          | 0            | 0          | kEplObdAccConst | 0            | kEplObdAccRead)
167 #define kEplObdAccGR           (0            | 0          | kEplObdAccRange | 0          | 0            | 0            | kEplObdAccRead)
168 #define kEplObdAccGW           (0            | 0          | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | 0          )
169 #define kEplObdAccGRW          (0            | 0          | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
170 #define kEplObdAccVR           (0            | kEplObdAccVar | 0            | 0          | 0            | 0            | kEplObdAccRead)
171 #define kEplObdAccVW           (0            | kEplObdAccVar | 0            | 0          | 0            | kEplObdAccWrite | 0          )
172 #define kEplObdAccVRW          (0            | kEplObdAccVar | 0            | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
173 #define kEplObdAccVPR          (0            | kEplObdAccVar | 0            | kEplObdAccPdo | 0            | 0            | kEplObdAccRead)
174 #define kEplObdAccVPW          (0            | kEplObdAccVar | 0            | kEplObdAccPdo | 0            | kEplObdAccWrite | 0          )
175 #define kEplObdAccVPRW         (0            | kEplObdAccVar | 0            | kEplObdAccPdo | 0            | kEplObdAccWrite | kEplObdAccRead)
176 #define kEplObdAccVGR          (0            | kEplObdAccVar | kEplObdAccRange | 0          | 0            | 0            | kEplObdAccRead)
177 #define kEplObdAccVGW          (0            | kEplObdAccVar | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | 0          )
178 #define kEplObdAccVGRW         (0            | kEplObdAccVar | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
179 #define kEplObdAccVGPR         (0            | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0            | 0            | kEplObdAccRead)
180 #define kEplObdAccVGPW         (0            | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0            | kEplObdAccWrite | 0          )
181 #define kEplObdAccVGPRW        (0            | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0            | kEplObdAccWrite | kEplObdAccRead)
182 #define kEplObdAccSR           (kEplObdAccStore | 0          | 0            | 0          | 0            | 0            | kEplObdAccRead)
183 #define kEplObdAccSW           (kEplObdAccStore | 0          | 0            | 0          | 0            | kEplObdAccWrite | 0          )
184 #define kEplObdAccSRW          (kEplObdAccStore | 0          | 0            | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
185 #define kEplObdAccSCR          (kEplObdAccStore | 0          | 0            | 0          | kEplObdAccConst | 0            | kEplObdAccRead)
186 #define kEplObdAccSGR          (kEplObdAccStore | 0          | kEplObdAccRange | 0          | 0            | 0            | kEplObdAccRead)
187 #define kEplObdAccSGW          (kEplObdAccStore | 0          | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | 0          )
188 #define kEplObdAccSGRW         (kEplObdAccStore | 0          | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
189 #define kEplObdAccSVR          (kEplObdAccStore | kEplObdAccVar | 0            | 0          | 0            | 0            | kEplObdAccRead)
190 #define kEplObdAccSVW          (kEplObdAccStore | kEplObdAccVar | 0            | 0          | 0            | kEplObdAccWrite | 0          )
191 #define kEplObdAccSVRW         (kEplObdAccStore | kEplObdAccVar | 0            | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
192 #define kEplObdAccSVPR         (kEplObdAccStore | kEplObdAccVar | 0            | kEplObdAccPdo | 0            | 0            | kEplObdAccRead)
193 #define kEplObdAccSVPW         (kEplObdAccStore | kEplObdAccVar | 0            | kEplObdAccPdo | 0            | kEplObdAccWrite | 0          )
194 #define kEplObdAccSVPRW        (kEplObdAccStore | kEplObdAccVar | 0            | kEplObdAccPdo | 0            | kEplObdAccWrite | kEplObdAccRead)
195 #define kEplObdAccSVGR         (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | 0          | 0            | 0            | kEplObdAccRead)
196 #define kEplObdAccSVGW         (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | 0          )
197 #define kEplObdAccSVGRW        (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | 0          | 0            | kEplObdAccWrite | kEplObdAccRead)
198 #define kEplObdAccSVGPR        (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0            | 0            | kEplObdAccRead)
199 #define kEplObdAccSVGPW        (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0            | kEplObdAccWrite | 0          )
200 #define kEplObdAccSVGPRW       (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0            | kEplObdAccWrite | kEplObdAccRead)
201
202 typedef unsigned int tEplObdSize;       // For all objects as objects size are used an unsigned int.
203
204 // -------------------------------------------------------------------------
205 // types for data types defined in DS301
206 // -------------------------------------------------------------------------
207
208 // types of objects in object dictionary
209 // DS-301 defines these types as WORD
210 typedef enum {
211 // types which are always supported
212         kEplObdTypBool = 0x0001,
213
214         kEplObdTypInt8 = 0x0002,
215         kEplObdTypInt16 = 0x0003,
216         kEplObdTypInt32 = 0x0004,
217         kEplObdTypUInt8 = 0x0005,
218         kEplObdTypUInt16 = 0x0006,
219         kEplObdTypUInt32 = 0x0007,
220         kEplObdTypReal32 = 0x0008,
221         kEplObdTypVString = 0x0009,
222         kEplObdTypOString = 0x000A,
223         kEplObdTypDomain = 0x000F,
224
225         kEplObdTypInt24 = 0x0010,
226         kEplObdTypUInt24 = 0x0016,
227
228         kEplObdTypReal64 = 0x0011,
229         kEplObdTypInt40 = 0x0012,
230         kEplObdTypInt48 = 0x0013,
231         kEplObdTypInt56 = 0x0014,
232         kEplObdTypInt64 = 0x0015,
233         kEplObdTypUInt40 = 0x0018,
234         kEplObdTypUInt48 = 0x0019,
235         kEplObdTypUInt56 = 0x001A,
236         kEplObdTypUInt64 = 0x001B,
237         kEplObdTypTimeOfDay = 0x000C,
238         kEplObdTypTimeDiff = 0x000D
239 } tEplObdType;
240 // other types are not supported in this version
241
242 // -------------------------------------------------------------------------
243 // types for data types defined in DS301
244 // -------------------------------------------------------------------------
245
246 typedef unsigned char tEplObdBoolean;   // 0001
247 typedef signed char tEplObdInteger8;    // 0002
248 typedef signed short int tEplObdInteger16;      // 0003
249 typedef signed long tEplObdInteger32;   // 0004
250 typedef unsigned char tEplObdUnsigned8; // 0005
251 typedef unsigned short int tEplObdUnsigned16;   // 0006
252 typedef unsigned long tEplObdUnsigned32;        // 0007
253 typedef float tEplObdReal32;    // 0008
254 typedef unsigned char tEplObdDomain;    // 000F
255 typedef signed long tEplObdInteger24;   // 0010
256 typedef unsigned long tEplObdUnsigned24;        // 0016
257
258 typedef signed QWORD tEplObdInteger40;  // 0012
259 typedef signed QWORD tEplObdInteger48;  // 0013
260 typedef signed QWORD tEplObdInteger56;  // 0014
261 typedef signed QWORD tEplObdInteger64;  // 0015
262
263 typedef unsigned QWORD tEplObdUnsigned40;       // 0018
264 typedef unsigned QWORD tEplObdUnsigned48;       // 0019
265 typedef unsigned QWORD tEplObdUnsigned56;       // 001A
266 typedef unsigned QWORD tEplObdUnsigned64;       // 001B
267
268 typedef double tEplObdReal64;   // 0011
269
270 typedef tTimeOfDay tEplObdTimeOfDay;    // 000C
271 typedef tTimeOfDay tEplObdTimeDifference;       // 000D
272
273 // -------------------------------------------------------------------------
274 // structur for defining a variable
275 // -------------------------------------------------------------------------
276 // -------------------------------------------------------------------------
277 typedef enum {
278         kVarValidSize = 0x01,
279         kVarValidData = 0x02,
280 //    kVarValidCallback       = 0x04,
281 //    kVarValidArg            = 0x08,
282
283         kVarValidAll = 0x03     // currently only size and data are implemented and used
284 } tEplVarParamValid;
285
286 typedef tEplKernel(PUBLIC ROM * tEplVarCallback) (CCM_DECL_INSTANCE_HDL_
287                                                   void *pParam_p);
288
289 typedef struct {
290         tEplVarParamValid m_ValidFlag;
291         unsigned int m_uiIndex;
292         unsigned int m_uiSubindex;
293         tEplObdSize m_Size;
294         void MEM *m_pData;
295 //    tEplVarCallback     m_fpCallback;
296 //    void *       m_pArg;
297
298 } tEplVarParam;
299
300 typedef struct {
301         void MEM *m_pData;
302         tEplObdSize m_Size;
303 /*
304     #if (EPL_PDO_USE_STATIC_MAPPING == FALSE)
305         tEplVarCallback    m_fpCallback;
306         void *   m_pArg;
307     #endif
308 */
309 } tEplObdVarEntry;
310
311 typedef struct {
312         tEplObdSize m_Size;
313         BYTE *m_pString;
314
315 } tEplObdOString;               // 000C
316
317 typedef struct {
318         tEplObdSize m_Size;
319         char *m_pString;
320 } tEplObdVString;               // 000D
321
322 typedef struct {
323         tEplObdSize m_Size;
324         char *m_pDefString;     // $$$ d.k. it is unused, so we could delete it
325         char *m_pString;
326
327 } tEplObdVStringDef;
328
329 typedef struct {
330         tEplObdSize m_Size;
331         BYTE *m_pDefString;     // $$$ d.k. it is unused, so we could delete it
332         BYTE *m_pString;
333
334 } tEplObdOStringDef;
335
336 //r.d. parameter struct for changing object size and/or pointer to data of Strings or Domains
337 typedef struct {
338         tEplObdSize m_DownloadSize;     // download size from SDO or APP
339         tEplObdSize m_ObjSize;  // current object size from OD - should be changed from callback function
340         void *m_pData;          // current object ptr  from OD - should be changed from callback function
341
342 } tEplObdVStringDomain;         // 000D
343
344 // ============================================================================
345 // types
346 // ============================================================================
347 // -------------------------------------------------------------------------
348 // subindexstruct
349 // -------------------------------------------------------------------------
350
351 // Change not the order for this struct!!!
352 typedef struct {
353         unsigned int m_uiSubIndex;
354         tEplObdType m_Type;
355         tEplObdAccess m_Access;
356         void *m_pDefault;
357         void MEM *m_pCurrent;   // points always to RAM
358
359 } tEplObdSubEntry;
360
361 // r.d.: has always to be  because new OBD-Macros for arrays
362 typedef tEplObdSubEntry *tEplObdSubEntryPtr;
363
364 // -------------------------------------------------------------------------
365 // callback function for objdictionary modul
366 // -------------------------------------------------------------------------
367
368 // parameters for callback function
369 typedef struct {
370         tEplObdEvent m_ObdEvent;
371         unsigned int m_uiIndex;
372         unsigned int m_uiSubIndex;
373         void *m_pArg;
374         DWORD m_dwAbortCode;
375
376 } tEplObdCbParam;
377
378 // define type for callback function: pParam_p points to tEplObdCbParam
379 typedef tEplKernel(PUBLIC ROM * tEplObdCallback) (CCM_DECL_INSTANCE_HDL_
380                                                   tEplObdCbParam MEM *
381                                                   pParam_p);
382
383 // do not change the order for this struct!!!
384
385 typedef struct {
386         unsigned int m_uiIndex;
387         tEplObdSubEntryPtr m_pSubIndex;
388         unsigned int m_uiCount;
389         tEplObdCallback m_fpCallback;   // function is called back if object access
390
391 } tEplObdEntry;
392
393 // allways  pointer
394 typedef tEplObdEntry *tEplObdEntryPtr;
395
396 // -------------------------------------------------------------------------
397 // structur to initialize OBD module
398 // -------------------------------------------------------------------------
399
400 typedef struct {
401         tEplObdEntryPtr m_pPart;
402         tEplObdEntryPtr m_pManufacturerPart;
403         tEplObdEntryPtr m_pDevicePart;
404
405 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
406
407         tEplObdEntryPtr m_pUserPart;
408
409 #endif
410
411 } tEplObdInitParam;
412
413 // -------------------------------------------------------------------------
414 // structur for parameters of STORE RESTORE command
415 // -------------------------------------------------------------------------
416
417 typedef struct {
418         tEplObdCommand m_bCommand;
419         tEplObdPart m_bCurrentOdPart;
420         void MEM *m_pData;
421         tEplObdSize m_ObjSize;
422
423 } tEplObdCbStoreParam;
424
425 typedef tEplKernel(PUBLIC ROM * tInitTabEntryCallback) (void MEM * pTabEntry_p,
426                                                         unsigned int
427                                                         uiObjIndex_p);
428
429 typedef tEplKernel(PUBLIC ROM *
430                    tEplObdStoreLoadObjCallback) (CCM_DECL_INSTANCE_HDL_
431                                                  tEplObdCbStoreParam MEM *
432                                                  pCbStoreParam_p);
433
434 // -------------------------------------------------------------------------
435 // this stucture is used for parameters for function ObdInitModuleTab()
436 // -------------------------------------------------------------------------
437 typedef struct {
438         unsigned int m_uiLowerObjIndex; // lower limit of ObjIndex
439         unsigned int m_uiUpperObjIndex; // upper limit of ObjIndex
440         tInitTabEntryCallback m_fpInitTabEntry; // will be called if ObjIndex was found
441         void MEM *m_pTabBase;   // base address of table
442         unsigned int m_uiEntrySize;     // size of table entry      // 25-feb-2005 r.d.: expansion from BYTE to WORD necessary for PDO bit mapping
443         unsigned int m_uiMaxEntries;    // max. tabel entries
444
445 } tEplObdModulTabParam;
446
447 //-------------------------------------------------------------------
448 //  enum for function EplObdSetNodeId
449 //-------------------------------------------------------------------
450 typedef enum {
451         kEplObdNodeIdUnknown = 0x00,    // unknown how the node id was set
452         kEplObdNodeIdSoftware = 0x01,   // node id set by software
453         kEplObdNodeIdHardware = 0x02    // node id set by hardware
454 } tEplObdNodeIdType;
455
456 // ============================================================================
457 // global variables
458 // ============================================================================
459
460 // ============================================================================
461 // public functions
462 // ============================================================================
463
464 #endif // #ifndef _EPLOBD_H_