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_VERSION_H_ 18 #define _CHRE_VERSION_H_ 19 20 /** 21 * Definitions and methods for the versioning of the Context Hub Runtime 22 * Environment. 23 * 24 * The CHRE API versioning pertains to all the chre_*.h files and chre.h. 25 */ 26 27 28 #include <stdint.h> 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 35 /** 36 * Value for version 0.1 of the Context Hub Runtime Environment API interface. 37 * 38 * @see CHRE_API_VERSION 39 */ 40 #define CHRE_API_VERSION_0_1 UINT32_C(0x00010000) 41 42 /** 43 * Major and Minor Version of this Context Hub Runtime Environment API. 44 * 45 * The major version changes when there is an incompatible API change. 46 * 47 * The minor version changes when there is an addition in functionality 48 * in a backwards-compatible manner. 49 * 50 * We define the version number as an unsigned 32-bit value. The most 51 * significant byte is the Major Version. The second-most significant byte 52 * is the Minor Version. The two least significant bytes are the Patch 53 * Version. The Patch Version is not defined by this header API, but 54 * is provided by a specific CHRE implementation (see chreGetVersion()). 55 * 56 * Note that version numbers can always be numerically compared with 57 * expected results, so 1.0.0 < 1.0.4 < 1.1.0 < 2.0.300 < 3.5.0. 58 */ 59 #define CHRE_API_VERSION CHRE_API_VERSION_0_1 60 61 62 /** 63 * Get the API version the CHRE implementation was compiled against. 64 * 65 * This is not necessarily the CHRE_API_VERSION in the header the nanoapp was 66 * built against, and indeed may not have even appeared in the context_hub_os.h 67 * header which this nanoapp was built against. 68 * 69 * By definition, this will have the two least significant bytes set to 0, 70 * and only contain the major and minor version number. 71 * 72 * @returns The API version. 73 */ 74 uint32_t chreGetApiVersion(void); 75 76 /** 77 * Get the version of this CHRE implementation. 78 * 79 * By definition, ((chreGetApiVersion() & UINT32_C(0xFFFF0000)) == 80 * (chreGetVersion() & UINT32_C(0xFFFF0000))). 81 * 82 * The Patch Version, in the lower two bytes, only have meaning in context 83 * of this specific platform ID. It is increased by the platform every time 84 * a backwards-compatible bug fix is released. 85 * 86 * @returns The version. 87 * 88 * @see chreGetPlatformId() 89 */ 90 uint32_t chreGetVersion(void); 91 92 /** 93 * Get the Platform ID of this CHRE. 94 * 95 * The most significant five bytes are the vendor ID as set out by the 96 * NANOAPP_VENDOR convention in context_hub.h, as used by nanoapp IDs. 97 * 98 * The least significant three bytes are set by the vendor, but must be 99 * unique for each different CHRE implementation/hardware that the vendor 100 * supplies. 101 * 102 * The idea is that in the case of known bugs in the field, a new nanoapp could 103 * be shipped with a workaround that would use this value, and chreGetVersion(), 104 * to have code that can conditionally work around the bug on a buggy version. 105 * Thus, we require this uniqueness to allow such a setup to work. 106 * 107 * @returns The platform ID. 108 */ 109 uint64_t chreGetPlatformId(void); 110 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* _CHRE_VERSION_H_ */ 117 118