diff options
author | Daniel Krueger <daniel.krueger@systec-electronic.com> | 2008-12-19 14:41:57 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 16:52:36 -0500 |
commit | 9d7164cfdb611c2f864d535ae5794f23db3d84f7 (patch) | |
tree | 046847f7d6432f1f3dc8236f62492503f4c9ebdc /drivers/staging/epl/EplObdu.c | |
parent | 37bcd24b845abbfd85c838ee9ce07c2b254d3a05 (diff) |
Staging: add epl stack
This is the openPOWERLINK network stack from systec electronic.
It's a bit messed up as there is a driver mixed into the
middle of it, lots of work needs to be done to unwind the
different portions to make it sane.
Cc: Daniel Krueger <daniel.krueger@systec-electronic.com>
Cc: Ronald Sieber <Ronald.Sieber@systec-electronic.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/epl/EplObdu.c')
-rw-r--r-- | drivers/staging/epl/EplObdu.c | 512 |
1 files changed, 512 insertions, 0 deletions
diff --git a/drivers/staging/epl/EplObdu.c b/drivers/staging/epl/EplObdu.c new file mode 100644 index 00000000000..46370cb1f82 --- /dev/null +++ b/drivers/staging/epl/EplObdu.c | |||
@@ -0,0 +1,512 @@ | |||
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 | |||
100 | |||
101 | |||
102 | //=========================================================================// | ||
103 | // // | ||
104 | // P U B L I C F U N C T I O N S // | ||
105 | // // | ||
106 | //=========================================================================// | ||
107 | |||
108 | //--------------------------------------------------------------------------- | ||
109 | // | ||
110 | // Function: EplObduWriteEntry() | ||
111 | // | ||
112 | // Description: Function writes data to an OBD entry. Strings | ||
113 | // are stored with added '\0' character. | ||
114 | // | ||
115 | // Parameters: uiIndex_p = Index of the OD entry | ||
116 | // uiSubIndex_p = Subindex of the OD Entry | ||
117 | // pSrcData_p = Pointer to the data to write | ||
118 | // Size_p = Size of the data in Byte | ||
119 | // | ||
120 | // Return: tEplKernel = Errorcode | ||
121 | // | ||
122 | // | ||
123 | // State: | ||
124 | // | ||
125 | //--------------------------------------------------------------------------- | ||
126 | EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry (unsigned int uiIndex_p, | ||
127 | unsigned int uiSubIndex_p, | ||
128 | void * pSrcData_p, | ||
129 | tEplObdSize Size_p) | ||
130 | { | ||
131 | tEplKernel Ret; | ||
132 | |||
133 | Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p); | ||
134 | |||
135 | return Ret; | ||
136 | } | ||
137 | |||
138 | |||
139 | //--------------------------------------------------------------------------- | ||
140 | // | ||
141 | // Function: EplObduReadEntry() | ||
142 | // | ||
143 | // Description: The function reads an object entry. The application | ||
144 | // can always read the data even if attrib kEplObdAccRead | ||
145 | // is not set. The attrib is only checked up for SDO transfer. | ||
146 | // | ||
147 | // Parameters: uiIndex_p = Index oof the OD entry to read | ||
148 | // uiSubIndex_p = Subindex to read | ||
149 | // pDstData_p = pointer to the buffer for data | ||
150 | // Offset_p = offset in data for read access | ||
151 | // pSize_p = IN: Size of the buffer | ||
152 | // OUT: number of readed Bytes | ||
153 | // | ||
154 | // Return: tEplKernel = errorcode | ||
155 | // | ||
156 | // State: | ||
157 | // | ||
158 | //--------------------------------------------------------------------------- | ||
159 | EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry (unsigned int uiIndex_p, | ||
160 | unsigned int uiSubIndex_p, | ||
161 | void * pDstData_p, | ||
162 | tEplObdSize* pSize_p) | ||
163 | { | ||
164 | tEplKernel Ret; | ||
165 | |||
166 | Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p); | ||
167 | |||
168 | return Ret; | ||
169 | } | ||
170 | |||
171 | |||
172 | //--------------------------------------------------------------------------- | ||
173 | // | ||
174 | // Function: EplObdAccessOdPart() | ||
175 | // | ||
176 | // Description: restores default values of one part of OD | ||
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 | EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart (tEplObdPart ObdPart_p, | ||
187 | tEplObdDir Direction_p) | ||
188 | { | ||
189 | tEplKernel Ret; | ||
190 | |||
191 | Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p); | ||
192 | |||
193 | return Ret; | ||
194 | } | ||
195 | |||
196 | //--------------------------------------------------------------------------- | ||
197 | // | ||
198 | // Function: EplObduDefineVar() | ||
199 | // | ||
200 | // Description: defines a variable in OD | ||
201 | // | ||
202 | // Parameters: pEplVarParam_p = varentry | ||
203 | // | ||
204 | // Return: tEplKernel = errorcode | ||
205 | // | ||
206 | // State: | ||
207 | // | ||
208 | //--------------------------------------------------------------------------- | ||
209 | EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar (tEplVarParam MEM* pVarParam_p) | ||
210 | { | ||
211 | tEplKernel Ret; | ||
212 | |||
213 | Ret = EplObduCalDefineVar(pVarParam_p); | ||
214 | |||
215 | return Ret; | ||
216 | } | ||
217 | |||
218 | //--------------------------------------------------------------------------- | ||
219 | // | ||
220 | // Function: EplObduGetObjectDataPtr() | ||
221 | // | ||
222 | // Description: It returnes the current data pointer. But if object is an | ||
223 | // constant object it returnes the default pointer. | ||
224 | // | ||
225 | // Parameters: uiIndex_p = Index of the entry | ||
226 | // uiSubindex_p = Subindex of the entry | ||
227 | // | ||
228 | // Return: void * = pointer to object data | ||
229 | // | ||
230 | // State: | ||
231 | // | ||
232 | //--------------------------------------------------------------------------- | ||
233 | EPLDLLEXPORT void* PUBLIC EplObduGetObjectDataPtr (unsigned int uiIndex_p, | ||
234 | unsigned int uiSubIndex_p) | ||
235 | { | ||
236 | void* pData; | ||
237 | |||
238 | pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p); | ||
239 | |||
240 | return pData; | ||
241 | } | ||
242 | |||
243 | //--------------------------------------------------------------------------- | ||
244 | // | ||
245 | // Function: EplObduRegisterUserOd() | ||
246 | // | ||
247 | // Description: function registers the user OD | ||
248 | // | ||
249 | // Parameters: pUserOd_p =pointer to user ODd | ||
250 | // | ||
251 | // Return: tEplKernel = errorcode | ||
252 | // | ||
253 | // State: | ||
254 | // | ||
255 | //--------------------------------------------------------------------------- | ||
256 | #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE)) | ||
257 | EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd (tEplObdEntryPtr pUserOd_p) | ||
258 | { | ||
259 | tEplKernel Ret; | ||
260 | |||
261 | Ret = EplObduCalRegisterUserOd(pUserOd_p); | ||
262 | |||
263 | return Ret; | ||
264 | |||
265 | } | ||
266 | #endif | ||
267 | //--------------------------------------------------------------------------- | ||
268 | // | ||
269 | // Function: EplObduInitVarEntry() | ||
270 | // | ||
271 | // Description: function to initialize VarEntry dependened on object type | ||
272 | // | ||
273 | // Parameters: pVarEntry_p = pointer to var entry structure | ||
274 | // bType_p = object type | ||
275 | // ObdSize_p = size of object data | ||
276 | // | ||
277 | // Returns: none | ||
278 | // | ||
279 | // State: | ||
280 | // | ||
281 | //--------------------------------------------------------------------------- | ||
282 | EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p, | ||
283 | BYTE bType_p, tEplObdSize ObdSize_p) | ||
284 | { | ||
285 | EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p); | ||
286 | } | ||
287 | |||
288 | //--------------------------------------------------------------------------- | ||
289 | // | ||
290 | // Function: EplObduGetDataSize() | ||
291 | // | ||
292 | // Description: function to initialize VarEntry dependened on object type | ||
293 | // | ||
294 | // gets the data size of an object | ||
295 | // for string objects it returnes the string length | ||
296 | // | ||
297 | // Parameters: uiIndex_p = Index | ||
298 | // uiSubIndex_p= Subindex | ||
299 | // | ||
300 | // Return: tEplObdSize | ||
301 | // | ||
302 | // State: | ||
303 | // | ||
304 | //--------------------------------------------------------------------------- | ||
305 | EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p, | ||
306 | unsigned int uiSubIndex_p) | ||
307 | { | ||
308 | tEplObdSize Size; | ||
309 | |||
310 | Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p); | ||
311 | |||
312 | return Size; | ||
313 | } | ||
314 | |||
315 | //--------------------------------------------------------------------------- | ||
316 | // | ||
317 | // Function: EplObduGetNodeId() | ||
318 | // | ||
319 | // Description: function returns nodeid from entry 0x1F93 | ||
320 | // | ||
321 | // | ||
322 | // Parameters: | ||
323 | // | ||
324 | // Return: unsigned int = Node Id | ||
325 | // | ||
326 | // State: | ||
327 | // | ||
328 | //--------------------------------------------------------------------------- | ||
329 | EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId() | ||
330 | { | ||
331 | unsigned int uiNodeId; | ||
332 | |||
333 | uiNodeId = EplObduCalGetNodeId(); | ||
334 | |||
335 | return uiNodeId; | ||
336 | } | ||
337 | |||
338 | //--------------------------------------------------------------------------- | ||
339 | // | ||
340 | // Function: EplObduSetNodeId() | ||
341 | // | ||
342 | // Description: function sets nodeid in entry 0x1F93 | ||
343 | // | ||
344 | // | ||
345 | // Parameters: uiNodeId_p = Node Id to set | ||
346 | // NodeIdType_p= Type on which way the Node Id was set | ||
347 | // | ||
348 | // Return: tEplKernel = Errorcode | ||
349 | // | ||
350 | // State: | ||
351 | // | ||
352 | //--------------------------------------------------------------------------- | ||
353 | EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p, | ||
354 | tEplObdNodeIdType NodeIdType_p) | ||
355 | { | ||
356 | tEplKernel Ret; | ||
357 | |||
358 | Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p); | ||
359 | |||
360 | return Ret; | ||
361 | } | ||
362 | |||
363 | //--------------------------------------------------------------------------- | ||
364 | // | ||
365 | // Function: EplObduGetAccessType() | ||
366 | // | ||
367 | // Description: Function returns accesstype of the entry | ||
368 | // | ||
369 | // Parameters: uiIndex_p = Index of the OD entry | ||
370 | // uiSubIndex_p = Subindex of the OD Entry | ||
371 | // pAccessTyp_p = pointer to buffer to store accesstyp | ||
372 | // | ||
373 | // Return: tEplKernel = Errorcode | ||
374 | // | ||
375 | // | ||
376 | // State: | ||
377 | // | ||
378 | //--------------------------------------------------------------------------- | ||
379 | EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p, | ||
380 | unsigned int uiSubIndex_p, | ||
381 | tEplObdAccess* pAccessTyp_p) | ||
382 | { | ||
383 | tEplObdAccess AccessType; | ||
384 | |||
385 | AccessType = EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p); | ||
386 | |||
387 | return AccessType; | ||
388 | } | ||
389 | |||
390 | //--------------------------------------------------------------------------- | ||
391 | // | ||
392 | // Function: EplObdReaduEntryToLe() | ||
393 | // | ||
394 | // Description: The function reads an object entry from the byteoder | ||
395 | // of the system to the little endian byteorder for numeric values. | ||
396 | // For other types a normal read will be processed. This is usefull for | ||
397 | // the PDO and SDO module. The application | ||
398 | // can always read the data even if attrib kEplObdAccRead | ||
399 | // is not set. The attrib is only checked up for SDO transfer. | ||
400 | // | ||
401 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ | ||
402 | // uiIndex_p = Index of the OD entry to read | ||
403 | // uiSubIndex_p = Subindex to read | ||
404 | // pDstData_p = pointer to the buffer for data | ||
405 | // Offset_p = offset in data for read access | ||
406 | // pSize_p = IN: Size of the buffer | ||
407 | // OUT: number of readed Bytes | ||
408 | // | ||
409 | // Return: tEplKernel | ||
410 | // | ||
411 | // State: | ||
412 | // | ||
413 | //--------------------------------------------------------------------------- | ||
414 | EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe (unsigned int uiIndex_p, | ||
415 | unsigned int uiSubIndex_p, | ||
416 | void * pDstData_p, | ||
417 | tEplObdSize * pSize_p) | ||
418 | { | ||
419 | tEplKernel Ret; | ||
420 | |||
421 | Ret = EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p); | ||
422 | |||
423 | return Ret; | ||
424 | } | ||
425 | |||
426 | //--------------------------------------------------------------------------- | ||
427 | // | ||
428 | // Function: EplObduWriteEntryFromLe() | ||
429 | // | ||
430 | // Description: Function writes data to an OBD entry from a source with | ||
431 | // little endian byteorder to the od with system specuific | ||
432 | // byteorder. Not numeric values will only by copied. Strings | ||
433 | // are stored with added '\0' character. | ||
434 | // | ||
435 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ | ||
436 | // uiIndex_p = Index of the OD entry | ||
437 | // uiSubIndex_p = Subindex of the OD Entry | ||
438 | // pSrcData_p = Pointer to the data to write | ||
439 | // Size_p = Size of the data in Byte | ||
440 | // | ||
441 | // Return: tEplKernel = Errorcode | ||
442 | // | ||
443 | // | ||
444 | // State: | ||
445 | // | ||
446 | //--------------------------------------------------------------------------- | ||
447 | EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe (unsigned int uiIndex_p, | ||
448 | unsigned int uiSubIndex_p, | ||
449 | void * pSrcData_p, | ||
450 | tEplObdSize Size_p) | ||
451 | { | ||
452 | tEplKernel Ret; | ||
453 | |||
454 | Ret = EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p); | ||
455 | |||
456 | return Ret; | ||
457 | } | ||
458 | |||
459 | //--------------------------------------------------------------------------- | ||
460 | // | ||
461 | // Function: EplObduSearchVarEntry() | ||
462 | // | ||
463 | // Description: gets variable from OD | ||
464 | // | ||
465 | // Parameters: uiIndex_p = index of the var entry to search | ||
466 | // uiSubindex_p = subindex of var entry to search | ||
467 | // ppVarEntry_p = pointer to the pointer to the varentry | ||
468 | // | ||
469 | // Return: tEplKernel | ||
470 | // | ||
471 | // State: | ||
472 | // | ||
473 | //--------------------------------------------------------------------------- | ||
474 | EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_ | ||
475 | unsigned int uiIndex_p, | ||
476 | unsigned int uiSubindex_p, | ||
477 | tEplObdVarEntry MEM** ppVarEntry_p) | ||
478 | { | ||
479 | tEplKernel Ret; | ||
480 | |||
481 | Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p); | ||
482 | |||
483 | return Ret; | ||
484 | } | ||
485 | //=========================================================================// | ||
486 | // // | ||
487 | // P R I V A T E F U N C T I O N S // | ||
488 | // // | ||
489 | //=========================================================================// | ||
490 | |||
491 | //--------------------------------------------------------------------------- | ||
492 | // | ||
493 | // Function: | ||
494 | // | ||
495 | // Description: | ||
496 | // | ||
497 | // | ||
498 | // | ||
499 | // Parameters: | ||
500 | // | ||
501 | // | ||
502 | // Returns: | ||
503 | // | ||
504 | // | ||
505 | // State: | ||
506 | // | ||
507 | //--------------------------------------------------------------------------- | ||
508 | |||
509 | #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) | ||
510 | |||
511 | // EOF | ||
512 | |||