• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _ADSP_PERF_STUB_H
30 #define _ADSP_PERF_STUB_H
31 #include "adsp_perf.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 _ADSP_PERF_SLIM_H
438 #define _ADSP_PERF_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 Type types[2];
450 static const Type types[2] = {{0x8,{{(const uintptr_t)0,(const uintptr_t)1}}, 2,0x8},{0x1,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x1}};
451 static const Parameter parameters[4] = {{0x4,{{(const uintptr_t)0,(const uintptr_t)1}}, 2,0x4,0,0},{SLIM_IFPTR32(0x8,0x10),{{(const uintptr_t)&(types[0]),(const uintptr_t)0x0}}, 9,SLIM_IFPTR32(0x4,0x8),3,0},{SLIM_IFPTR32(0x8,0x10),{{(const uintptr_t)&(types[1]),(const uintptr_t)0x0}}, 9,SLIM_IFPTR32(0x4,0x8),3,0},{0x4,{{(const uintptr_t)0,(const uintptr_t)1}}, 2,0x4,3,0}};
452 static const Parameter* const parameterArrays[5] = {(&(parameters[2])),(&(parameters[3])),(&(parameters[3])),(&(parameters[1])),(&(parameters[0]))};
453 static const Method methods[3] = {{REMOTE_SCALARS_MAKEX(0,0,0x1,0x0,0x0,0x0),0x4,0x0,1,1,(&(parameterArrays[4])),0x4,0x0},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x1,0x0,0x0),0x4,0x0,3,1,(&(parameterArrays[3])),0x4,0x1},{REMOTE_SCALARS_MAKEX(0,0,0x1,0x2,0x0,0x0),0x4,0x8,5,3,(&(parameterArrays[0])),0x4,0x4}};
454 static const Method* const methodArrays[3] = {&(methods[0]),&(methods[1]),&(methods[2])};
455 static const char strings[48] = "get_usecs\0get_keys\0numKeys\0maxLen\0enable\0dst\0ix\0";
456 static const uint16_t methodStrings[8] = {10,14,27,19,0,41,34,45};
457 static const uint16_t methodStringsArrays[3] = {6,4,0};
458 __QAIC_SLIM_EXPORT const Interface __QAIC_SLIM(adsp_perf_slim) = {3,&(methodArrays[0]),0,0,&(methodStringsArrays [0]),methodStrings,strings};
459 #endif //_ADSP_PERF_SLIM_H
460 #ifdef __cplusplus
461 extern "C" {
462 #endif
463 
464 #ifndef _const_adsp_perf_handle
465 #define _const_adsp_perf_handle ((remote_handle)-1)
466 #endif //_const_adsp_perf_handle
467 
_adsp_perf_pls_dtor(void * data)468 static void _adsp_perf_pls_dtor(void* data) {
469    remote_handle* ph = (remote_handle*)data;
470    if(_const_adsp_perf_handle != *ph) {
471       (void)__QAIC_REMOTE(remote_handle_close)(*ph);
472       *ph = _const_adsp_perf_handle;
473    }
474 }
475 
_adsp_perf_pls_ctor(void * ctx,void * data)476 static int _adsp_perf_pls_ctor(void* ctx, void* data) {
477    remote_handle* ph = (remote_handle*)data;
478    *ph = _const_adsp_perf_handle;
479    if(*ph == (remote_handle)-1) {
480       return __QAIC_REMOTE(remote_handle_open)((const char*)ctx, ph);
481    }
482    return 0;
483 }
484 
485 #if (defined __qdsp6__) || (defined __hexagon__)
486 #pragma weak  adsp_pls_add_lookup
487 extern int adsp_pls_add_lookup(uint32_t type, uint32_t key, int size, int (*ctor)(void* ctx, void* data), void* ctx, void (*dtor)(void* ctx), void** ppo);
488 #pragma weak  HAP_pls_add_lookup
489 extern int HAP_pls_add_lookup(uint32_t type, uint32_t key, int size, int (*ctor)(void* ctx, void* data), void* ctx, void (*dtor)(void* ctx), void** ppo);
490 
_adsp_perf_handle(void)491 __QAIC_STUB_EXPORT remote_handle _adsp_perf_handle(void) {
492    remote_handle* ph;
493    if(adsp_pls_add_lookup) {
494       if(0 == adsp_pls_add_lookup((uint32_t)_adsp_perf_handle, 0, sizeof(*ph),  _adsp_perf_pls_ctor, "adsp_perf",  _adsp_perf_pls_dtor, (void**)&ph))  {
495          return *ph;
496       }
497       return (remote_handle)-1;
498    } else if(HAP_pls_add_lookup) {
499       if(0 == HAP_pls_add_lookup((uint32_t)_adsp_perf_handle, 0, sizeof(*ph),  _adsp_perf_pls_ctor, "adsp_perf",  _adsp_perf_pls_dtor, (void**)&ph))  {
500          return *ph;
501       }
502       return (remote_handle)-1;
503    }
504    return(remote_handle)-1;
505 }
506 
507 #else //__qdsp6__ || __hexagon__
508 
509 uint32_t _adsp_perf_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare);
510 
511 #ifdef _WIN32
512 #include "Windows.h"
_adsp_perf_atomic_CompareAndExchange(uint32_t * volatile puDest,uint32_t uExchange,uint32_t uCompare)513 uint32_t _adsp_perf_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare) {
514    return (uint32_t)InterlockedCompareExchange((volatile LONG*)puDest, (LONG)uExchange, (LONG)uCompare);
515 }
516 #elif __GNUC__
_adsp_perf_atomic_CompareAndExchange(uint32_t * volatile puDest,uint32_t uExchange,uint32_t uCompare)517 uint32_t _adsp_perf_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare) {
518    return __sync_val_compare_and_swap(puDest, uCompare, uExchange);
519 }
520 #endif //_WIN32
521 
522 
_adsp_perf_handle(void)523 __QAIC_STUB_EXPORT remote_handle _adsp_perf_handle(void) {
524    static remote_handle handle = _const_adsp_perf_handle;
525    if((remote_handle)-1 != handle) {
526       return handle;
527    } else {
528       remote_handle tmp;
529       int nErr = _adsp_perf_pls_ctor("adsp_perf", (void*)&tmp);
530       if(nErr) {
531          return (remote_handle)-1;
532       }
533       if(((remote_handle)-1 != handle) || ((remote_handle)-1 != (remote_handle)_adsp_perf_atomic_CompareAndExchange((uint32_t*)&handle, (uint32_t)tmp, (uint32_t)-1))) {
534          _adsp_perf_pls_dtor(&tmp);
535       }
536       return handle;
537    }
538 }
539 
540 #endif //__qdsp6__
541 
__QAIC_STUB(adsp_perf_skel_invoke)542 __QAIC_STUB_EXPORT int __QAIC_STUB(adsp_perf_skel_invoke)(uint32_t _sc, remote_arg* _pra) __QAIC_STUB_ATTRIBUTE {
543    return __QAIC_REMOTE(remote_handle_invoke)(_adsp_perf_handle(), _sc, _pra);
544 }
545 
546 #ifdef __cplusplus
547 }
548 #endif
549 
550 
551 #ifdef __cplusplus
552 extern "C" {
553 #endif
_stub_method(remote_handle _handle,uint32_t _mid,uint32_t _in0[1])554 static __inline int _stub_method(remote_handle _handle, uint32_t _mid, uint32_t _in0[1]) {
555    remote_arg _pra[1];
556    uint32_t _primIn[1];
557    int _nErr = 0;
558    _pra[0].buf.pv = (void*)_primIn;
559    _pra[0].buf.nLen = sizeof(_primIn);
560    _COPY(_primIn, 0, _in0, 0, 4);
561    _TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 1, 0, 0, 0), _pra));
562    _CATCH(_nErr) {}
563    return _nErr;
564 }
__QAIC_STUB(adsp_perf_enable)565 __QAIC_STUB_EXPORT int __QAIC_STUB(adsp_perf_enable)(int ix) __QAIC_STUB_ATTRIBUTE {
566    uint32_t _mid = 0;
567    return _stub_method(_adsp_perf_handle(), _mid, (uint32_t*)&ix);
568 }
_stub_method_1(remote_handle _handle,uint32_t _mid,char * _rout0[1],uint32_t _rout0Len[1])569 static __inline int _stub_method_1(remote_handle _handle, uint32_t _mid, char* _rout0[1], uint32_t _rout0Len[1]) {
570    int _numIn[1];
571    remote_arg _pra[2];
572    uint32_t _primIn[1];
573    remote_arg* _praIn;
574    remote_arg* _praROut;
575    int _nErr = 0;
576    _numIn[0] = 0;
577    _pra[0].buf.pv = (void*)_primIn;
578    _pra[0].buf.nLen = sizeof(_primIn);
579    _COPY(_primIn, 0, _rout0Len, 0, 4);
580    _praIn = (_pra + 1);
581    _praROut = (_praIn + _numIn[0] + 0);
582    _praROut[0].buf.pv = _rout0[0];
583    _praROut[0].buf.nLen = (8 * _rout0Len[0]);
584    _TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 1, 1, 0, 0), _pra));
585    _CATCH(_nErr) {}
586    return _nErr;
587 }
__QAIC_STUB(adsp_perf_get_usecs)588 __QAIC_STUB_EXPORT int __QAIC_STUB(adsp_perf_get_usecs)(int64* dst, int dstLen) __QAIC_STUB_ATTRIBUTE {
589    uint32_t _mid = 1;
590    return _stub_method_1(_adsp_perf_handle(), _mid, (char**)&dst, (uint32_t*)&dstLen);
591 }
_stub_method_2(remote_handle _handle,uint32_t _mid,char * _rout0[1],uint32_t _rout0Len[1],uint32_t _rout1[1],uint32_t _rout2[1])592 static __inline int _stub_method_2(remote_handle _handle, uint32_t _mid, char* _rout0[1], uint32_t _rout0Len[1], uint32_t _rout1[1], uint32_t _rout2[1]) {
593    int _numIn[1];
594    remote_arg _pra[3];
595    uint32_t _primIn[1];
596    uint32_t _primROut[2];
597    remote_arg* _praIn;
598    remote_arg* _praROut;
599    int _nErr = 0;
600    _numIn[0] = 0;
601    _pra[0].buf.pv = (void*)_primIn;
602    _pra[0].buf.nLen = sizeof(_primIn);
603    _pra[(_numIn[0] + 1)].buf.pv = (void*)_primROut;
604    _pra[(_numIn[0] + 1)].buf.nLen = sizeof(_primROut);
605    _COPY(_primIn, 0, _rout0Len, 0, 4);
606    _praIn = (_pra + 1);
607    _praROut = (_praIn + _numIn[0] + 1);
608    _praROut[0].buf.pv = _rout0[0];
609    _praROut[0].buf.nLen = (1 * _rout0Len[0]);
610    _TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 1, 2, 0, 0), _pra));
611    _COPY(_rout1, 0, _primROut, 0, 4);
612    _COPY(_rout2, 0, _primROut, 4, 4);
613    _CATCH(_nErr) {}
614    return _nErr;
615 }
__QAIC_STUB(adsp_perf_get_keys)616 __QAIC_STUB_EXPORT int __QAIC_STUB(adsp_perf_get_keys)(char* keys, int keysLen, int* maxLen, int* numKeys) __QAIC_STUB_ATTRIBUTE {
617    uint32_t _mid = 2;
618    return _stub_method_2(_adsp_perf_handle(), _mid, (char**)&keys, (uint32_t*)&keysLen, (uint32_t*)maxLen, (uint32_t*)numKeys);
619 }
620 #ifdef __cplusplus
621 }
622 #endif
623 #endif //_ADSP_PERF_STUB_H
624