Staging: vme: change to VME_BUS
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / epl / EplObdu.c
blob5f1d9986254ec124f9565f409b60b24d4057996c
1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
6 Project: openPOWERLINK
8 Description: source file for Epl-Obd-Userspace-module
10 License:
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
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.
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.
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.
41 Severability Clause:
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.
50 -------------------------------------------------------------------------
52 $RCSfile: EplObdu.c,v $
54 $Author: D.Krueger $
56 $Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
58 $State: Exp $
60 Build Environment:
61 GCC V3.4
63 -------------------------------------------------------------------------
65 Revision History:
67 2006/06/19 k.t.: start of the implementation
69 ****************************************************************************/
71 #include "EplInc.h"
72 #include "user/EplObdu.h"
73 #include "user/EplObduCal.h"
75 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
76 /***************************************************************************/
77 /* */
78 /* */
79 /* G L O B A L D E F I N I T I O N S */
80 /* */
81 /* */
82 /***************************************************************************/
84 //---------------------------------------------------------------------------
85 // const defines
86 //---------------------------------------------------------------------------
88 //---------------------------------------------------------------------------
89 // local types
90 //---------------------------------------------------------------------------
92 //---------------------------------------------------------------------------
93 // modul globale vars
94 //---------------------------------------------------------------------------
96 //---------------------------------------------------------------------------
97 // local function prototypes
98 //---------------------------------------------------------------------------
100 //=========================================================================//
101 // //
102 // P U B L I C F U N C T I O N S //
103 // //
104 //=========================================================================//
106 //---------------------------------------------------------------------------
108 // Function: EplObduWriteEntry()
110 // Description: Function writes data to an OBD entry. Strings
111 // are stored with added '\0' character.
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
118 // Return: tEplKernel = Errorcode
121 // State:
123 //---------------------------------------------------------------------------
124 tEplKernel EplObduWriteEntry(unsigned int uiIndex_p,
125 unsigned int uiSubIndex_p,
126 void *pSrcData_p, tEplObdSize Size_p)
128 tEplKernel Ret;
130 Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
132 return Ret;
135 //---------------------------------------------------------------------------
137 // Function: EplObduReadEntry()
139 // Description: The function reads an object entry. The application
140 // can always read the data even if attrib kEplObdAccRead
141 // is not set. The attrib is only checked up for SDO transfer.
143 // Parameters: uiIndex_p = Index oof the OD entry to read
144 // uiSubIndex_p = Subindex to read
145 // pDstData_p = pointer to the buffer for data
146 // Offset_p = offset in data for read access
147 // pSize_p = IN: Size of the buffer
148 // OUT: number of readed Bytes
150 // Return: tEplKernel = errorcode
152 // State:
154 //---------------------------------------------------------------------------
155 tEplKernel EplObduReadEntry(unsigned int uiIndex_p,
156 unsigned int uiSubIndex_p,
157 void *pDstData_p,
158 tEplObdSize *pSize_p)
160 tEplKernel Ret;
162 Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
164 return Ret;
167 //---------------------------------------------------------------------------
169 // Function: EplObdAccessOdPart()
171 // Description: restores default values of one part of OD
173 // Parameters: ObdPart_p = od-part to reset
174 // Direction_p = directory flag for
176 // Return: tEplKernel = errorcode
178 // State:
180 //---------------------------------------------------------------------------
181 tEplKernel EplObduAccessOdPart(tEplObdPart ObdPart_p, tEplObdDir Direction_p)
183 tEplKernel Ret;
185 Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
187 return Ret;
190 //---------------------------------------------------------------------------
192 // Function: EplObduDefineVar()
194 // Description: defines a variable in OD
196 // Parameters: pEplVarParam_p = varentry
198 // Return: tEplKernel = errorcode
200 // State:
202 //---------------------------------------------------------------------------
203 tEplKernel EplObduDefineVar(tEplVarParam *pVarParam_p)
205 tEplKernel Ret;
207 Ret = EplObduCalDefineVar(pVarParam_p);
209 return Ret;
212 //---------------------------------------------------------------------------
214 // Function: EplObduGetObjectDataPtr()
216 // Description: It returnes the current data pointer. But if object is an
217 // constant object it returnes the default pointer.
219 // Parameters: uiIndex_p = Index of the entry
220 // uiSubindex_p = Subindex of the entry
222 // Return: void * = pointer to object data
224 // State:
226 //---------------------------------------------------------------------------
227 void *EplObduGetObjectDataPtr(unsigned int uiIndex_p, unsigned int uiSubIndex_p)
229 void *pData;
231 pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
233 return pData;
236 //---------------------------------------------------------------------------
238 // Function: EplObduRegisterUserOd()
240 // Description: function registers the user OD
242 // Parameters: pUserOd_p =pointer to user ODd
244 // Return: tEplKernel = errorcode
246 // State:
248 //---------------------------------------------------------------------------
249 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
250 tEplKernel EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p)
252 tEplKernel Ret;
254 Ret = EplObduCalRegisterUserOd(pUserOd_p);
256 return Ret;
259 #endif
260 //---------------------------------------------------------------------------
262 // Function: EplObduInitVarEntry()
264 // Description: function to initialize VarEntry dependened on object type
266 // Parameters: pVarEntry_p = pointer to var entry structure
267 // bType_p = object type
268 // ObdSize_p = size of object data
270 // Returns: none
272 // State:
274 //---------------------------------------------------------------------------
275 void EplObduInitVarEntry(tEplObdVarEntry *pVarEntry_p, u8 bType_p, tEplObdSize ObdSize_p)
277 EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
280 //---------------------------------------------------------------------------
282 // Function: EplObduGetDataSize()
284 // Description: function to initialize VarEntry dependened on object type
286 // gets the data size of an object
287 // for string objects it returnes the string length
289 // Parameters: uiIndex_p = Index
290 // uiSubIndex_p= Subindex
292 // Return: tEplObdSize
294 // State:
296 //---------------------------------------------------------------------------
297 tEplObdSize EplObduGetDataSize(unsigned int uiIndex_p, unsigned int uiSubIndex_p)
299 tEplObdSize Size;
301 Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
303 return Size;
306 //---------------------------------------------------------------------------
308 // Function: EplObduGetNodeId()
310 // Description: function returns nodeid from entry 0x1F93
313 // Parameters:
315 // Return: unsigned int = Node Id
317 // State:
319 //---------------------------------------------------------------------------
320 unsigned int EplObduGetNodeId(void)
322 unsigned int uiNodeId;
324 uiNodeId = EplObduCalGetNodeId();
326 return uiNodeId;
329 //---------------------------------------------------------------------------
331 // Function: EplObduSetNodeId()
333 // Description: function sets nodeid in entry 0x1F93
336 // Parameters: uiNodeId_p = Node Id to set
337 // NodeIdType_p= Type on which way the Node Id was set
339 // Return: tEplKernel = Errorcode
341 // State:
343 //---------------------------------------------------------------------------
344 tEplKernel EplObduSetNodeId(unsigned int uiNodeId_p, tEplObdNodeIdType NodeIdType_p)
346 tEplKernel Ret;
348 Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
350 return Ret;
353 //---------------------------------------------------------------------------
355 // Function: EplObduGetAccessType()
357 // Description: Function returns accesstype of the entry
359 // Parameters: uiIndex_p = Index of the OD entry
360 // uiSubIndex_p = Subindex of the OD Entry
361 // pAccessTyp_p = pointer to buffer to store accesstyp
363 // Return: tEplKernel = Errorcode
366 // State:
368 //---------------------------------------------------------------------------
369 tEplKernel EplObduGetAccessType(unsigned int uiIndex_p,
370 unsigned int uiSubIndex_p,
371 tEplObdAccess *pAccessTyp_p)
373 tEplObdAccess AccessType;
375 AccessType =
376 EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
378 return AccessType;
381 //---------------------------------------------------------------------------
383 // Function: EplObdReaduEntryToLe()
385 // Description: The function reads an object entry from the byteoder
386 // of the system to the little endian byteorder for numeric values.
387 // For other types a normal read will be processed. This is usefull for
388 // the PDO and SDO module. The application
389 // can always read the data even if attrib kEplObdAccRead
390 // is not set. The attrib is only checked up for SDO transfer.
392 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
393 // uiIndex_p = Index of the OD entry to read
394 // uiSubIndex_p = Subindex to read
395 // pDstData_p = pointer to the buffer for data
396 // Offset_p = offset in data for read access
397 // pSize_p = IN: Size of the buffer
398 // OUT: number of readed Bytes
400 // Return: tEplKernel
402 // State:
404 //---------------------------------------------------------------------------
405 tEplKernel EplObduReadEntryToLe(unsigned int uiIndex_p,
406 unsigned int uiSubIndex_p,
407 void *pDstData_p,
408 tEplObdSize *pSize_p)
410 tEplKernel Ret;
412 Ret =
413 EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p,
414 pSize_p);
416 return Ret;
419 //---------------------------------------------------------------------------
421 // Function: EplObduWriteEntryFromLe()
423 // Description: Function writes data to an OBD entry from a source with
424 // little endian byteorder to the od with system specuific
425 // byteorder. Not numeric values will only by copied. Strings
426 // are stored with added '\0' character.
428 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
429 // uiIndex_p = Index of the OD entry
430 // uiSubIndex_p = Subindex of the OD Entry
431 // pSrcData_p = Pointer to the data to write
432 // Size_p = Size of the data in Byte
434 // Return: tEplKernel = Errorcode
437 // State:
439 //---------------------------------------------------------------------------
440 tEplKernel EplObduWriteEntryFromLe(unsigned int uiIndex_p,
441 unsigned int uiSubIndex_p,
442 void *pSrcData_p,
443 tEplObdSize Size_p)
445 tEplKernel Ret;
447 Ret =
448 EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p,
449 Size_p);
451 return Ret;
454 //---------------------------------------------------------------------------
456 // Function: EplObduSearchVarEntry()
458 // Description: gets variable from OD
460 // Parameters: uiIndex_p = index of the var entry to search
461 // uiSubindex_p = subindex of var entry to search
462 // ppVarEntry_p = pointer to the pointer to the varentry
464 // Return: tEplKernel
466 // State:
468 //---------------------------------------------------------------------------
469 tEplKernel EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p,
470 unsigned int uiSubindex_p,
471 tEplObdVarEntry **ppVarEntry_p)
473 tEplKernel Ret;
475 Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
477 return Ret;
480 //=========================================================================//
481 // //
482 // P R I V A T E F U N C T I O N S //
483 // //
484 //=========================================================================//
486 //---------------------------------------------------------------------------
488 // Function:
490 // Description:
494 // Parameters:
497 // Returns:
500 // State:
502 //---------------------------------------------------------------------------
504 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
506 // EOF