1#pragma once
  2
  3#ifdef __cplusplus
  4extern "C" {
  5#endif
  6
  7#ifdef _WIN32
  8#    pragma clang diagnostic ignored "-Wignored-attributes"
  9#endif
 10
 11#include <AEEStdErr.h>
 12#include <rpcmem.h>
 13#include <remote.h>
 14#include <dspqueue.h>
 15
 16#if defined(_WIN32) && !defined(__MINGW32__)
 17#    ifdef GGML_BACKEND_BUILD
 18#        define HTPDRV_API __declspec(dllexport) extern
 19#    else
 20#        define HTPDRV_API __declspec(dllimport) extern
 21#    endif
 22#else
 23#    define HTPDRV_API __attribute__ ((visibility ("default"))) extern
 24#endif
 25
 26/* Offset to differentiate HLOS and Hexagon error codes.
 27   Stores the value of AEE_EOFFSET for Hexagon. */
 28#ifndef DSP_OFFSET
 29#    define DSP_OFFSET 0x80000400
 30#endif
 31
 32/* Errno for connection reset by peer. */
 33#ifndef ECONNRESET
 34#    ifdef __hexagon__
 35#        define ECONNRESET 104
 36#    endif
 37#endif
 38
 39/* Abstraction of different OS specific sleep APIs.
 40   SLEEP accepts input in seconds. */
 41#ifndef SLEEP
 42#    ifdef __hexagon__
 43#        define SLEEP(x)                      \
 44            { /* Do nothing for simulator. */ \
 45            }
 46#    else
 47#        ifdef _WIN32
 48#            define SLEEP(x) Sleep(1000 * x) /* Sleep accepts input in milliseconds. */
 49#        else
 50#            define SLEEP(x) sleep(x)        /* sleep accepts input in seconds. */
 51#        endif
 52#    endif
 53#endif
 54
 55/* Include windows specific header files. */
 56#ifdef _WIN32
 57#    include <windows.h>
 58#    include <sysinfoapi.h>
 59#    define _CRT_SECURE_NO_WARNINGS         1
 60#    define _WINSOCK_DEPRECATED_NO_WARNINGS 1
 61#endif
 62
 63/* Includes and defines for all HLOS except windows */
 64#if !defined(__hexagon__) && !defined(_WIN32)
 65#    include "unistd.h"
 66
 67#    include <sys/time.h>
 68#endif
 69
 70/* Includes and defines for Hexagon and all HLOS except Windows. */
 71#if !defined(_WIN32)
 72/* Weak reference to remote symbol for compilation. */
 73#    pragma weak remote_session_control
 74#    pragma weak remote_handle_control
 75#    pragma weak remote_handle64_control
 76#    pragma weak fastrpc_mmap
 77#    pragma weak fastrpc_munmap
 78#    pragma weak rpcmem_alloc2
 79#endif
 80
 81#if !defined(_WIN32)
 82#    pragma weak remote_system_request
 83#endif
 84
 85#ifdef _WIN32
 86#     define DSPQUEUE_TIMEOUT DSPQUEUE_TIMEOUT_NONE
 87#else
 88#     define DSPQUEUE_TIMEOUT 1000000
 89#endif
 90
 91/**
 92 * htpdrv_init API: driver interface entry point
 93 *
 94 * @return      Return AEE error codes as defined in Hexagon SDK.
 95 */
 96HTPDRV_API int htpdrv_init(void);
 97
 98/**
 99 * get_domain API: get domain struct from domain value.
100 *
101 * @param[in]  domain value of a domain
102 * @return     Returns domain struct of the domain if it is supported or else
103 *             returns NULL.
104 *
105 */
106HTPDRV_API domain * get_domain(int domain_id);
107
108/**
109 * get_hex_arch_ver API: query the Hexagon processor architecture version information
110 *
111 * @param[in]   domain_id value of a domain
112 * @param[out]  Arch version (73, 75, ...)
113 * @return      0 if query is successful.
114 *              non-zero if error, return value points to the error.
115 *
116 */
117HTPDRV_API int get_hex_arch_ver(int domain, int * arch);
118
119#ifdef __cplusplus
120}
121#endif