Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[linux-2.6] / drivers / staging / epl / EplSdo.h
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:  include file for api function of the sdo 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: EplSdo.h,v $
53
54                 $Author: D.Krueger $
55
56                 $Revision: 1.6 $  $Date: 2008/04/17 21:36:32 $
57
58                 $State: Exp $
59
60                 Build Environment:
61                     GCC V3.4
62
63   -------------------------------------------------------------------------
64
65   Revision History:
66
67  2006/06/26 k.t.:   start of the implementation
68
69 ****************************************************************************/
70
71 #include "EplInc.h"
72 #include "EplFrame.h"
73 #include "EplSdoAc.h"
74
75 #ifndef _EPLSDO_H_
76 #define _EPLSDO_H_
77
78 //---------------------------------------------------------------------------
79 // const defines
80 //---------------------------------------------------------------------------
81 // global defines
82 #ifndef EPL_SDO_MAX_PAYLOAD
83 #define EPL_SDO_MAX_PAYLOAD     256
84 #endif
85
86 // handle between Protocol Abstraction Layer and asynchronous SDO Sequence Layer
87 #define EPL_SDO_UDP_HANDLE      0x8000
88 #define EPL_SDO_ASND_HANDLE     0x4000
89 #define EPL_SDO_ASY_HANDLE_MASK 0xC000
90 #define EPL_SDO_ASY_INVALID_HDL 0x3FFF
91
92 // handle between  SDO Sequence Layer and sdo command layer
93 #define EPL_SDO_ASY_HANDLE      0x8000
94 #define EPL_SDO_PDO_HANDLE      0x4000
95 #define EPL_SDO_SEQ_HANDLE_MASK 0xC000
96 #define EPL_SDO_SEQ_INVALID_HDL 0x3FFF
97
98 #define EPL_ASND_HEADER_SIZE        4
99 //#define EPL_SEQ_HEADER_SIZE         4
100 #define EPL_ETHERNET_HEADER_SIZE    14
101
102 #define EPL_SEQ_NUM_MASK            0xFC
103
104 // size for send buffer and history
105 #define EPL_MAX_SDO_FRAME_SIZE      EPL_C_IP_MIN_MTU
106 // size for receive frame
107 // -> needed because SND-Kit sends up to 1518 Byte
108 //    without Sdo-Command: Maximum Segment Size
109 #define EPL_MAX_SDO_REC_FRAME_SIZE  EPL_C_IP_MAX_MTU
110
111 //---------------------------------------------------------------------------
112 // typedef
113 //---------------------------------------------------------------------------
114 // handle between Protocol Abstraction Layer and asynchronuus SDO Sequence Layer
115 typedef unsigned int tEplSdoConHdl;
116
117 // callback function pointer for Protocol Abstraction Layer to call
118 // asynchronuus SDO Sequence Layer
119 typedef tEplKernel(PUBLIC * tEplSequLayerReceiveCb) (tEplSdoConHdl ConHdl_p,
120                                                      tEplAsySdoSeq *
121                                                      pSdoSeqData_p,
122                                                      unsigned int uiDataSize_p);
123
124 // handle between asynchronuus SDO Sequence Layer and SDO Command layer
125 typedef unsigned int tEplSdoSeqConHdl;
126
127 // callback function pointer for asynchronuus SDO Sequence Layer to call
128 // SDO Command layer for received data
129 typedef tEplKernel(PUBLIC *
130                    tEplSdoComReceiveCb) (tEplSdoSeqConHdl SdoSeqConHdl_p,
131                                          tEplAsySdoCom * pAsySdoCom_p,
132                                          unsigned int uiDataSize_p);
133
134 // status of connection
135 typedef enum {
136         kAsySdoConStateConnected = 0x00,
137         kAsySdoConStateInitError = 0x01,
138         kAsySdoConStateConClosed = 0x02,
139         kAsySdoConStateAckReceived = 0x03,
140         kAsySdoConStateFrameSended = 0x04,
141         kAsySdoConStateTimeout = 0x05
142 } tEplAsySdoConState;
143
144 // callback function pointer for asynchronuus SDO Sequence Layer to call
145 // SDO Command layer for connection status
146 typedef tEplKernel(PUBLIC * tEplSdoComConCb) (tEplSdoSeqConHdl SdoSeqConHdl_p,
147                                               tEplAsySdoConState
148                                               AsySdoConState_p);
149
150 // handle between  SDO Command layer and application
151 typedef unsigned int tEplSdoComConHdl;
152
153 // status of connection
154 typedef enum {
155         kEplSdoComTransferNotActive = 0x00,
156         kEplSdoComTransferRunning = 0x01,
157         kEplSdoComTransferTxAborted = 0x02,
158         kEplSdoComTransferRxAborted = 0x03,
159         kEplSdoComTransferFinished = 0x04,
160         kEplSdoComTransferLowerLayerAbort = 0x05
161 } tEplSdoComConState;
162
163 // SDO Services and Command-Ids from DS 1.0.0 p.152
164 typedef enum {
165         kEplSdoServiceNIL = 0x00,
166         kEplSdoServiceWriteByIndex = 0x01,
167         kEplSdoServiceReadByIndex = 0x02
168             //--------------------------------
169             // the following services are optional and
170             // not supported now
171 /*
172     kEplSdoServiceWriteAllByIndex   = 0x03,
173     kEplSdoServiceReadAllByIndex    = 0x04,
174     kEplSdoServiceWriteByName       = 0x05,
175     kEplSdoServiceReadByName        = 0x06,
176
177     kEplSdoServiceFileWrite         = 0x20,
178     kEplSdoServiceFileRead          = 0x21,
179
180     kEplSdoServiceWriteMultiByIndex = 0x31,
181     kEplSdoServiceReadMultiByIndex  = 0x32,
182
183     kEplSdoServiceMaxSegSize        = 0x70
184
185     // 0x80 - 0xFF manufacturer specific
186
187  */
188 } tEplSdoServiceType;
189
190 // describes if read or write access
191 typedef enum {
192         kEplSdoAccessTypeRead = 0x00,
193         kEplSdoAccessTypeWrite = 0x01
194 } tEplSdoAccessType;
195
196 typedef enum {
197         kEplSdoTypeAuto = 0x00,
198         kEplSdoTypeUdp = 0x01,
199         kEplSdoTypeAsnd = 0x02,
200         kEplSdoTypePdo = 0x03
201 } tEplSdoType;
202
203 typedef enum {
204         kEplSdoTransAuto = 0x00,
205         kEplSdoTransExpedited = 0x01,
206         kEplSdoTransSegmented = 0x02
207 } tEplSdoTransType;
208
209 // structure to inform application about finish of SDO transfer
210 typedef struct {
211         tEplSdoComConHdl m_SdoComConHdl;
212         tEplSdoComConState m_SdoComConState;
213         DWORD m_dwAbortCode;
214         tEplSdoAccessType m_SdoAccessType;
215         unsigned int m_uiNodeId;        // NodeId of the target
216         unsigned int m_uiTargetIndex;   // index which was accessed
217         unsigned int m_uiTargetSubIndex;        // subindex which was accessed
218         unsigned int m_uiTransferredByte;       // number of bytes transferred
219         void *m_pUserArg;       // user definable argument pointer
220
221 } tEplSdoComFinished;
222
223 // callback function pointer to inform application about connection
224 typedef tEplKernel(PUBLIC * tEplSdoFinishedCb) (tEplSdoComFinished *
225                                                 pSdoComFinished_p);
226
227 // structure to init SDO transfer to Read or Write by Index
228 typedef struct {
229         tEplSdoComConHdl m_SdoComConHdl;
230         unsigned int m_uiIndex;
231         unsigned int m_uiSubindex;
232         void *m_pData;
233         unsigned int m_uiDataSize;
234         unsigned int m_uiTimeout;       // not used in this version
235         tEplSdoAccessType m_SdoAccessType;
236         tEplSdoFinishedCb m_pfnSdoFinishedCb;
237         void *m_pUserArg;       // user definable argument pointer
238
239 } tEplSdoComTransParamByIndex;
240
241 //---------------------------------------------------------------------------
242 // function prototypes
243 //---------------------------------------------------------------------------
244
245 #endif // #ifndef _EPLSDO_H_