Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef _CHRE_API_H_
     18 #define _CHRE_API_H_
     19 
     20 #include <stdarg.h>
     21 #include <stdint.h>
     22 
     23 /* if va_list is passed by value it must fit in 32-bit register */
     24 #if !defined(SYSCALL_PARAMS_PASSED_AS_PTRS) || !defined(SYSCALL_VARARGS_PARAMS_PASSED_AS_PTRS)
     25 C_STATIC_ASSERT(va_list_size, sizeof(va_list) == sizeof(uint32_t));
     26 #endif
     27 
     28 /*
     29  *  many syscalls rely on the property that uintptr_t can hold uint32_t without data loss
     30  * This is enforced by static assertion below.
     31  */
     32 C_STATIC_ASSERT(uintptr_size, sizeof(uintptr_t) >= sizeof(uint32_t));
     33 
     34 //EXTERNAL API
     35 #define SYSCALL_CHRE_MAIN                 0
     36 #define SYSCALL_CHRE_LAST                 1
     37 
     38 #define SYSCALL_CHRE_MAIN_API             0
     39 #define SYSCALL_CHRE_MAIN_LAST            1
     40 
     41 #define SYSCALL_CHRE_MAIN_API_GET_APP_ID             0 // (void) -> uint64_t
     42 #define SYSCALL_CHRE_MAIN_API_GET_INST_ID            1 // (void) -> uint32_t
     43 #define SYSCALL_CHRE_MAIN_API_LOG                    2 // (enum LogLevel, const char *, uintptr_t) -> void
     44 #define SYSCALL_CHRE_MAIN_API_GET_TIME               3 // (void) -> uint64_t
     45 #define SYSCALL_CHRE_MAIN_API_TIMER_SET              4 // (uint64_t, const void *, bool) -> uint32_t
     46 #define SYSCALL_CHRE_MAIN_API_TIMER_CANCEL           5 // (uint32_t) -> bool
     47 #define SYSCALL_CHRE_MAIN_API_ABORT                  6 // (uint32_t) -> void
     48 #define SYSCALL_CHRE_MAIN_API_HEAP_ALLOC             7 // (uint32_t) -> void *
     49 #define SYSCALL_CHRE_MAIN_API_HEAP_FREE              8 // (void *) -> void
     50 #define SYSCALL_CHRE_MAIN_API_SEND_EVENT             9 // (uint32_t, void *, chreEventCompleteFunction*, uint32_t) -> bool
     51 #define SYSCALL_CHRE_MAIN_API_SEND_MSG              10 // (void *, uint32_t, uint32_t, chreMessageFreeFunction *) -> bool
     52 #define SYSCALL_CHRE_MAIN_API_SENSOR_FIND_DEFAULT   11 //
     53 #define SYSCALL_CHRE_MAIN_API_SENSOR_GET_INFO       12 //
     54 #define SYSCALL_CHRE_MAIN_API_SENSOR_GET_STATUS     13 //
     55 #define SYSCALL_CHRE_MAIN_API_SENSOR_CONFIG         14 //
     56 #define SYSCALL_CHRE_MAIN_API_GET_OS_API_VERSION    15 //
     57 #define SYSCALL_CHRE_MAIN_API_GET_OS_VERSION        16 //
     58 #define SYSCALL_CHRE_MAIN_API_GET_PLATFORM_ID       17 //
     59 #define SYSCALL_CHRE_MAIN_API_LAST                  18 // always last. holes are allowed, but not immediately before this
     60 
     61 //called by os entry point to export the api
     62 void osChreApiExport(void);
     63 // release CHRE event and optionally call completion callback
     64 void osChreFreeEvent(uint32_t tid, void (*free_info)(uint16_t, void *), uint32_t evtType, void * evtData);
     65 
     66 #endif
     67