ath9k: Set IEEE80211_TX_CTL_RATE_CTRL_PROBE in rate control for probe rate
[linux-2.6/cjktty.git] / drivers / staging / epl / EplApiProcessImage.c
blob2b2fdf229a75118eb30a9b4b52b0794c6693517e
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"
72 //#include "kernel/EplPdokCal.h"
74 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
75 #include <asm/uaccess.h>
76 #endif
78 /***************************************************************************/
79 /* */
80 /* */
81 /* G L O B A L D E F I N I T I O N S */
82 /* */
83 /* */
84 /***************************************************************************/
86 //---------------------------------------------------------------------------
87 // const defines
88 //---------------------------------------------------------------------------
90 //---------------------------------------------------------------------------
91 // local types
92 //---------------------------------------------------------------------------
94 //---------------------------------------------------------------------------
95 // modul globale vars
96 //---------------------------------------------------------------------------
98 //---------------------------------------------------------------------------
99 // local function prototypes
100 //---------------------------------------------------------------------------
102 /***************************************************************************/
103 /* */
104 /* */
105 /* C L A S S EplApi */
106 /* */
107 /* */
108 /***************************************************************************/
110 // Description:
113 /***************************************************************************/
115 //=========================================================================//
116 // //
117 // P R I V A T E D E F I N I T I O N S //
118 // //
119 //=========================================================================//
121 //---------------------------------------------------------------------------
122 // const defines
123 //---------------------------------------------------------------------------
125 //---------------------------------------------------------------------------
126 // local types
127 //---------------------------------------------------------------------------
129 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
130 typedef struct {
131 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
132 BYTE m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
133 #endif
134 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
135 BYTE m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
136 #endif
138 } tEplApiProcessImageInstance;
140 //---------------------------------------------------------------------------
141 // local vars
142 //---------------------------------------------------------------------------
144 static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
145 #endif
147 //---------------------------------------------------------------------------
148 // local function prototypes
149 //---------------------------------------------------------------------------
151 //=========================================================================//
152 // //
153 // P U B L I C F U N C T I O N S //
154 // //
155 //=========================================================================//
157 //---------------------------------------------------------------------------
159 // Function: EplApiProcessImageSetup()
161 // Description: sets up static process image
163 // Parameters: (none)
165 // Returns: tEplKernel = error code
168 // State:
170 //---------------------------------------------------------------------------
172 tEplKernel PUBLIC EplApiProcessImageSetup(void)
174 tEplKernel Ret = kEplSuccessful;
175 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
176 unsigned int uiVarEntries;
177 tEplObdSize ObdSize;
178 #endif
180 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
181 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
182 ObdSize = 1;
183 Ret = EplApiLinkObject(0x2000,
184 EplApiProcessImageInstance_g.
185 m_abProcessImageInput, &uiVarEntries, &ObdSize,
188 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
189 ObdSize = 1;
190 Ret = EplApiLinkObject(0x2001,
191 EplApiProcessImageInstance_g.
192 m_abProcessImageInput, &uiVarEntries, &ObdSize,
195 ObdSize = 2;
196 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
197 Ret = EplApiLinkObject(0x2010,
198 EplApiProcessImageInstance_g.
199 m_abProcessImageInput, &uiVarEntries, &ObdSize,
202 ObdSize = 2;
203 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
204 Ret = EplApiLinkObject(0x2011,
205 EplApiProcessImageInstance_g.
206 m_abProcessImageInput, &uiVarEntries, &ObdSize,
209 ObdSize = 4;
210 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
211 Ret = EplApiLinkObject(0x2020,
212 EplApiProcessImageInstance_g.
213 m_abProcessImageInput, &uiVarEntries, &ObdSize,
216 ObdSize = 4;
217 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
218 Ret = EplApiLinkObject(0x2021,
219 EplApiProcessImageInstance_g.
220 m_abProcessImageInput, &uiVarEntries, &ObdSize,
222 #endif
224 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
225 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
226 ObdSize = 1;
227 Ret = EplApiLinkObject(0x2030,
228 EplApiProcessImageInstance_g.
229 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
232 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
233 ObdSize = 1;
234 Ret = EplApiLinkObject(0x2031,
235 EplApiProcessImageInstance_g.
236 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
239 ObdSize = 2;
240 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
241 Ret = EplApiLinkObject(0x2040,
242 EplApiProcessImageInstance_g.
243 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
246 ObdSize = 2;
247 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
248 Ret = EplApiLinkObject(0x2041,
249 EplApiProcessImageInstance_g.
250 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
253 ObdSize = 4;
254 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
255 Ret = EplApiLinkObject(0x2050,
256 EplApiProcessImageInstance_g.
257 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
260 ObdSize = 4;
261 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
262 Ret = EplApiLinkObject(0x2051,
263 EplApiProcessImageInstance_g.
264 m_abProcessImageOutput, &uiVarEntries, &ObdSize,
266 #endif
268 return Ret;
271 //----------------------------------------------------------------------------
272 // Function: EplApiProcessImageExchangeIn()
274 // Description: replaces passed input process image with the one of EPL stack
276 // Parameters: pPI_p = input process image
278 // Returns: tEplKernel = error code
280 // State:
281 //----------------------------------------------------------------------------
283 tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage * pPI_p)
285 tEplKernel Ret = kEplSuccessful;
287 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
288 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
289 copy_to_user(pPI_p->m_pImage,
290 EplApiProcessImageInstance_g.m_abProcessImageInput,
291 min(pPI_p->m_uiSize,
292 sizeof(EplApiProcessImageInstance_g.
293 m_abProcessImageInput)));
294 #else
295 EPL_MEMCPY(pPI_p->m_pImage,
296 EplApiProcessImageInstance_g.m_abProcessImageInput,
297 min(pPI_p->m_uiSize,
298 sizeof(EplApiProcessImageInstance_g.
299 m_abProcessImageInput)));
300 #endif
301 #endif
303 return Ret;
306 //----------------------------------------------------------------------------
307 // Function: EplApiProcessImageExchangeOut()
309 // Description: copies passed output process image to EPL stack.
311 // Parameters: pPI_p = output process image
313 // Returns: tEplKernel = error code
315 // State:
316 //----------------------------------------------------------------------------
318 tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage * pPI_p)
320 tEplKernel Ret = kEplSuccessful;
322 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
323 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
324 copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
325 pPI_p->m_pImage,
326 min(pPI_p->m_uiSize,
327 sizeof(EplApiProcessImageInstance_g.
328 m_abProcessImageOutput)));
329 #else
330 EPL_MEMCPY(EplApiProcessImageInstance_g.m_abProcessImageOutput,
331 pPI_p->m_pImage,
332 min(pPI_p->m_uiSize,
333 sizeof(EplApiProcessImageInstance_g.
334 m_abProcessImageOutput)));
335 #endif
336 #endif
338 return Ret;
341 //=========================================================================//
342 // //
343 // P R I V A T E F U N C T I O N S //
344 // //
345 //=========================================================================//
347 // EOF