1 2 /* 3 * Copyright (C) 2017 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef CHRE_UTIL_NANOAPP_APP_ID_H_ 19 #define CHRE_UTIL_NANOAPP_APP_ID_H_ 20 21 #include <chre/common.h> 22 #include <stdint.h> 23 24 /** 25 * @file 26 * Helpers for defining static nanoapp IDs, e.g. for use with 27 * CHRE_STATIC_NANOAPP_INIT. 28 */ 29 30 //! Sample Vendor ID for example nanoapps. The vendor ID portion is the 5 most 31 //! significant bytes of the app ID. This vendor ID should not appear in 32 //! production. 33 #define CHRE_VENDOR_ID_EXAMPLE UINT64_C(0x0123456789000000) 34 35 namespace chre { 36 37 /** 38 * Constructs a fully qualified nanoapp ID from a vendor portion (most 39 * significant 5 bytes) and app number (least significant 3 bytes) 40 * 41 * @param vendor Value with vendor unique identifier in the most significant 5 42 * bytes 43 * @param appNumber Value with vendor-scoped app number in the least significant 44 * 3 bytes 45 * 46 * @return app ID combining vendor and app number 47 */ makeNanoappId(uint64_t vendor,uint32_t appNumber)48constexpr uint64_t makeNanoappId(uint64_t vendor, uint32_t appNumber) { 49 return ((vendor & CHRE_VENDOR_ID_MASK) | (appNumber & ~CHRE_VENDOR_ID_MASK)); 50 } 51 52 /** 53 * @return App ID combining the given 3-byte app number and Google's 5-byte 54 * vendor ID 55 */ makeExampleNanoappId(uint32_t appNumber)56constexpr uint64_t makeExampleNanoappId(uint32_t appNumber) { 57 return makeNanoappId(CHRE_VENDOR_ID_EXAMPLE, appNumber); 58 } 59 60 /** 61 * @return App ID combining the given 3-byte app number and Google's 5-byte 62 * vendor ID 63 */ makeGoogleNanoappId(uint32_t appNumber)64constexpr uint64_t makeGoogleNanoappId(uint32_t appNumber) { 65 return makeNanoappId(CHRE_VENDOR_ID_GOOGLE, appNumber); 66 } 67 68 // clang-format off 69 constexpr uint64_t kHelloWorldAppId = makeExampleNanoappId(1); 70 constexpr uint64_t kMessageWorldAppId = makeExampleNanoappId(2); 71 constexpr uint64_t kTimerWorldAppId = makeExampleNanoappId(3); 72 constexpr uint64_t kSensorWorldAppId = makeExampleNanoappId(4); 73 constexpr uint64_t kGnssWorldAppId = makeExampleNanoappId(5); 74 constexpr uint64_t kWifiWorldAppId = makeExampleNanoappId(6); 75 constexpr uint64_t kWwanWorldAppId = makeExampleNanoappId(7); 76 // 8 = reserved (previously used by ImuCal) 77 constexpr uint64_t kSpammerAppId = makeExampleNanoappId(9); 78 constexpr uint64_t kUnloadTesterAppId = makeExampleNanoappId(10); 79 // 11 = reserved (previously used by AshWorld) 80 constexpr uint64_t kAudioWorldAppId = makeExampleNanoappId(12); 81 constexpr uint64_t kHostAwakeWorldAppId = makeExampleNanoappId(13); 82 constexpr uint64_t kAudioStressTestAppId = makeExampleNanoappId(14); 83 constexpr uint64_t kPowerTestAppId = makeExampleNanoappId(15); 84 // 16 = Power Test TCM 85 constexpr uint64_t kDebugDumpWorldAppId = makeExampleNanoappId(17); 86 // clang-format on 87 88 } // namespace chre 89 90 #endif // CHRE_UTIL_NANOAPP_APP_ID_H_ 91