Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[sfrench/cifs-2.6.git] / 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 tEplKernel EplObduCalWriteEntry(unsigned int uiIndex_p,
125                                 unsigned int uiSubIndex_p,
126                                 void *pSrcData_p, tEplObdSize Size_p)
127 {
128         tEplKernel Ret;
129
130 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
131         Ret = EplObdWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
132 #else
133         Ret = kEplSuccessful;
134 #endif
135
136         return Ret;
137 }
138
139 //---------------------------------------------------------------------------
140 //
141 // Function:    EplObduCalReadEntry()
142 //
143 // Description: Function encapsulate access of function EplObdReadEntry
144 //
145 // Parameters:  uiIndex_p       = Index oof the OD entry to read
146 //              uiSubIndex_p    = Subindex to read
147 //              pDstData_p      = pointer to the buffer for data
148 //              Offset_p        = offset in data for read access
149 //              pSize_p         = IN: Size of the buffer
150 //                                OUT: number of readed Bytes
151 //
152 // Return:      tEplKernel      =   errorcode
153 //
154 // State:
155 //
156 //---------------------------------------------------------------------------
157 tEplKernel EplObduCalReadEntry(unsigned int uiIndex_p,
158                                unsigned int uiSubIndex_p,
159                                void *pDstData_p, tEplObdSize *pSize_p)
160 {
161         tEplKernel Ret;
162
163 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
164         Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
165 #else
166         Ret = kEplSuccessful;
167 #endif
168
169         return Ret;
170 }
171
172 //---------------------------------------------------------------------------
173 //
174 // Function:    EplObduCalAccessOdPart()
175 //
176 // Description: Function encapsulate access of function EplObdAccessOdPart
177 //
178 // Parameters:  ObdPart_p       = od-part to reset
179 //              Direction_p     = directory flag for
180 //
181 // Return:      tEplKernel  = errorcode
182 //
183 // State:
184 //
185 //---------------------------------------------------------------------------
186 tEplKernel EplObduCalAccessOdPart(tEplObdPart ObdPart_p, tEplObdDir Direction_p)
187 {
188         tEplKernel Ret;
189
190 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
191         Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
192 #else
193         Ret = kEplSuccessful;
194 #endif
195
196         return Ret;
197 }
198
199 //---------------------------------------------------------------------------
200 //
201 // Function:    EplObduCalDefineVar()
202 //
203 // Description: Function encapsulate access of function EplObdDefineVar
204 //
205 // Parameters:  pEplVarParam_p = varentry
206 //
207 // Return:      tEplKernel  =   errorcode
208 //
209 // State:
210 //
211 //---------------------------------------------------------------------------
212 tEplKernel EplObduCalDefineVar(tEplVarParam *pVarParam_p)
213 {
214         tEplKernel Ret;
215
216 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
217         Ret = EplObdDefineVar(pVarParam_p);
218 #else
219         Ret = kEplSuccessful;
220 #endif
221
222         return Ret;
223 }
224
225 //---------------------------------------------------------------------------
226 //
227 // Function:    EplObduCalGetObjectDataPtr()
228 //
229 // Description: Function encapsulate access of function EplObdGetObjectDataPtr
230 //
231 // Parameters:  uiIndex_p    =   Index of the entry
232 //              uiSubindex_p =   Subindex of the entry
233 //
234 // Return:      void *    = pointer to object data
235 //
236 // State:
237 //
238 //---------------------------------------------------------------------------
239 void *EplObduCalGetObjectDataPtr(unsigned int uiIndex_p, unsigned int uiSubIndex_p)
240 {
241         void *pData;
242
243 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
244         pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
245 #else
246         pData = NULL;
247 #endif
248
249         return pData;
250 }
251
252 //---------------------------------------------------------------------------
253 //
254 // Function:    EplObduCalRegisterUserOd()
255 //
256 // Description: Function encapsulate access of function EplObdRegisterUserOd
257 //
258 // Parameters:  pUserOd_p   = pointer to user OD
259 //
260 // Return:     tEplKernel = errorcode
261 //
262 // State:
263 //
264 //---------------------------------------------------------------------------
265 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
266 tEplKernel EplObduCalRegisterUserOd(tEplObdEntryPtr pUserOd_p)
267 {
268         tEplKernel Ret;
269
270 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
271         Ret = EplObdRegisterUserOd(pUserOd_p);
272 #else
273         Ret = kEplSuccessful;
274 #endif
275
276         return Ret;
277
278 }
279 #endif
280 //---------------------------------------------------------------------------
281 //
282 // Function:    EplObduCalInitVarEntry()
283 //
284 // Description: Function encapsulate access of function EplObdInitVarEntry
285 //
286 // Parameters:  pVarEntry_p = pointer to var entry structure
287 //              bType_p     = object type
288 //              ObdSize_p   = size of object data
289 //
290 // Returns:     none
291 //
292 // State:
293 //
294 //---------------------------------------------------------------------------
295 void EplObduCalInitVarEntry(tEplObdVarEntry *pVarEntry_p, u8 bType_p,
296                             tEplObdSize ObdSize_p)
297 {
298 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
299         EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
300 #endif
301 }
302
303 //---------------------------------------------------------------------------
304 //
305 // Function:    EplObduCalGetDataSize()
306 //
307 // Description: Function encapsulate access of function EplObdGetDataSize
308 //
309 //              gets the data size of an object
310 //              for string objects it returnes the string length
311 //
312 // Parameters:  uiIndex_p   =   Index
313 //              uiSubIndex_p=   Subindex
314 //
315 // Return:      tEplObdSize
316 //
317 // State:
318 //
319 //---------------------------------------------------------------------------
320 tEplObdSize EplObduCalGetDataSize(unsigned int uiIndex_p,
321                                   unsigned int uiSubIndex_p)
322 {
323         tEplObdSize Size;
324
325 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
326         Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
327 #else
328         Size = 0;
329 #endif
330
331         return Size;
332 }
333
334 //---------------------------------------------------------------------------
335 //
336 // Function:    EplObduCalGetNodeId()
337 //
338 // Description: Function encapsulate access of function EplObdGetNodeId
339 //
340 //
341 // Parameters:
342 //
343 // Return:      unsigned int = Node Id
344 //
345 // State:
346 //
347 //---------------------------------------------------------------------------
348 unsigned int EplObduCalGetNodeId(void)
349 {
350         unsigned int uiNodeId;
351
352 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
353         uiNodeId = EplObdGetNodeId();
354 #else
355         uiNodeId = 0;
356 #endif
357
358         return uiNodeId;
359 }
360
361 //---------------------------------------------------------------------------
362 //
363 // Function:    EplObduCalSetNodeId()
364 //
365 // Description: Function encapsulate access of function EplObdSetNodeId
366 //
367 //
368 // Parameters:  uiNodeId_p  =   Node Id to set
369 //              NodeIdType_p=   Type on which way the Node Id was set
370 //
371 // Return:      tEplKernel = Errorcode
372 //
373 // State:
374 //
375 //---------------------------------------------------------------------------
376 tEplKernel EplObduCalSetNodeId(unsigned int uiNodeId_p,
377                                tEplObdNodeIdType NodeIdType_p)
378 {
379         tEplKernel Ret;
380
381 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
382         Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
383 #else
384         Ret = kEplSuccessful;
385 #endif
386
387         return Ret;
388 }
389
390 //---------------------------------------------------------------------------
391 //
392 // Function:    EplObduCalGetAccessType()
393 //
394 // Description: Function encapsulate access of function EplObdGetAccessType
395 //
396 // Parameters:  uiIndex_p       =   Index of the OD entry
397 //              uiSubIndex_p    =   Subindex of the OD Entry
398 //              pAccessTyp_p    =   pointer to buffer to store accesstype
399 //
400 // Return:      tEplKernel      =   errorcode
401 //
402 //
403 // State:
404 //
405 //---------------------------------------------------------------------------
406 tEplKernel EplObduCalGetAccessType(unsigned int uiIndex_p,
407                                    unsigned int uiSubIndex_p,
408                                    tEplObdAccess *pAccessTyp_p)
409 {
410         tEplObdAccess AccesType;
411
412 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
413         AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
414 #else
415         AccesType = 0;
416 #endif
417
418         return AccesType;
419
420 }
421
422 //---------------------------------------------------------------------------
423 //
424 // Function:    EplObduCalReadEntryToLe()
425 //
426 // Description: Function encapsulate access of function EplObdReadEntryToLe
427 //
428 // Parameters:  uiIndex_p       = Index of the OD entry to read
429 //              uiSubIndex_p    = Subindex to read
430 //              pDstData_p      = pointer to the buffer for data
431 //              Offset_p        = offset in data for read access
432 //              pSize_p         = IN: Size of the buffer
433 //                                OUT: number of readed Bytes
434 //
435 // Return:      tEplKernel
436 //
437 // State:
438 //
439 //---------------------------------------------------------------------------
440 tEplKernel EplObduCalReadEntryToLe(unsigned int uiIndex_p,
441                                    unsigned int uiSubIndex_p,
442                                    void *pDstData_p,
443                                    tEplObdSize *pSize_p)
444 {
445         tEplKernel Ret;
446
447 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
448         Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
449 #else
450         Ret = kEplSuccessful;
451 #endif
452
453         return Ret;
454 }
455
456 //---------------------------------------------------------------------------
457 //
458 // Function:    EplObduCalWriteEntryFromLe()
459 //
460 // Description: Function encapsulate access of function EplObdWriteEntryFromLe
461 //
462 // Parameters:  uiIndex_p       =   Index of the OD entry
463 //              uiSubIndex_p    =   Subindex of the OD Entry
464 //              pSrcData_p      =   Pointer to the data to write
465 //              Size_p          =   Size of the data in Byte
466 //
467 // Return:      tEplKernel      =   Errorcode
468 //
469 //
470 // State:
471 //
472 //---------------------------------------------------------------------------
473 tEplKernel EplObduCalWriteEntryFromLe(unsigned int uiIndex_p,
474                                       unsigned int uiSubIndex_p,
475                                       void *pSrcData_p, tEplObdSize Size_p)
476 {
477         tEplKernel Ret;
478
479 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
480         Ret =
481             EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
482 #else
483         Ret = kEplSuccessful;
484 #endif
485         return Ret;
486 }
487
488 //---------------------------------------------------------------------------
489 //
490 // Function:    EplObduCalSearchVarEntry()
491 //
492 // Description: gets variable from OD
493 //
494 // Parameters:  uiIndex_p       =   index of the var entry to search
495 //              uiSubindex_p    =   subindex of var entry to search
496 //              ppVarEntry_p    =   pointer to the pointer to the varentry
497 //
498 // Return:      tEplKernel
499 //
500 // State:
501 //
502 //---------------------------------------------------------------------------
503 tEplKernel EplObduCalSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p,
504                                     unsigned int uiSubindex_p,
505                                     tEplObdVarEntry **ppVarEntry_p)
506 {
507         tEplKernel Ret;
508
509 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
510         Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
511 #else
512         Ret = kEplSuccessful;
513 #endif
514         return Ret;
515 }
516
517 //=========================================================================//
518 //                                                                         //
519 //          P R I V A T E   F U N C T I O N S                              //
520 //                                                                         //
521 //=========================================================================//
522
523 //---------------------------------------------------------------------------
524 //
525 // Function:
526 //
527 // Description:
528 //
529 //
530 //
531 // Parameters:
532 //
533 //
534 // Returns:
535 //
536 //
537 // State:
538 //
539 //---------------------------------------------------------------------------
540
541 #endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
542
543 // EOF