1 #ifndef _CHRE_APP_SUPPORT_CC_ 2 #define _CHRE_APP_SUPPORT_CC_ 3 4 /* 5 Copyright (c) 2017, The Linux Foundation. All rights reserved. 6 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions are 9 met: 10 * Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 12 * Redistributions in binary form must reproduce the above 13 copyright notice, this list of conditions and the following 14 disclaimer in the documentation and/or other materials provided 15 with the distribution. 16 * Neither the name of The Linux Foundation nor the names of its 17 contributors may be used to endorse or promote products derived 18 from this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 24 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <chre.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 struct AppInfo { 40 uint64_t appId; 41 uint32_t appVer; 42 bool (*init)(void); 43 void (*end)(void); 44 void (*handle)(uint32_t, uint16_t, const void*); 45 }; 46 47 extern void hexChreAddApp(const struct AppInfo* info); 48 extern void hexChreRemoveApp(const struct AppInfo* info); 49 50 #if !defined(NANOAPP_ID) || !defined(NANOAPP_VERSION) 51 #error NANOAPP_ID and NANOAPP_VERSION must be defined in the build environment 52 #endif 53 54 static const struct AppInfo mAppInfo = { 55 .appId = NANOAPP_ID, 56 .appVer = NANOAPP_VERSION, 57 .init = (nanoappStart), 58 .end = (nanoappEnd), 59 .handle = (nanoappHandleEvent) 60 }; 61 62 static void __appInit (void) __attribute__((constructor)); __appInit(void)63 static void __appInit (void) { 64 hexChreAddApp(&(mAppInfo)); 65 } 66 67 static void __appEnd (void) __attribute__((destructor)); __appEnd(void)68 static void __appEnd (void) { 69 hexChreRemoveApp(&(mAppInfo)); 70 } 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif 77