1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: source file for EPL API module (process image)
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
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.
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 $
56 $Revision: 1.7 $ $Date: 2008/11/13 17:13:09 $
63 -------------------------------------------------------------------------
67 2006/10/10 d.k.: start of the implementation, version 1.00
69 ****************************************************************************/
72 //#include "kernel/EplPdokCal.h"
74 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
75 #include <asm/uaccess.h>
79 /***************************************************************************/
82 /* G L O B A L D E F I N I T I O N S */
85 /***************************************************************************/
87 //---------------------------------------------------------------------------
89 //---------------------------------------------------------------------------
91 //---------------------------------------------------------------------------
93 //---------------------------------------------------------------------------
95 //---------------------------------------------------------------------------
97 //---------------------------------------------------------------------------
99 //---------------------------------------------------------------------------
100 // local function prototypes
101 //---------------------------------------------------------------------------
104 /***************************************************************************/
107 /* C L A S S EplApi */
110 /***************************************************************************/
115 /***************************************************************************/
118 //=========================================================================//
120 // P R I V A T E D E F I N I T I O N S //
122 //=========================================================================//
124 //---------------------------------------------------------------------------
126 //---------------------------------------------------------------------------
128 //---------------------------------------------------------------------------
130 //---------------------------------------------------------------------------
132 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
135 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
136 BYTE m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
138 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
139 BYTE m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
142 } tEplApiProcessImageInstance;
144 //---------------------------------------------------------------------------
146 //---------------------------------------------------------------------------
148 static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
151 //---------------------------------------------------------------------------
152 // local function prototypes
153 //---------------------------------------------------------------------------
156 //=========================================================================//
158 // P U B L I C F U N C T I O N S //
160 //=========================================================================//
163 //---------------------------------------------------------------------------
165 // Function: EplApiProcessImageSetup()
167 // Description: sets up static process image
169 // Parameters: (none)
171 // Returns: tEplKernel = error code
176 //---------------------------------------------------------------------------
178 tEplKernel PUBLIC EplApiProcessImageSetup(void)
180 tEplKernel Ret = kEplSuccessful;
181 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
182 unsigned int uiVarEntries;
186 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
187 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
189 Ret = EplApiLinkObject(
191 EplApiProcessImageInstance_g.m_abProcessImageInput,
196 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
198 Ret = EplApiLinkObject(
200 EplApiProcessImageInstance_g.m_abProcessImageInput,
206 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
207 Ret = EplApiLinkObject(
209 EplApiProcessImageInstance_g.m_abProcessImageInput,
215 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
216 Ret = EplApiLinkObject(
218 EplApiProcessImageInstance_g.m_abProcessImageInput,
224 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
225 Ret = EplApiLinkObject(
227 EplApiProcessImageInstance_g.m_abProcessImageInput,
233 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
234 Ret = EplApiLinkObject(
236 EplApiProcessImageInstance_g.m_abProcessImageInput,
242 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
243 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
245 Ret = EplApiLinkObject(
247 EplApiProcessImageInstance_g.m_abProcessImageOutput,
252 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
254 Ret = EplApiLinkObject(
256 EplApiProcessImageInstance_g.m_abProcessImageOutput,
262 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
263 Ret = EplApiLinkObject(
265 EplApiProcessImageInstance_g.m_abProcessImageOutput,
271 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
272 Ret = EplApiLinkObject(
274 EplApiProcessImageInstance_g.m_abProcessImageOutput,
280 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
281 Ret = EplApiLinkObject(
283 EplApiProcessImageInstance_g.m_abProcessImageOutput,
289 uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
290 Ret = EplApiLinkObject(
292 EplApiProcessImageInstance_g.m_abProcessImageOutput,
301 //----------------------------------------------------------------------------
302 // Function: EplApiProcessImageExchangeIn()
304 // Description: replaces passed input process image with the one of EPL stack
306 // Parameters: pPI_p = input process image
308 // Returns: tEplKernel = error code
311 //----------------------------------------------------------------------------
313 tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage* pPI_p)
315 tEplKernel Ret = kEplSuccessful;
317 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
318 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
319 copy_to_user(pPI_p->m_pImage,
320 EplApiProcessImageInstance_g.m_abProcessImageInput,
321 min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageInput)));
323 EPL_MEMCPY(pPI_p->m_pImage,
324 EplApiProcessImageInstance_g.m_abProcessImageInput,
325 min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageInput)));
333 //----------------------------------------------------------------------------
334 // Function: EplApiProcessImageExchangeOut()
336 // Description: copies passed output process image to EPL stack.
338 // Parameters: pPI_p = output process image
340 // Returns: tEplKernel = error code
343 //----------------------------------------------------------------------------
345 tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage* pPI_p)
347 tEplKernel Ret = kEplSuccessful;
349 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
350 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
351 copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
353 min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageOutput)));
355 EPL_MEMCPY(EplApiProcessImageInstance_g.m_abProcessImageOutput,
357 min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageOutput)));
365 //=========================================================================//
367 // P R I V A T E F U N C T I O N S //
369 //=========================================================================//