wl1251: move module probe methods into spi.c
[linux-2.6/btrfs-unstable.git] / drivers / staging / epl / EplApiProcessImage.c
blob7d55086a8e4e9d80b61074d3fcdd999728e9c29f
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 API module (process image)
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: EplApiProcessImage.c,v $
54 $Author: D.Krueger $
56 $Revision: 1.7 $ $Date: 2008/11/13 17:13:09 $
58 $State: Exp $
60 Build Environment:
61 GCC V3.4
63 -------------------------------------------------------------------------
65 Revision History:
67 2006/10/10 d.k.: start of the implementation, version 1.00
69 ****************************************************************************/
71 #include "Epl.h"
73 #include <linux/uaccess.h>
75 /***************************************************************************/
76 /* */
77 /* */
78 /* G L O B A L D E F I N I T I O N S */
79 /* */
80 /* */
81 /***************************************************************************/
83 //---------------------------------------------------------------------------
84 // const defines
85 //---------------------------------------------------------------------------
87 //---------------------------------------------------------------------------
88 // local types
89 //---------------------------------------------------------------------------
91 //---------------------------------------------------------------------------
92 // modul globale vars
93 //---------------------------------------------------------------------------
95 //---------------------------------------------------------------------------
96 // local function prototypes
97 //---------------------------------------------------------------------------
99 /***************************************************************************/
100 /* */
101 /* */
102 /* C L A S S EplApi */
103 /* */
104 /* */
105 /***************************************************************************/
107 // Description:
110 /***************************************************************************/
112 //=========================================================================//
113 // //
114 // P R I V A T E D E F I N I T I O N S //
115 // //
116 //=========================================================================//
118 //---------------------------------------------------------------------------
119 // const defines
120 //---------------------------------------------------------------------------
122 //---------------------------------------------------------------------------
123 // local types
124 //---------------------------------------------------------------------------
126 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
127 typedef struct {
128 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
129 u8 m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
130 #endif
131 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
132 u8 m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
133 #endif
135 } tEplApiProcessImageInstance;
137 //---------------------------------------------------------------------------
138 // local vars
139 //---------------------------------------------------------------------------
141 static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
142 #endif
144 //---------------------------------------------------------------------------
145 // local function prototypes
146 //---------------------------------------------------------------------------
148 //=========================================================================//
149 // //
150 // P U B L I C F U N C T I O N S //
151 // //
152 //=========================================================================//
154 //---------------------------------------------------------------------------
156 // Function: EplApiProcessImageSetup()
158 // Description: sets up static process image
160 // Parameters: (none)
162 // Returns: tEplKernel = error code
165 // State:
167 //---------------------------------------------------------------------------
169 tEplKernel EplApiProcessImageSetup(void)
171 tEplKernel Ret = kEplSuccessful;
172 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
173 unsigned int uiVarEntries;
174 tEplObdSize ObdSize;
175 #endif
177 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
178 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
179 ObdSize = 1;
180 Ret = EplApiLinkObject(0x2000,
181 EplApiProcessImageInstance_g.
182 m_abProcessImageInput, &uiVarEntries, &ObdSize,
185 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
186 ObdSize = 1;
187 Ret = EplApiLinkObject(0x2001,
188 EplApiProcessImageInstance_g.
189 m_abProcessImageInput, &uiVarEntries, &ObdSize,
192 ObdSize = 2;
193 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
194 Ret = EplApiLinkObject(0x2010,
195 EplApiProcessImageInstance_g.
196 m_abProcessImageInput, &uiVarEntries, &ObdSize,
199 ObdSize = 2;
200 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
201 Ret = EplApiLinkObject(0x2011,
202 EplApiProcessImageInstance_g.
203 m_abProcessImageInput, &uiVarEntries, &ObdSize,
206 ObdSize = 4;
207 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
208 Ret = EplApiLinkObject(0x2020,
209 EplApiProcessImageInstance_g.
210 m_abProcessImageInput, &uiVarEntries, &ObdSize,
213 ObdSize = 4;
214 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
215 Ret = EplApiLinkObject(0x2021,
216 EplApiProcessImageInstance_g.
217 m_abProcessImageInput, &uiVarEntries, &ObdSize,
219 #endif
221 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
222 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
223 ObdSize = 1;
224 Ret = EplApiLinkObject(0x2030,
225 EplApiProcessImageInstance_g.
226 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
229 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
230 ObdSize = 1;
231 Ret = EplApiLinkObject(0x2031,
232 EplApiProcessImageInstance_g.
233 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
236 ObdSize = 2;
237 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
238 Ret = EplApiLinkObject(0x2040,
239 EplApiProcessImageInstance_g.
240 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
243 ObdSize = 2;
244 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
245 Ret = EplApiLinkObject(0x2041,
246 EplApiProcessImageInstance_g.
247 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
250 ObdSize = 4;
251 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
252 Ret = EplApiLinkObject(0x2050,
253 EplApiProcessImageInstance_g.
254 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
257 ObdSize = 4;
258 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
259 Ret = EplApiLinkObject(0x2051,
260 EplApiProcessImageInstance_g.
261 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
263 #endif
265 return Ret;
268 //----------------------------------------------------------------------------
269 // Function: EplApiProcessImageExchangeIn()
271 // Description: replaces passed input process image with the one of EPL stack
273 // Parameters: pPI_p = input process image
275 // Returns: tEplKernel = error code
277 // State:
278 //----------------------------------------------------------------------------
280 tEplKernel EplApiProcessImageExchangeIn(tEplApiProcessImage *pPI_p)
282 tEplKernel Ret = kEplSuccessful;
284 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
285 copy_to_user(pPI_p->m_pImage,
286 EplApiProcessImageInstance_g.m_abProcessImageInput,
287 min(pPI_p->m_uiSize,
288 sizeof(EplApiProcessImageInstance_g.
289 m_abProcessImageInput)));
290 #endif
292 return Ret;
295 //----------------------------------------------------------------------------
296 // Function: EplApiProcessImageExchangeOut()
298 // Description: copies passed output process image to EPL stack.
300 // Parameters: pPI_p = output process image
302 // Returns: tEplKernel = error code
304 // State:
305 //----------------------------------------------------------------------------
307 tEplKernel EplApiProcessImageExchangeOut(tEplApiProcessImage *pPI_p)
309 tEplKernel Ret = kEplSuccessful;
311 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
312 copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
313 pPI_p->m_pImage,
314 min(pPI_p->m_uiSize,
315 sizeof(EplApiProcessImageInstance_g.
316 m_abProcessImageOutput)));
317 #endif
319 return Ret;
322 //=========================================================================//
323 // //
324 // P R I V A T E F U N C T I O N S //
325 // //
326 //=========================================================================//
328 // EOF