Staging: comedi: Remove comedi_cmd typedef
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / epl / EplObdu.c
CommitLineData
9d7164cf
DK
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 Epl-Obd-Userspace-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: EplObdu.c,v $
53
54 $Author: D.Krueger $
55
56 $Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
57
58 $State: Exp $
59
60 Build Environment:
61 GCC V3.4
62
63 -------------------------------------------------------------------------
64
65 Revision History:
66
67 2006/06/19 k.t.: start of the implementation
68
69****************************************************************************/
70
71#include "EplInc.h"
72#include "user/EplObdu.h"
73#include "user/EplObduCal.h"
74
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/***************************************************************************/
83
84//---------------------------------------------------------------------------
85// const defines
86//---------------------------------------------------------------------------
87
88//---------------------------------------------------------------------------
89// local types
90//---------------------------------------------------------------------------
91
92//---------------------------------------------------------------------------
93// modul globale vars
94//---------------------------------------------------------------------------
95
96//---------------------------------------------------------------------------
97// local function prototypes
98//---------------------------------------------------------------------------
99
9d7164cf
DK
100//=========================================================================//
101// //
102// P U B L I C F U N C T I O N S //
103// //
104//=========================================================================//
105
106//---------------------------------------------------------------------------
107//
108// Function: EplObduWriteEntry()
109//
110// Description: Function writes data to an OBD entry. Strings
111// are stored with added '\0' character.
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//---------------------------------------------------------------------------
833dfbe7
GKH
124EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry(unsigned int uiIndex_p,
125 unsigned int uiSubIndex_p,
126 void *pSrcData_p,
127 tEplObdSize Size_p)
9d7164cf 128{
833dfbe7 129 tEplKernel Ret;
9d7164cf 130
833dfbe7 131 Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
9d7164cf 132
833dfbe7 133 return Ret;
9d7164cf
DK
134}
135
9d7164cf
DK
136//---------------------------------------------------------------------------
137//
138// Function: EplObduReadEntry()
139//
140// Description: The function reads an object entry. The application
141// can always read the data even if attrib kEplObdAccRead
142// is not set. The attrib is only checked up for SDO transfer.
143//
144// Parameters: uiIndex_p = Index oof the OD entry to read
145// uiSubIndex_p = Subindex to read
146// pDstData_p = pointer to the buffer for data
147// Offset_p = offset in data for read access
148// pSize_p = IN: Size of the buffer
149// OUT: number of readed Bytes
150//
151// Return: tEplKernel = errorcode
152//
153// State:
154//
155//---------------------------------------------------------------------------
833dfbe7
GKH
156EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry(unsigned int uiIndex_p,
157 unsigned int uiSubIndex_p,
158 void *pDstData_p,
159 tEplObdSize * pSize_p)
9d7164cf 160{
833dfbe7 161 tEplKernel Ret;
9d7164cf 162
833dfbe7 163 Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
9d7164cf 164
833dfbe7 165 return Ret;
9d7164cf
DK
166}
167
9d7164cf
DK
168//---------------------------------------------------------------------------
169//
170// Function: EplObdAccessOdPart()
171//
172// Description: restores default values of one part of OD
173//
174// Parameters: ObdPart_p = od-part to reset
175// Direction_p = directory flag for
176//
177// Return: tEplKernel = errorcode
178//
179// State:
180//
181//---------------------------------------------------------------------------
833dfbe7
GKH
182EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart(tEplObdPart ObdPart_p,
183 tEplObdDir Direction_p)
9d7164cf 184{
833dfbe7 185 tEplKernel Ret;
9d7164cf 186
833dfbe7 187 Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
9d7164cf 188
833dfbe7 189 return Ret;
9d7164cf
DK
190}
191
192//---------------------------------------------------------------------------
193//
194// Function: EplObduDefineVar()
195//
196// Description: defines a variable in OD
197//
198// Parameters: pEplVarParam_p = varentry
199//
200// Return: tEplKernel = errorcode
201//
202// State:
203//
204//---------------------------------------------------------------------------
833dfbe7 205EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar(tEplVarParam MEM * pVarParam_p)
9d7164cf 206{
833dfbe7 207 tEplKernel Ret;
9d7164cf 208
833dfbe7 209 Ret = EplObduCalDefineVar(pVarParam_p);
9d7164cf 210
833dfbe7 211 return Ret;
9d7164cf
DK
212}
213
214//---------------------------------------------------------------------------
215//
216// Function: EplObduGetObjectDataPtr()
217//
218// Description: It returnes the current data pointer. But if object is an
219// constant object it returnes the default pointer.
220//
221// Parameters: uiIndex_p = Index of the entry
222// uiSubindex_p = Subindex of the entry
223//
224// Return: void * = pointer to object data
225//
226// State:
227//
228//---------------------------------------------------------------------------
833dfbe7
GKH
229EPLDLLEXPORT void *PUBLIC EplObduGetObjectDataPtr(unsigned int uiIndex_p,
230 unsigned int uiSubIndex_p)
9d7164cf 231{
833dfbe7 232 void *pData;
9d7164cf 233
833dfbe7 234 pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
9d7164cf 235
833dfbe7 236 return pData;
9d7164cf
DK
237}
238
239//---------------------------------------------------------------------------
240//
241// Function: EplObduRegisterUserOd()
242//
243// Description: function registers the user OD
244//
245// Parameters: pUserOd_p =pointer to user ODd
246//
247// Return: tEplKernel = errorcode
248//
249// State:
250//
251//---------------------------------------------------------------------------
252#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
833dfbe7 253EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p)
9d7164cf 254{
833dfbe7 255 tEplKernel Ret;
9d7164cf 256
833dfbe7 257 Ret = EplObduCalRegisterUserOd(pUserOd_p);
9d7164cf 258
833dfbe7 259 return Ret;
9d7164cf
DK
260
261}
262#endif
263//---------------------------------------------------------------------------
264//
265// Function: EplObduInitVarEntry()
266//
267// Description: function to initialize VarEntry dependened on object type
268//
269// Parameters: pVarEntry_p = pointer to var entry structure
270// bType_p = object type
271// ObdSize_p = size of object data
272//
273// Returns: none
274//
275// State:
276//
277//---------------------------------------------------------------------------
833dfbe7
GKH
278EPLDLLEXPORT void PUBLIC EplObduInitVarEntry(tEplObdVarEntry MEM * pVarEntry_p,
279 BYTE bType_p,
280 tEplObdSize ObdSize_p)
9d7164cf 281{
833dfbe7 282 EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
9d7164cf
DK
283}
284
285//---------------------------------------------------------------------------
286//
287// Function: EplObduGetDataSize()
288//
289// Description: function to initialize VarEntry dependened on object type
290//
291// gets the data size of an object
292// for string objects it returnes the string length
293//
294// Parameters: uiIndex_p = Index
295// uiSubIndex_p= Subindex
296//
297// Return: tEplObdSize
298//
299// State:
300//
301//---------------------------------------------------------------------------
302EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
833dfbe7 303 unsigned int uiSubIndex_p)
9d7164cf 304{
833dfbe7 305 tEplObdSize Size;
9d7164cf 306
833dfbe7 307 Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
9d7164cf 308
833dfbe7 309 return Size;
9d7164cf
DK
310}
311
312//---------------------------------------------------------------------------
313//
314// Function: EplObduGetNodeId()
315//
316// Description: function returns nodeid from entry 0x1F93
317//
318//
319// Parameters:
320//
321// Return: unsigned int = Node Id
322//
323// State:
324//
325//---------------------------------------------------------------------------
326EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
327{
833dfbe7 328 unsigned int uiNodeId;
9d7164cf 329
833dfbe7 330 uiNodeId = EplObduCalGetNodeId();
9d7164cf 331
833dfbe7 332 return uiNodeId;
9d7164cf
DK
333}
334
335//---------------------------------------------------------------------------
336//
337// Function: EplObduSetNodeId()
338//
339// Description: function sets nodeid in entry 0x1F93
340//
341//
342// Parameters: uiNodeId_p = Node Id to set
343// NodeIdType_p= Type on which way the Node Id was set
344//
345// Return: tEplKernel = Errorcode
346//
347// State:
348//
349//---------------------------------------------------------------------------
350EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
833dfbe7 351 tEplObdNodeIdType NodeIdType_p)
9d7164cf 352{
833dfbe7 353 tEplKernel Ret;
9d7164cf 354
833dfbe7 355 Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
9d7164cf 356
833dfbe7 357 return Ret;
9d7164cf
DK
358}
359
360//---------------------------------------------------------------------------
361//
362// Function: EplObduGetAccessType()
363//
364// Description: Function returns accesstype of the entry
365//
366// Parameters: uiIndex_p = Index of the OD entry
367// uiSubIndex_p = Subindex of the OD Entry
368// pAccessTyp_p = pointer to buffer to store accesstyp
369//
370// Return: tEplKernel = Errorcode
371//
372//
373// State:
374//
375//---------------------------------------------------------------------------
376EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
833dfbe7
GKH
377 unsigned int uiSubIndex_p,
378 tEplObdAccess *
379 pAccessTyp_p)
9d7164cf 380{
833dfbe7 381 tEplObdAccess AccessType;
9d7164cf 382
833dfbe7
GKH
383 AccessType =
384 EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
9d7164cf 385
833dfbe7 386 return AccessType;
9d7164cf
DK
387}
388
389//---------------------------------------------------------------------------
390//
391// Function: EplObdReaduEntryToLe()
392//
393// Description: The function reads an object entry from the byteoder
394// of the system to the little endian byteorder for numeric values.
395// For other types a normal read will be processed. This is usefull for
396// the PDO and SDO module. The application
397// can always read the data even if attrib kEplObdAccRead
398// is not set. The attrib is only checked up for SDO transfer.
399//
400// Parameters: EPL_MCO_DECL_INSTANCE_PTR_
401// uiIndex_p = Index of the OD entry to read
402// uiSubIndex_p = Subindex to read
403// pDstData_p = pointer to the buffer for data
404// Offset_p = offset in data for read access
405// pSize_p = IN: Size of the buffer
406// OUT: number of readed Bytes
407//
408// Return: tEplKernel
409//
410// State:
411//
412//---------------------------------------------------------------------------
833dfbe7
GKH
413EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe(unsigned int uiIndex_p,
414 unsigned int uiSubIndex_p,
415 void *pDstData_p,
416 tEplObdSize * pSize_p)
9d7164cf 417{
833dfbe7 418 tEplKernel Ret;
9d7164cf 419
833dfbe7
GKH
420 Ret =
421 EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p,
422 pSize_p);
9d7164cf 423
833dfbe7 424 return Ret;
9d7164cf
DK
425}
426
427//---------------------------------------------------------------------------
428//
429// Function: EplObduWriteEntryFromLe()
430//
431// Description: Function writes data to an OBD entry from a source with
432// little endian byteorder to the od with system specuific
433// byteorder. Not numeric values will only by copied. Strings
434// are stored with added '\0' character.
435//
436// Parameters: EPL_MCO_DECL_INSTANCE_PTR_
437// uiIndex_p = Index of the OD entry
438// uiSubIndex_p = Subindex of the OD Entry
439// pSrcData_p = Pointer to the data to write
440// Size_p = Size of the data in Byte
441//
442// Return: tEplKernel = Errorcode
443//
444//
445// State:
446//
447//---------------------------------------------------------------------------
833dfbe7
GKH
448EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe(unsigned int uiIndex_p,
449 unsigned int
450 uiSubIndex_p,
451 void *pSrcData_p,
452 tEplObdSize Size_p)
9d7164cf 453{
833dfbe7 454 tEplKernel Ret;
9d7164cf 455
833dfbe7
GKH
456 Ret =
457 EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p,
458 Size_p);
9d7164cf 459
833dfbe7 460 return Ret;
9d7164cf
DK
461}
462
463//---------------------------------------------------------------------------
464//
465// Function: EplObduSearchVarEntry()
466//
467// Description: gets variable from OD
468//
469// Parameters: uiIndex_p = index of the var entry to search
470// uiSubindex_p = subindex of var entry to search
471// ppVarEntry_p = pointer to the pointer to the varentry
472//
473// Return: tEplKernel
474//
475// State:
476//
477//---------------------------------------------------------------------------
833dfbe7
GKH
478EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_
479 unsigned int uiIndex_p,
480 unsigned int uiSubindex_p,
481 tEplObdVarEntry MEM **
482 ppVarEntry_p)
9d7164cf 483{
833dfbe7 484 tEplKernel Ret;
9d7164cf 485
833dfbe7 486 Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
9d7164cf 487
833dfbe7 488 return Ret;
9d7164cf 489}
833dfbe7 490
9d7164cf
DK
491//=========================================================================//
492// //
493// P R I V A T E F U N C T I O N S //
494// //
495//=========================================================================//
496
497//---------------------------------------------------------------------------
498//
499// Function:
500//
501// Description:
502//
503//
504//
505// Parameters:
506//
507//
508// Returns:
509//
510//
511// State:
512//
513//---------------------------------------------------------------------------
514
515#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
516
517// EOF