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>
78 /***************************************************************************/
81 /* G L O B A L D E F I N I T I O N S */
84 /***************************************************************************/
86 //---------------------------------------------------------------------------
88 //---------------------------------------------------------------------------
90 //---------------------------------------------------------------------------
92 //---------------------------------------------------------------------------
94 //---------------------------------------------------------------------------
96 //---------------------------------------------------------------------------
98 //---------------------------------------------------------------------------
99 // local function prototypes
100 //---------------------------------------------------------------------------
102 /***************************************************************************/
105 /* C L A S S EplApi */
108 /***************************************************************************/
113 /***************************************************************************/
115 //=========================================================================//
117 // P R I V A T E D E F I N I T I O N S //
119 //=========================================================================//
121 //---------------------------------------------------------------------------
123 //---------------------------------------------------------------------------
125 //---------------------------------------------------------------------------
127 //---------------------------------------------------------------------------
129 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
131 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
132 BYTE m_abProcessImageInput
[EPL_API_PROCESS_IMAGE_SIZE_IN
];
134 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
135 BYTE m_abProcessImageOutput
[EPL_API_PROCESS_IMAGE_SIZE_OUT
];
138 } tEplApiProcessImageInstance
;
140 //---------------------------------------------------------------------------
142 //---------------------------------------------------------------------------
144 static tEplApiProcessImageInstance EplApiProcessImageInstance_g
;
147 //---------------------------------------------------------------------------
148 // local function prototypes
149 //---------------------------------------------------------------------------
151 //=========================================================================//
153 // P U B L I C F U N C T I O N S //
155 //=========================================================================//
157 //---------------------------------------------------------------------------
159 // Function: EplApiProcessImageSetup()
161 // Description: sets up static process image
163 // Parameters: (none)
165 // Returns: tEplKernel = error code
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
;
180 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
181 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_IN
;
183 Ret
= EplApiLinkObject(0x2000,
184 EplApiProcessImageInstance_g
.
185 m_abProcessImageInput
, &uiVarEntries
, &ObdSize
,
188 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_IN
;
190 Ret
= EplApiLinkObject(0x2001,
191 EplApiProcessImageInstance_g
.
192 m_abProcessImageInput
, &uiVarEntries
, &ObdSize
,
196 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_IN
/ ObdSize
;
197 Ret
= EplApiLinkObject(0x2010,
198 EplApiProcessImageInstance_g
.
199 m_abProcessImageInput
, &uiVarEntries
, &ObdSize
,
203 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_IN
/ ObdSize
;
204 Ret
= EplApiLinkObject(0x2011,
205 EplApiProcessImageInstance_g
.
206 m_abProcessImageInput
, &uiVarEntries
, &ObdSize
,
210 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_IN
/ ObdSize
;
211 Ret
= EplApiLinkObject(0x2020,
212 EplApiProcessImageInstance_g
.
213 m_abProcessImageInput
, &uiVarEntries
, &ObdSize
,
217 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_IN
/ ObdSize
;
218 Ret
= EplApiLinkObject(0x2021,
219 EplApiProcessImageInstance_g
.
220 m_abProcessImageInput
, &uiVarEntries
, &ObdSize
,
224 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
225 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_OUT
;
227 Ret
= EplApiLinkObject(0x2030,
228 EplApiProcessImageInstance_g
.
229 m_abProcessImageOutput
, &uiVarEntries
, &ObdSize
,
232 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_OUT
;
234 Ret
= EplApiLinkObject(0x2031,
235 EplApiProcessImageInstance_g
.
236 m_abProcessImageOutput
, &uiVarEntries
, &ObdSize
,
240 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_OUT
/ ObdSize
;
241 Ret
= EplApiLinkObject(0x2040,
242 EplApiProcessImageInstance_g
.
243 m_abProcessImageOutput
, &uiVarEntries
, &ObdSize
,
247 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_OUT
/ ObdSize
;
248 Ret
= EplApiLinkObject(0x2041,
249 EplApiProcessImageInstance_g
.
250 m_abProcessImageOutput
, &uiVarEntries
, &ObdSize
,
254 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_OUT
/ ObdSize
;
255 Ret
= EplApiLinkObject(0x2050,
256 EplApiProcessImageInstance_g
.
257 m_abProcessImageOutput
, &uiVarEntries
, &ObdSize
,
261 uiVarEntries
= EPL_API_PROCESS_IMAGE_SIZE_OUT
/ ObdSize
;
262 Ret
= EplApiLinkObject(0x2051,
263 EplApiProcessImageInstance_g
.
264 m_abProcessImageOutput
, &uiVarEntries
, &ObdSize
,
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
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
,
292 sizeof(EplApiProcessImageInstance_g
.
293 m_abProcessImageInput
)));
295 EPL_MEMCPY(pPI_p
->m_pImage
,
296 EplApiProcessImageInstance_g
.m_abProcessImageInput
,
298 sizeof(EplApiProcessImageInstance_g
.
299 m_abProcessImageInput
)));
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
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
,
327 sizeof(EplApiProcessImageInstance_g
.
328 m_abProcessImageOutput
)));
330 EPL_MEMCPY(EplApiProcessImageInstance_g
.m_abProcessImageOutput
,
333 sizeof(EplApiProcessImageInstance_g
.
334 m_abProcessImageOutput
)));
341 //=========================================================================//
343 // P R I V A T E F U N C T I O N S //
345 //=========================================================================//