1 /*
2 * Copyright (c) 2019, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 #ifndef _APPS_MEM_SKEL_H
30 #define _APPS_MEM_SKEL_H
31 #include "apps_mem.h"
32 #ifndef _QAIC_ENV_H
33 #define _QAIC_ENV_H
34
35 #ifdef __GNUC__
36 #ifdef __clang__
37 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
38 #else
39 #pragma GCC diagnostic ignored "-Wpragmas"
40 #endif
41 #pragma GCC diagnostic ignored "-Wuninitialized"
42 #pragma GCC diagnostic ignored "-Wunused-parameter"
43 #pragma GCC diagnostic ignored "-Wunused-function"
44 #endif
45
46 #ifndef _ATTRIBUTE_UNUSED
47
48 #ifdef _WIN32
49 #define _ATTRIBUTE_UNUSED
50 #else
51 #define _ATTRIBUTE_UNUSED __attribute__ ((unused))
52 #endif
53
54 #endif // _ATTRIBUTE_UNUSED
55
56 #ifndef __QAIC_REMOTE
57 #define __QAIC_REMOTE(ff) ff
58 #endif //__QAIC_REMOTE
59
60 #ifndef __QAIC_HEADER
61 #define __QAIC_HEADER(ff) ff
62 #endif //__QAIC_HEADER
63
64 #ifndef __QAIC_HEADER_EXPORT
65 #define __QAIC_HEADER_EXPORT
66 #endif // __QAIC_HEADER_EXPORT
67
68 #ifndef __QAIC_HEADER_ATTRIBUTE
69 #define __QAIC_HEADER_ATTRIBUTE
70 #endif // __QAIC_HEADER_ATTRIBUTE
71
72 #ifndef __QAIC_IMPL
73 #define __QAIC_IMPL(ff) ff
74 #endif //__QAIC_IMPL
75
76 #ifndef __QAIC_IMPL_EXPORT
77 #define __QAIC_IMPL_EXPORT
78 #endif // __QAIC_IMPL_EXPORT
79
80 #ifndef __QAIC_IMPL_ATTRIBUTE
81 #define __QAIC_IMPL_ATTRIBUTE
82 #endif // __QAIC_IMPL_ATTRIBUTE
83
84 #ifndef __QAIC_STUB
85 #define __QAIC_STUB(ff) ff
86 #endif //__QAIC_STUB
87
88 #ifndef __QAIC_STUB_EXPORT
89 #define __QAIC_STUB_EXPORT
90 #endif // __QAIC_STUB_EXPORT
91
92 #ifndef __QAIC_STUB_ATTRIBUTE
93 #define __QAIC_STUB_ATTRIBUTE
94 #endif // __QAIC_STUB_ATTRIBUTE
95
96 #ifndef __QAIC_SKEL
97 #define __QAIC_SKEL(ff) ff
98 #endif //__QAIC_SKEL__
99
100 #ifndef __QAIC_SKEL_EXPORT
101 #define __QAIC_SKEL_EXPORT
102 #endif // __QAIC_SKEL_EXPORT
103
104 #ifndef __QAIC_SKEL_ATTRIBUTE
105 #define __QAIC_SKEL_ATTRIBUTE
106 #endif // __QAIC_SKEL_ATTRIBUTE
107
108 #ifdef __QAIC_DEBUG__
109 #ifndef __QAIC_DBG_PRINTF__
110 #include <stdio.h>
111 #define __QAIC_DBG_PRINTF__( ee ) do { printf ee ; } while(0)
112 #endif
113 #else
114 #define __QAIC_DBG_PRINTF__( ee ) (void)0
115 #endif
116
117
118 #define _OFFSET(src, sof) ((void*)(((char*)(src)) + (sof)))
119
120 #define _COPY(dst, dof, src, sof, sz) \
121 do {\
122 struct __copy { \
123 char ar[sz]; \
124 };\
125 *(struct __copy*)_OFFSET(dst, dof) = *(struct __copy*)_OFFSET(src, sof);\
126 } while (0)
127
128 #define _COPYIF(dst, dof, src, sof, sz) \
129 do {\
130 if(_OFFSET(dst, dof) != _OFFSET(src, sof)) {\
131 _COPY(dst, dof, src, sof, sz); \
132 } \
133 } while (0)
134
135 _ATTRIBUTE_UNUSED
_qaic_memmove(void * dst,void * src,int size)136 static __inline void _qaic_memmove(void* dst, void* src, int size) {
137 int i;
138 for(i = 0; i < size; ++i) {
139 ((char*)dst)[i] = ((char*)src)[i];
140 }
141 }
142
143 #define _MEMMOVEIF(dst, src, sz) \
144 do {\
145 if(dst != src) {\
146 _qaic_memmove(dst, src, sz);\
147 } \
148 } while (0)
149
150
151 #define _ASSIGN(dst, src, sof) \
152 do {\
153 dst = OFFSET(src, sof); \
154 } while (0)
155
156 #define _STD_STRLEN_IF(str) (str == 0 ? 0 : strlen(str))
157
158 #include "AEEStdErr.h"
159
160 #define _TRY(ee, func) \
161 do { \
162 if (AEE_SUCCESS != ((ee) = func)) {\
163 __QAIC_DBG_PRINTF__((__FILE__ ":%d:error:%d:%s\n", __LINE__, (int)(ee),#func));\
164 goto ee##bail;\
165 } \
166 } while (0)
167
168 #define _CATCH(exception) exception##bail: if (exception != AEE_SUCCESS)
169
170 #define _ASSERT(nErr, ff) _TRY(nErr, 0 == (ff) ? AEE_EBADPARM : AEE_SUCCESS)
171
172 #ifdef __QAIC_DEBUG__
173 #define _ALLOCATE(nErr, pal, size, alignment, pv) _TRY(nErr, _allocator_alloc(pal, __FILE_LINE__, size, alignment, (void**)&pv))
174 #else
175 #define _ALLOCATE(nErr, pal, size, alignment, pv) _TRY(nErr, _allocator_alloc(pal, 0, size, alignment, (void**)&pv))
176 #endif
177
178
179 #endif // _QAIC_ENV_H
180
181 #include "remote.h"
182 #ifndef _ALLOCATOR_H
183 #define _ALLOCATOR_H
184
185 #include <stdlib.h>
186 #include <stdint.h>
187
188 typedef struct _heap _heap;
189 struct _heap {
190 _heap* pPrev;
191 const char* loc;
192 uint64_t buf;
193 };
194
195 typedef struct _allocator {
196 _heap* pheap;
197 uint8_t* stack;
198 uint8_t* stackEnd;
199 int nSize;
200 } _allocator;
201
202 _ATTRIBUTE_UNUSED
_heap_alloc(_heap ** ppa,const char * loc,int size,void ** ppbuf)203 static __inline int _heap_alloc(_heap** ppa, const char* loc, int size, void** ppbuf) {
204 _heap* pn = 0;
205 pn = malloc(size + sizeof(_heap) - sizeof(uint64_t));
206 if(pn != 0) {
207 pn->pPrev = *ppa;
208 pn->loc = loc;
209 *ppa = pn;
210 *ppbuf = (void*)&(pn->buf);
211 return 0;
212 } else {
213 return -1;
214 }
215 }
216 #define _ALIGN_SIZE(x, y) (((x) + (y-1)) & ~(y-1))
217
218 _ATTRIBUTE_UNUSED
_allocator_alloc(_allocator * me,const char * loc,int size,unsigned int al,void ** ppbuf)219 static __inline int _allocator_alloc(_allocator* me,
220 const char* loc,
221 int size,
222 unsigned int al,
223 void** ppbuf) {
224 if(size < 0) {
225 return -1;
226 } else if (size == 0) {
227 *ppbuf = 0;
228 return 0;
229 }
230 if((_ALIGN_SIZE((uintptr_t)me->stackEnd, al) + size) < (uintptr_t)me->stack + me->nSize) {
231 *ppbuf = (uint8_t*)_ALIGN_SIZE((uintptr_t)me->stackEnd, al);
232 me->stackEnd = (uint8_t*)_ALIGN_SIZE((uintptr_t)me->stackEnd, al) + size;
233 return 0;
234 } else {
235 return _heap_alloc(&me->pheap, loc, size, ppbuf);
236 }
237 }
238
239 _ATTRIBUTE_UNUSED
_allocator_deinit(_allocator * me)240 static __inline void _allocator_deinit(_allocator* me) {
241 _heap* pa = me->pheap;
242 while(pa != 0) {
243 _heap* pn = pa;
244 const char* loc = pn->loc;
245 (void)loc;
246 pa = pn->pPrev;
247 free(pn);
248 }
249 }
250
251 _ATTRIBUTE_UNUSED
_allocator_init(_allocator * me,uint8_t * stack,int stackSize)252 static __inline void _allocator_init(_allocator* me, uint8_t* stack, int stackSize) {
253 me->stack = stack;
254 me->stackEnd = stack + stackSize;
255 me->nSize = stackSize;
256 me->pheap = 0;
257 }
258
259
260 #endif // _ALLOCATOR_H
261
262 #ifndef SLIM_H
263 #define SLIM_H
264
265 #include <stdint.h>
266
267 //a C data structure for the idl types that can be used to implement
268 //static and dynamic language bindings fairly efficiently.
269 //
270 //the goal is to have a minimal ROM and RAM footprint and without
271 //doing too many allocations. A good way to package these things seemed
272 //like the module boundary, so all the idls within one module can share
273 //all the type references.
274
275
276 #define PARAMETER_IN 0x0
277 #define PARAMETER_OUT 0x1
278 #define PARAMETER_INOUT 0x2
279 #define PARAMETER_ROUT 0x3
280 #define PARAMETER_INROUT 0x4
281
282 //the types that we get from idl
283 #define TYPE_OBJECT 0x0
284 #define TYPE_INTERFACE 0x1
285 #define TYPE_PRIMITIVE 0x2
286 #define TYPE_ENUM 0x3
287 #define TYPE_STRING 0x4
288 #define TYPE_WSTRING 0x5
289 #define TYPE_STRUCTURE 0x6
290 #define TYPE_UNION 0x7
291 #define TYPE_ARRAY 0x8
292 #define TYPE_SEQUENCE 0x9
293
294 //these require the pack/unpack to recurse
295 //so it's a hint to those languages that can optimize in cases where
296 //recursion isn't necessary.
297 #define TYPE_COMPLEX_STRUCTURE (0x10 | TYPE_STRUCTURE)
298 #define TYPE_COMPLEX_UNION (0x10 | TYPE_UNION)
299 #define TYPE_COMPLEX_ARRAY (0x10 | TYPE_ARRAY)
300 #define TYPE_COMPLEX_SEQUENCE (0x10 | TYPE_SEQUENCE)
301
302
303 typedef struct Type Type;
304
305 #define INHERIT_TYPE\
306 int32_t nativeSize; /*in the simple case its the same as wire size and alignment*/\
307 union {\
308 struct {\
309 const uintptr_t p1;\
310 const uintptr_t p2;\
311 } _cast;\
312 struct {\
313 uint32_t iid;\
314 uint32_t bNotNil;\
315 } object;\
316 struct {\
317 const Type *arrayType;\
318 int32_t nItems;\
319 } array;\
320 struct {\
321 const Type *seqType;\
322 int32_t nMaxLen;\
323 } seqSimple; \
324 struct {\
325 uint32_t bFloating;\
326 uint32_t bSigned;\
327 } prim; \
328 const SequenceType* seqComplex;\
329 const UnionType *unionType;\
330 const StructType *structType;\
331 int32_t stringMaxLen;\
332 uint8_t bInterfaceNotNil;\
333 } param;\
334 uint8_t type;\
335 uint8_t nativeAlignment\
336
337 typedef struct UnionType UnionType;
338 typedef struct StructType StructType;
339 typedef struct SequenceType SequenceType;
340 struct Type {
341 INHERIT_TYPE;
342 };
343
344 struct SequenceType {
345 const Type * seqType;
346 uint32_t nMaxLen;
347 uint32_t inSize;
348 uint32_t routSizePrimIn;
349 uint32_t routSizePrimROut;
350 };
351
352 //byte offset from the start of the case values for
353 //this unions case value array. it MUST be aligned
354 //at the alignment requrements for the descriptor
355 //
356 //if negative it means that the unions cases are
357 //simple enumerators, so the value read from the descriptor
358 //can be used directly to find the correct case
359 typedef union CaseValuePtr CaseValuePtr;
360 union CaseValuePtr {
361 const uint8_t* value8s;
362 const uint16_t* value16s;
363 const uint32_t* value32s;
364 const uint64_t* value64s;
365 };
366
367 //these are only used in complex cases
368 //so I pulled them out of the type definition as references to make
369 //the type smaller
370 struct UnionType {
371 const Type *descriptor;
372 uint32_t nCases;
373 const CaseValuePtr caseValues;
374 const Type * const *cases;
375 int32_t inSize;
376 int32_t routSizePrimIn;
377 int32_t routSizePrimROut;
378 uint8_t inAlignment;
379 uint8_t routAlignmentPrimIn;
380 uint8_t routAlignmentPrimROut;
381 uint8_t inCaseAlignment;
382 uint8_t routCaseAlignmentPrimIn;
383 uint8_t routCaseAlignmentPrimROut;
384 uint8_t nativeCaseAlignment;
385 uint8_t bDefaultCase;
386 };
387
388 struct StructType {
389 uint32_t nMembers;
390 const Type * const *members;
391 int32_t inSize;
392 int32_t routSizePrimIn;
393 int32_t routSizePrimROut;
394 uint8_t inAlignment;
395 uint8_t routAlignmentPrimIn;
396 uint8_t routAlignmentPrimROut;
397 };
398
399 typedef struct Parameter Parameter;
400 struct Parameter {
401 INHERIT_TYPE;
402 uint8_t mode;
403 uint8_t bNotNil;
404 };
405
406 #define SLIM_IFPTR32(is32,is64) (sizeof(uintptr_t) == 4 ? (is32) : (is64))
407 #define SLIM_SCALARS_IS_DYNAMIC(u) (((u) & 0x00ffffff) == 0x00ffffff)
408
409 typedef struct Method Method;
410 struct Method {
411 uint32_t uScalars; //no method index
412 int32_t primInSize;
413 int32_t primROutSize;
414 int maxArgs;
415 int numParams;
416 const Parameter * const *params;
417 uint8_t primInAlignment;
418 uint8_t primROutAlignment;
419 };
420
421 typedef struct Interface Interface;
422
423 struct Interface {
424 int nMethods;
425 const Method * const *methodArray;
426 int nIIds;
427 const uint32_t *iids;
428 const uint16_t* methodStringArray;
429 const uint16_t* methodStrings;
430 const char* strings;
431 };
432
433
434 #endif //SLIM_H
435
436
437 #ifndef _APPS_MEM_SLIM_H
438 #define _APPS_MEM_SLIM_H
439 #include "remote.h"
440 #include <stdint.h>
441
442 #ifndef __QAIC_SLIM
443 #define __QAIC_SLIM(ff) ff
444 #endif
445 #ifndef __QAIC_SLIM_EXPORT
446 #define __QAIC_SLIM_EXPORT
447 #endif
448
449 static const Parameter parameters[6] = {{0x4,{{(const uintptr_t)0,(const uintptr_t)1}}, 2,0x4,0,0},{0x4,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x4,0,0},{0x4,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x4,3,0},{0x8,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x8,0,0},{0x8,{{(const uintptr_t)0,(const uintptr_t)1}}, 2,0x8,0,0},{0x8,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x8,3,0}};
450 static const Parameter* const parameterArrays[20] = {(&(parameters[0])),(&(parameters[1])),(&(parameters[1])),(&(parameters[3])),(&(parameters[4])),(&(parameters[5])),(&(parameters[5])),(&(parameters[0])),(&(parameters[1])),(&(parameters[1])),(&(parameters[1])),(&(parameters[0])),(&(parameters[2])),(&(parameters[2])),(&(parameters[0])),(&(parameters[0])),(&(parameters[5])),(&(parameters[5])),(&(parameters[3])),(&(parameters[0]))};
451 static const Method methods[6] = {{REMOTE_SCALARS_MAKEX(0,0,0x1,0x1,0x0,0x0),0x14,0x8,7,7,(&(parameterArrays[7])),0x4,0x4},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x0,0x0,0x0),0x8,0x0,2,2,(&(parameterArrays[10])),0x4,0x0},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x1,0x0,0x0),0x20,0x10,11,7,(&(parameterArrays[0])),0x8,0x8},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x0,0x0,0x0),0x10,0x0,6,2,(&(parameterArrays[3])),0x8,0x0},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x1,0x0,0x0),0x8,0x10,4,4,(&(parameterArrays[14])),0x4,0x8},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x0,0x0,0x0),0xc,0x0,4,2,(&(parameterArrays[18])),0x8,0x0}};
452 static const Method* const methodArrays[6] = {&(methods[0]),&(methods[1]),&(methods[2]),&(methods[3]),&(methods[4]),&(methods[5])};
453 static const char strings[130] = "request_unmap64\0request_map64\0request_unmap\0share_unmap\0request_map\0share_map\0ion_flags\0rflags\0heapid\0vadsp\0vapps\0size\0len\0vin\0fd\0";
454 static const uint16_t methodStrings[30] = {16,95,78,88,123,119,108,102,56,95,78,88,123,119,108,102,68,127,114,108,102,44,102,114,0,102,119,30,102,119};
455 static const uint16_t methodStringsArrays[6] = {8,27,0,24,16,21};
456 __QAIC_SLIM_EXPORT const Interface __QAIC_SLIM(apps_mem_slim) = {6,&(methodArrays[0]),0,0,&(methodStringsArrays [0]),methodStrings,strings};
457 #endif //_APPS_MEM_SLIM_H
458 #ifdef __cplusplus
459 extern "C" {
460 #endif
_skel_method(int (* _pfn)(uint64_t,uint32_t),uint32_t _sc,remote_arg * _pra)461 static __inline int _skel_method(int (*_pfn)(uint64_t, uint32_t), uint32_t _sc, remote_arg* _pra) {
462 remote_arg* _praEnd;
463 uint64_t _in0[1];
464 uint32_t _in1[1];
465 uint64_t* _primIn;
466 int _nErr = 0;
467 _praEnd = ((_pra + REMOTE_SCALARS_INBUFS(_sc)) + REMOTE_SCALARS_OUTBUFS(_sc));
468 _ASSERT(_nErr, (_pra + 1) <= _praEnd);
469 _ASSERT(_nErr, _pra[0].buf.nLen >= 12);
470 _primIn = _pra[0].buf.pv;
471 _COPY(_in0, 0, _primIn, 0, 8);
472 _COPY(_in1, 0, _primIn, 8, 4);
473 _TRY(_nErr, _pfn(*_in0, *_in1));
474 _CATCH(_nErr) {}
475 return _nErr;
476 }
_skel_method_1(int (* _pfn)(uint32_t,uint32_t,uint64_t *,uint64_t *),uint32_t _sc,remote_arg * _pra)477 static __inline int _skel_method_1(int (*_pfn)(uint32_t, uint32_t, uint64_t*, uint64_t*), uint32_t _sc, remote_arg* _pra) {
478 remote_arg* _praEnd;
479 uint32_t _in0[1];
480 uint32_t _in1[1];
481 uint64_t _rout2[1];
482 uint64_t _rout3[1];
483 uint32_t* _primIn;
484 int _numIn[1];
485 uint64_t* _primROut;
486 int _nErr = 0;
487 _praEnd = ((_pra + REMOTE_SCALARS_INBUFS(_sc)) + REMOTE_SCALARS_OUTBUFS(_sc));
488 _ASSERT(_nErr, (_pra + 2) <= _praEnd);
489 _numIn[0] = (REMOTE_SCALARS_INBUFS(_sc) - 1);
490 _ASSERT(_nErr, _pra[0].buf.nLen >= 8);
491 _primIn = _pra[0].buf.pv;
492 _ASSERT(_nErr, _pra[(_numIn[0] + 1)].buf.nLen >= 16);
493 _primROut = _pra[(_numIn[0] + 1)].buf.pv;
494 _COPY(_in0, 0, _primIn, 0, 4);
495 _COPY(_in1, 0, _primIn, 4, 4);
496 _TRY(_nErr, _pfn(*_in0, *_in1, _rout2, _rout3));
497 _COPY(_primROut, 0, _rout2, 0, 8);
498 _COPY(_primROut, 8, _rout3, 0, 8);
499 _CATCH(_nErr) {}
500 return _nErr;
501 }
_skel_method_2(int (* _pfn)(uint64_t,uint64_t),uint32_t _sc,remote_arg * _pra)502 static __inline int _skel_method_2(int (*_pfn)(uint64_t, uint64_t), uint32_t _sc, remote_arg* _pra) {
503 remote_arg* _praEnd;
504 uint64_t _in0[1];
505 uint64_t _in1[1];
506 uint64_t* _primIn;
507 int _nErr = 0;
508 _praEnd = ((_pra + REMOTE_SCALARS_INBUFS(_sc)) + REMOTE_SCALARS_OUTBUFS(_sc));
509 _ASSERT(_nErr, (_pra + 1) <= _praEnd);
510 _ASSERT(_nErr, _pra[0].buf.nLen >= 16);
511 _primIn = _pra[0].buf.pv;
512 _COPY(_in0, 0, _primIn, 0, 8);
513 _COPY(_in1, 0, _primIn, 8, 8);
514 _TRY(_nErr, _pfn(*_in0, *_in1));
515 _CATCH(_nErr) {}
516 return _nErr;
517 }
_skel_method_3(int (* _pfn)(uint32_t,uint32_t,uint32_t,uint64_t,uint64_t,uint64_t *,uint64_t *),uint32_t _sc,remote_arg * _pra)518 static __inline int _skel_method_3(int (*_pfn)(uint32_t, uint32_t, uint32_t, uint64_t, uint64_t, uint64_t*, uint64_t*), uint32_t _sc, remote_arg* _pra) {
519 remote_arg* _praEnd;
520 uint32_t _in0[1];
521 uint32_t _in1[1];
522 uint32_t _in2[1];
523 uint64_t _in3[1];
524 uint64_t _in4[1];
525 uint64_t _rout5[1];
526 uint64_t _rout6[1];
527 uint64_t* _primIn;
528 int _numIn[1];
529 uint64_t* _primROut;
530 int _nErr = 0;
531 _praEnd = ((_pra + REMOTE_SCALARS_INBUFS(_sc)) + REMOTE_SCALARS_OUTBUFS(_sc));
532 _ASSERT(_nErr, (_pra + 2) <= _praEnd);
533 _numIn[0] = (REMOTE_SCALARS_INBUFS(_sc) - 1);
534 _ASSERT(_nErr, _pra[0].buf.nLen >= 32);
535 _primIn = _pra[0].buf.pv;
536 _ASSERT(_nErr, _pra[(_numIn[0] + 1)].buf.nLen >= 16);
537 _primROut = _pra[(_numIn[0] + 1)].buf.pv;
538 _COPY(_in0, 0, _primIn, 0, 4);
539 _COPY(_in1, 0, _primIn, 4, 4);
540 _COPY(_in2, 0, _primIn, 8, 4);
541 _COPY(_in3, 0, _primIn, 16, 8);
542 _COPY(_in4, 0, _primIn, 24, 8);
543 _TRY(_nErr, _pfn(*_in0, *_in1, *_in2, *_in3, *_in4, _rout5, _rout6));
544 _COPY(_primROut, 0, _rout5, 0, 8);
545 _COPY(_primROut, 8, _rout6, 0, 8);
546 _CATCH(_nErr) {}
547 return _nErr;
548 }
_skel_method_4(int (* _pfn)(uint32_t,uint32_t),uint32_t _sc,remote_arg * _pra)549 static __inline int _skel_method_4(int (*_pfn)(uint32_t, uint32_t), uint32_t _sc, remote_arg* _pra) {
550 remote_arg* _praEnd;
551 uint32_t _in0[1];
552 uint32_t _in1[1];
553 uint32_t* _primIn;
554 int _nErr = 0;
555 _praEnd = ((_pra + REMOTE_SCALARS_INBUFS(_sc)) + REMOTE_SCALARS_OUTBUFS(_sc));
556 _ASSERT(_nErr, (_pra + 1) <= _praEnd);
557 _ASSERT(_nErr, _pra[0].buf.nLen >= 8);
558 _primIn = _pra[0].buf.pv;
559 _COPY(_in0, 0, _primIn, 0, 4);
560 _COPY(_in1, 0, _primIn, 4, 4);
561 _TRY(_nErr, _pfn(*_in0, *_in1));
562 _CATCH(_nErr) {}
563 return _nErr;
564 }
_skel_method_5(int (* _pfn)(uint32_t,uint32_t,uint32_t,uint32_t,uint32_t,uint32_t *,uint32_t *),uint32_t _sc,remote_arg * _pra)565 static __inline int _skel_method_5(int (*_pfn)(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t*, uint32_t*), uint32_t _sc, remote_arg* _pra) {
566 remote_arg* _praEnd;
567 uint32_t _in0[1];
568 uint32_t _in1[1];
569 uint32_t _in2[1];
570 uint32_t _in3[1];
571 uint32_t _in4[1];
572 uint32_t _rout5[1];
573 uint32_t _rout6[1];
574 uint32_t* _primIn;
575 int _numIn[1];
576 uint32_t* _primROut;
577 int _nErr = 0;
578 _praEnd = ((_pra + REMOTE_SCALARS_INBUFS(_sc)) + REMOTE_SCALARS_OUTBUFS(_sc));
579 _ASSERT(_nErr, (_pra + 2) <= _praEnd);
580 _numIn[0] = (REMOTE_SCALARS_INBUFS(_sc) - 1);
581 _ASSERT(_nErr, _pra[0].buf.nLen >= 20);
582 _primIn = _pra[0].buf.pv;
583 _ASSERT(_nErr, _pra[(_numIn[0] + 1)].buf.nLen >= 8);
584 _primROut = _pra[(_numIn[0] + 1)].buf.pv;
585 _COPY(_in0, 0, _primIn, 0, 4);
586 _COPY(_in1, 0, _primIn, 4, 4);
587 _COPY(_in2, 0, _primIn, 8, 4);
588 _COPY(_in3, 0, _primIn, 12, 4);
589 _COPY(_in4, 0, _primIn, 16, 4);
590 _TRY(_nErr, _pfn(*_in0, *_in1, *_in2, *_in3, *_in4, _rout5, _rout6));
591 _COPY(_primROut, 0, _rout5, 0, 4);
592 _COPY(_primROut, 4, _rout6, 0, 4);
593 _CATCH(_nErr) {}
594 return _nErr;
595 }
__QAIC_SKEL(apps_mem_skel_invoke)596 __QAIC_SKEL_EXPORT int __QAIC_SKEL(apps_mem_skel_invoke)(uint32_t _sc, remote_arg* _pra) __QAIC_SKEL_ATTRIBUTE {
597 switch(REMOTE_SCALARS_METHOD(_sc))
598 {
599 case 0:
600 return _skel_method_5((void*)__QAIC_IMPL(apps_mem_request_map), _sc, _pra);
601 case 1:
602 return _skel_method_4((void*)__QAIC_IMPL(apps_mem_request_unmap), _sc, _pra);
603 case 2:
604 return _skel_method_3((void*)__QAIC_IMPL(apps_mem_request_map64), _sc, _pra);
605 case 3:
606 return _skel_method_2((void*)__QAIC_IMPL(apps_mem_request_unmap64), _sc, _pra);
607 case 4:
608 return _skel_method_1((void*)__QAIC_IMPL(apps_mem_share_map), _sc, _pra);
609 case 5:
610 return _skel_method((void*)__QAIC_IMPL(apps_mem_share_unmap), _sc, _pra);
611 }
612 return AEE_EUNSUPPORTED;
613 }
614 #ifdef __cplusplus
615 }
616 #endif
617 #endif //_APPS_MEM_SKEL_H
618