Staging: aten2011: move .h files into the driver
[linux-2.6] / drivers / staging / epl / EplObduCal.c
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:  source file for communication abstraction layer
9                 for the Epl-Obd-Userspace-Modul
10
11   License:
12
13     Redistribution and use in source and binary forms, with or without
14     modification, are permitted provided that the following conditions
15     are met:
16
17     1. Redistributions of source code must retain the above copyright
18        notice, this list of conditions and the following disclaimer.
19
20     2. Redistributions in binary form must reproduce the above copyright
21        notice, this list of conditions and the following disclaimer in the
22        documentation and/or other materials provided with the distribution.
23
24     3. Neither the name of SYSTEC electronic GmbH nor the names of its
25        contributors may be used to endorse or promote products derived
26        from this software without prior written permission. For written
27        permission, please contact info@systec-electronic.com.
28
29     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33     COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40     POSSIBILITY OF SUCH DAMAGE.
41
42     Severability Clause:
43
44         If a provision of this License is or becomes illegal, invalid or
45         unenforceable in any jurisdiction, that shall not affect:
46         1. the validity or enforceability in that jurisdiction of any other
47            provision of this License; or
48         2. the validity or enforceability in other jurisdictions of that or
49            any other provision of this License.
50
51   -------------------------------------------------------------------------
52
53                 $RCSfile: EplObduCal.c,v $
54
55                 $Author: D.Krueger $
56
57                 $Revision: 1.6 $  $Date: 2008/10/17 15:32:32 $
58
59                 $State: Exp $
60
61                 Build Environment:
62                     GCC V3.4
63
64   -------------------------------------------------------------------------
65
66   Revision History:
67
68   2006/06/19 k.t.:   start of the implementation
69
70 ****************************************************************************/
71 #include "EplInc.h"
72 #include "user/EplObduCal.h"
73 #include "kernel/EplObdk.h"
74
75 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) && (EPL_OBD_USE_KERNEL != FALSE)
76
77 /***************************************************************************/
78 /*                                                                         */
79 /*                                                                         */
80 /*          G L O B A L   D E F I N I T I O N S                            */
81 /*                                                                         */
82 /*                                                                         */
83 /***************************************************************************/
84
85 //---------------------------------------------------------------------------
86 // const defines
87 //---------------------------------------------------------------------------
88
89 //---------------------------------------------------------------------------
90 // local types
91 //---------------------------------------------------------------------------
92
93 //---------------------------------------------------------------------------
94 // modul globale vars
95 //---------------------------------------------------------------------------
96
97 //---------------------------------------------------------------------------
98 // local function prototypes
99 //---------------------------------------------------------------------------
100
101 //=========================================================================//
102 //                                                                         //
103 //          P U B L I C   F U N C T I O N S                                //
104 //                                                                         //
105 //=========================================================================//
106
107 //---------------------------------------------------------------------------
108 //
109 // Function:    EplObduCalWriteEntry()
110 //
111 // Description: Function encapsulate access of function EplObdWriteEntry
112 //
113 // Parameters:  uiIndex_p       =   Index of the OD entry
114 //              uiSubIndex_p    =   Subindex of the OD Entry
115 //              pSrcData_p      =   Pointer to the data to write
116 //              Size_p          =   Size of the data in Byte
117 //
118 // Return:      tEplKernel      =   Errorcode
119 //
120 //
121 // State:
122 //
123 //---------------------------------------------------------------------------
124 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry(unsigned int uiIndex_p,
125                                                     unsigned int uiSubIndex_p,
126                                                     void *pSrcData_p,
127                                                     tEplObdSize Size_p)
128 {
129         tEplKernel Ret;
130
131 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
132         Ret = EplObdWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
133 #else
134         Ret = kEplSuccessful;
135 #endif
136
137         return Ret;
138 }
139
140 //---------------------------------------------------------------------------
141 //
142 // Function:    EplObduCalReadEntry()
143 //
144 // Description: Function encapsulate access of function EplObdReadEntry
145 //
146 // Parameters:  uiIndex_p       = Index oof the OD entry to read
147 //              uiSubIndex_p    = Subindex to read
148 //              pDstData_p      = pointer to the buffer for data
149 //              Offset_p        = offset in data for read access
150 //              pSize_p         = IN: Size of the buffer
151 //                                OUT: number of readed Bytes
152 //
153 // Return:      tEplKernel      =   errorcode
154 //
155 // State:
156 //
157 //---------------------------------------------------------------------------
158 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry(unsigned int uiIndex_p,
159                                                    unsigned int uiSubIndex_p,
160                                                    void *pDstData_p,
161                                                    tEplObdSize * pSize_p)
162 {
163         tEplKernel Ret;
164
165 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
166         Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
167 #else
168         Ret = kEplSuccessful;
169 #endif
170
171         return Ret;
172 }
173
174 //---------------------------------------------------------------------------
175 //
176 // Function:    EplObduCalAccessOdPart()
177 //
178 // Description: Function encapsulate access of function EplObdAccessOdPart
179 //
180 // Parameters:  ObdPart_p       = od-part to reset
181 //              Direction_p     = directory flag for
182 //
183 // Return:      tEplKernel  = errorcode
184 //
185 // State:
186 //
187 //---------------------------------------------------------------------------
188 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart(tEplObdPart ObdPart_p,
189                                                       tEplObdDir Direction_p)
190 {
191         tEplKernel Ret;
192
193 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
194         Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
195 #else
196         Ret = kEplSuccessful;
197 #endif
198
199         return Ret;
200 }
201
202 //---------------------------------------------------------------------------
203 //
204 // Function:    EplObduCalDefineVar()
205 //
206 // Description: Function encapsulate access of function EplObdDefineVar
207 //
208 // Parameters:  pEplVarParam_p = varentry
209 //
210 // Return:      tEplKernel  =   errorcode
211 //
212 // State:
213 //
214 //---------------------------------------------------------------------------
215 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar(tEplVarParam MEM *
216                                                    pVarParam_p)
217 {
218         tEplKernel Ret;
219
220 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
221         Ret = EplObdDefineVar(pVarParam_p);
222 #else
223         Ret = kEplSuccessful;
224 #endif
225
226         return Ret;
227 }
228
229 //---------------------------------------------------------------------------
230 //
231 // Function:    EplObduCalGetObjectDataPtr()
232 //
233 // Description: Function encapsulate access of function EplObdGetObjectDataPtr
234 //
235 // Parameters:  uiIndex_p    =   Index of the entry
236 //              uiSubindex_p =   Subindex of the entry
237 //
238 // Return:      void *    = pointer to object data
239 //
240 // State:
241 //
242 //---------------------------------------------------------------------------
243 EPLDLLEXPORT void *PUBLIC EplObduCalGetObjectDataPtr(unsigned int uiIndex_p,
244                                                      unsigned int uiSubIndex_p)
245 {
246         void *pData;
247
248 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
249         pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
250 #else
251         pData = NULL;
252 #endif
253
254         return pData;
255 }
256
257 //---------------------------------------------------------------------------
258 //
259 // Function:    EplObduCalRegisterUserOd()
260 //
261 // Description: Function encapsulate access of function EplObdRegisterUserOd
262 //
263 // Parameters:  pUserOd_p   = pointer to user OD
264 //
265 // Return:     tEplKernel = errorcode
266 //
267 // State:
268 //
269 //---------------------------------------------------------------------------
270 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
271 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd(tEplObdEntryPtr
272                                                         pUserOd_p)
273 {
274         tEplKernel Ret;
275
276 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
277         Ret = EplObdRegisterUserOd(pUserOd_p);
278 #else
279         Ret = kEplSuccessful;
280 #endif
281
282         return Ret;
283
284 }
285 #endif
286 //---------------------------------------------------------------------------
287 //
288 // Function:    EplObduCalInitVarEntry()
289 //
290 // Description: Function encapsulate access of function EplObdInitVarEntry
291 //
292 // Parameters:  pVarEntry_p = pointer to var entry structure
293 //              bType_p     = object type
294 //              ObdSize_p   = size of object data
295 //
296 // Returns:     none
297 //
298 // State:
299 //
300 //---------------------------------------------------------------------------
301 EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry(tEplObdVarEntry MEM *
302                                                 pVarEntry_p, BYTE bType_p,
303                                                 tEplObdSize ObdSize_p)
304 {
305 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
306         EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
307 #endif
308 }
309
310 //---------------------------------------------------------------------------
311 //
312 // Function:    EplObduCalGetDataSize()
313 //
314 // Description: Function encapsulate access of function EplObdGetDataSize
315 //
316 //              gets the data size of an object
317 //              for string objects it returnes the string length
318 //
319 // Parameters:  uiIndex_p   =   Index
320 //              uiSubIndex_p=   Subindex
321 //
322 // Return:      tEplObdSize
323 //
324 // State:
325 //
326 //---------------------------------------------------------------------------
327 EPLDLLEXPORT tEplObdSize PUBLIC EplObduCalGetDataSize(unsigned int uiIndex_p,
328                                                       unsigned int uiSubIndex_p)
329 {
330         tEplObdSize Size;
331
332 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
333         Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
334 #else
335         Size = 0;
336 #endif
337
338         return Size;
339 }
340
341 //---------------------------------------------------------------------------
342 //
343 // Function:    EplObduCalGetNodeId()
344 //
345 // Description: Function encapsulate access of function EplObdGetNodeId
346 //
347 //
348 // Parameters:
349 //
350 // Return:      unsigned int = Node Id
351 //
352 // State:
353 //
354 //---------------------------------------------------------------------------
355 EPLDLLEXPORT unsigned int PUBLIC EplObduCalGetNodeId()
356 {
357         unsigned int uiNodeId;
358
359 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
360         uiNodeId = EplObdGetNodeId();
361 #else
362         uiNodeId = 0;
363 #endif
364
365         return uiNodeId;
366 }
367
368 //---------------------------------------------------------------------------
369 //
370 // Function:    EplObduCalSetNodeId()
371 //
372 // Description: Function encapsulate access of function EplObdSetNodeId
373 //
374 //
375 // Parameters:  uiNodeId_p  =   Node Id to set
376 //              NodeIdType_p=   Type on which way the Node Id was set
377 //
378 // Return:      tEplKernel = Errorcode
379 //
380 // State:
381 //
382 //---------------------------------------------------------------------------
383 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSetNodeId(unsigned int uiNodeId_p,
384                                                    tEplObdNodeIdType
385                                                    NodeIdType_p)
386 {
387         tEplKernel Ret;
388
389 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
390         Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
391 #else
392         Ret = kEplSuccessful;
393 #endif
394
395         return Ret;
396 }
397
398 //---------------------------------------------------------------------------
399 //
400 // Function:    EplObduCalGetAccessType()
401 //
402 // Description: Function encapsulate access of function EplObdGetAccessType
403 //
404 // Parameters:  uiIndex_p       =   Index of the OD entry
405 //              uiSubIndex_p    =   Subindex of the OD Entry
406 //              pAccessTyp_p    =   pointer to buffer to store accesstype
407 //
408 // Return:      tEplKernel      =   errorcode
409 //
410 //
411 // State:
412 //
413 //---------------------------------------------------------------------------
414 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalGetAccessType(unsigned int uiIndex_p,
415                                                        unsigned int
416                                                        uiSubIndex_p,
417                                                        tEplObdAccess *
418                                                        pAccessTyp_p)
419 {
420         tEplObdAccess AccesType;
421
422 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
423         AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
424 #else
425         AccesType = 0;
426 #endif
427
428         return AccesType;
429
430 }
431
432 //---------------------------------------------------------------------------
433 //
434 // Function:    EplObduCalReadEntryToLe()
435 //
436 // Description: Function encapsulate access of function EplObdReadEntryToLe
437 //
438 // Parameters:  uiIndex_p       = Index of the OD entry to read
439 //              uiSubIndex_p    = Subindex to read
440 //              pDstData_p      = pointer to the buffer for data
441 //              Offset_p        = offset in data for read access
442 //              pSize_p         = IN: Size of the buffer
443 //                                OUT: number of readed Bytes
444 //
445 // Return:      tEplKernel
446 //
447 // State:
448 //
449 //---------------------------------------------------------------------------
450 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe(unsigned int uiIndex_p,
451                                                        unsigned int
452                                                        uiSubIndex_p,
453                                                        void *pDstData_p,
454                                                        tEplObdSize * pSize_p)
455 {
456         tEplKernel Ret;
457
458 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
459         Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
460 #else
461         Ret = kEplSuccessful;
462 #endif
463
464         return Ret;
465 }
466
467 //---------------------------------------------------------------------------
468 //
469 // Function:    EplObduCalWriteEntryFromLe()
470 //
471 // Description: Function encapsulate access of function EplObdWriteEntryFromLe
472 //
473 // Parameters:  uiIndex_p       =   Index of the OD entry
474 //              uiSubIndex_p    =   Subindex of the OD Entry
475 //              pSrcData_p      =   Pointer to the data to write
476 //              Size_p          =   Size of the data in Byte
477 //
478 // Return:      tEplKernel      =   Errorcode
479 //
480 //
481 // State:
482 //
483 //---------------------------------------------------------------------------
484 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe(unsigned int
485                                                           uiIndex_p,
486                                                           unsigned int
487                                                           uiSubIndex_p,
488                                                           void *pSrcData_p,
489                                                           tEplObdSize Size_p)
490 {
491         tEplKernel Ret;
492
493 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
494         Ret =
495             EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
496 #else
497         Ret = kEplSuccessful;
498 #endif
499         return Ret;
500 }
501
502 //---------------------------------------------------------------------------
503 //
504 // Function:    EplObduCalSearchVarEntry()
505 //
506 // Description: gets variable from OD
507 //
508 // Parameters:  uiIndex_p       =   index of the var entry to search
509 //              uiSubindex_p    =   subindex of var entry to search
510 //              ppVarEntry_p    =   pointer to the pointer to the varentry
511 //
512 // Return:      tEplKernel
513 //
514 // State:
515 //
516 //---------------------------------------------------------------------------
517 EPLDLLEXPORT tEplKernel PUBLIC
518 EplObduCalSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p,
519                          unsigned int uiSubindex_p,
520                          tEplObdVarEntry MEM ** ppVarEntry_p)
521 {
522         tEplKernel Ret;
523
524 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
525         Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
526 #else
527         Ret = kEplSuccessful;
528 #endif
529         return Ret;
530 }
531
532 //=========================================================================//
533 //                                                                         //
534 //          P R I V A T E   F U N C T I O N S                              //
535 //                                                                         //
536 //=========================================================================//
537
538 //---------------------------------------------------------------------------
539 //
540 // Function:
541 //
542 // Description:
543 //
544 //
545 //
546 // Parameters:
547 //
548 //
549 // Returns:
550 //
551 //
552 // State:
553 //
554 //---------------------------------------------------------------------------
555
556 #endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
557
558 // EOF