From 69b4f49ba6cfd79baa66c85f98a8df3757dfcc6d Mon Sep 17 00:00:00 2001 From: Vinayak Katoch Date: Tue, 18 Mar 2025 16:45:35 +0530 Subject: [PATCH 1/5] Remove hardcoded vendor DSP path fallbacks Remove VENDOR_DSP_LOCATION and VENDOR_DOM_LOCATION macros from apps_std_internal.h and fastrpc_apps_user.c. Simplify open_shell() by removing fallback logic that attempted to open shell files from /vendor/dsp/ and /vendor/dsp/xdsp/. Shell files are now opened only from DSP_LIBS_LOCATION paths. Update comments in apps_std_imp.c to reflect generic fallback behavior without vendor path references. Signed-off-by: Vinayak Katoch --- inc/apps_std_internal.h | 7 ------- src/apps_std_imp.c | 4 ++-- src/fastrpc_apps_user.c | 32 +------------------------------- 3 files changed, 3 insertions(+), 40 deletions(-) diff --git a/inc/apps_std_internal.h b/inc/apps_std_internal.h index 37be0c20..f8253549 100644 --- a/inc/apps_std_internal.h +++ b/inc/apps_std_internal.h @@ -22,13 +22,6 @@ #define MAX_NON_PRELOAD_LIBS_LEN 2048 #define FILE_EXT ".so" -#ifndef VENDOR_DSP_LOCATION -#define VENDOR_DSP_LOCATION "/vendor/dsp/" -#endif -#ifndef VENDOR_DOM_LOCATION -#define VENDOR_DOM_LOCATION "/vendor/dsp/xdsp/" -#endif - // Search path used by fastRPC for acdb path #ifndef ADSP_AVS_CFG_PATH #define ADSP_AVS_CFG_PATH ";/etc/acdbdata/;" diff --git a/src/apps_std_imp.c b/src/apps_std_imp.c index 3a693456..7b1068d8 100644 --- a/src/apps_std_imp.c +++ b/src/apps_std_imp.c @@ -1065,7 +1065,7 @@ int fopen_from_dirlist(const char *dirList, const char *delim, } FREEIF(absName); - // fallback: If not found in domain path /vendor/dsp/adsp try in /vendor/dsp + // fallback to open the file without domain absNameLen = strlen(dirName) + strlen(name) + 2; VERIFYC(NULL != (absName = (char *)malloc(sizeof(char) * absNameLen)), AEE_ENOMEMORY); @@ -1238,7 +1238,7 @@ __QAIC_IMPL_EXPORT int __QAIC_IMPL(apps_std_fopen_with_env_fd)( } FREEIF(absName); - // fallback: If not found in domain path /vendor/dsp/adsp try in /vendor/dsp + // fallback to open the file without domain absNameLen = strlen(dirName) + strlen(name) + 2; VERIFYC(NULL != (absName = (char *)malloc(sizeof(char) * absNameLen)), AEE_ENOMEMORY); diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index c19fbefa..f90211d6 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -76,9 +76,6 @@ #include "fastrpc_trace.h" #include "fastrpc_config_parser.h" -#define VENDOR_DSP_LOCATION "/vendor/dsp/" -#define VENDOR_DOM_LOCATION "/vendor/dsp/xdsp/" - char DSP_LIBS_LOCATION[PATH_MAX] = DEFAULT_DSP_SEARCH_PATHS; #ifdef LE_ENABLE @@ -3393,11 +3390,10 @@ static void get_process_testsig(apps_std_FILE *fp, uint64_t *ptrlen) { } static int open_shell(int domain_id, apps_std_FILE *fh, int unsigned_shell) { - char *absName = NULL; char *shell_absName = NULL; char *domain_str = NULL; char dir_list[PATH_MAX] = {0}; - uint16_t shell_absNameLen = 0, absNameLen = 0; + uint16_t shell_absNameLen = 0; int nErr = AEE_SUCCESS; int domain = GET_DOMAIN_FROM_EFFEC_DOMAIN_ID(domain_id); const char *shell_name = SIGNED_SHELL; @@ -3423,28 +3419,6 @@ static int open_shell(int domain_id, apps_std_FILE *fh, int unsigned_shell) { strlcpy(dir_list, DSP_LIBS_LOCATION, sizeof(dir_list)); nErr = fopen_from_dirlist(dir_list, ";", "r", shell_absName, fh); - if (nErr) { - absNameLen = strlen(VENDOR_DSP_LOCATION) + shell_absNameLen + 1; - VERIFYC(NULL != - (absName = (char *)realloc(absName, sizeof(char) * absNameLen)), - AEE_ENOMEMORY); - strlcpy(absName, VENDOR_DSP_LOCATION, absNameLen); - strlcat(absName, shell_absName, absNameLen); - - nErr = apps_std_fopen(absName, "r", fh); - if (nErr) { - absNameLen = strlen(VENDOR_DOM_LOCATION) + shell_absNameLen + 1; - VERIFYC(NULL != (absName = - (char *)realloc(absName, sizeof(char) * absNameLen)), - AEE_ENOMEMORY); - strlcpy(absName, VENDOR_DSP_LOCATION, absNameLen); - strlcat(absName, SUBSYSTEM_NAME[domain], absNameLen); - strlcat(absName, "/", absNameLen); - strlcat(absName, shell_absName, absNameLen); - - nErr = apps_std_fopen(absName, "r", fh); - } - } if (!nErr) FARF(RUNTIME_RPC_HIGH, "Successfully opened %s, domain %d", shell_absName, domain); bail: @@ -3456,10 +3430,6 @@ static int open_shell(int domain_id, apps_std_FILE *fh, int unsigned_shell) { free(shell_absName); shell_absName = NULL; } - if (absName) { - free(absName); - absName = NULL; - } if (nErr != AEE_SUCCESS) { if (domain == SDSP_DOMAIN_ID && fh != NULL) { nErr = AEE_SUCCESS; From 9206dccfa6f3a95dad115d33d868d74d282bc88a Mon Sep 17 00:00:00 2001 From: Vinayak Katoch Date: Fri, 25 Apr 2025 12:09:52 +0530 Subject: [PATCH 2/5] Remove Android reference from fastrpc_apps_user.h header guards Change header guard macros from FASTRPC_ANDROID_USER_H to FASTRPC_APPS_USER_H to remove Android-specific naming and make the header more generic for cross-platform usage. Signed-off-by: Vinayak Katoch --- inc/fastrpc_apps_user.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/fastrpc_apps_user.h b/inc/fastrpc_apps_user.h index 1cab47ae..ca197f10 100644 --- a/inc/fastrpc_apps_user.h +++ b/inc/fastrpc_apps_user.h @@ -1,8 +1,8 @@ // Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. // SPDX-License-Identifier: BSD-3-Clause -#ifndef FASTRPC_ANDROID_USER_H -#define FASTRPC_ANDROID_USER_H +#ifndef FASTRPC_APPS_USER_H +#define FASTRPC_APPS_USER_H #include #include @@ -134,4 +134,4 @@ int get_unsigned_pd_attribute(uint32_t domain, int *unsigned_module); */ int is_userspace_allocation_supported(); -#endif //FASTRPC_ANDROID_USER_H +#endif //FASTRPC_APPS_USER_H From f9e6ee3eb796cd6b0fd8817c894e31a72a1a6d47 Mon Sep 17 00:00:00 2001 From: Vinayak Katoch Date: Fri, 25 Apr 2025 12:17:41 +0530 Subject: [PATCH 3/5] Rename listener_android to listener and update all references Rename listener_android.h to listener.h and listener_android.c to listener.c to remove Android-specific naming. Update all function names from listener_android_* to listener_* pattern. Update header guards, includes, Makefile entries, platform library dependencies, and all function calls throughout the codebase to maintain compilation compatibility. Signed-off-by: Vinayak Katoch --- inc/Makefile.am | 2 +- inc/{listener_android.h => listener.h} | 12 ++++++------ src/Makefile.am | 2 +- src/fastrpc_apps_user.c | 16 ++++++++-------- src/{listener_android.c => listener.c} | 18 +++++++++--------- src/pl_list.c | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) rename inc/{listener_android.h => listener.h} (79%) rename src/{listener_android.c => listener.c} (97%) diff --git a/inc/Makefile.am b/inc/Makefile.am index 9b1657bf..5f04dc24 100644 --- a/inc/Makefile.am +++ b/inc/Makefile.am @@ -53,7 +53,7 @@ noinst_HEADERS = \ fastrpc_procbuf.h \ fastrpc_process_attributes.h \ fastrpc_trace.h \ - listener_android.h \ + listener.h \ listener_buf.h \ log_config.h \ mod_table.h \ diff --git a/inc/listener_android.h b/inc/listener.h similarity index 79% rename from inc/listener_android.h rename to inc/listener.h index 2cf229c8..8ae82752 100644 --- a/inc/listener_android.h +++ b/inc/listener.h @@ -1,8 +1,8 @@ // Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. // SPDX-License-Identifier: BSD-3-Clause -#ifndef LISTENER_ANDROID_H -#define LISTENER_ANDROID_H +#ifndef LISTENER_H +#define LISTENER_H #include #include @@ -22,18 +22,18 @@ /* * API to initialize globals and internal data structures used in listener modules */ -int listener_android_init(void); +int listener_init(void); /* * API to de-initialize globals and internal data structures used in listener modules */ -void listener_android_deinit(void); +void listener_deinit(void); /* * API to initialize domain specific data strcutures used in listener modules */ -int listener_android_domain_init(int domain, int update_requested, sem_t *r_sem); +int listener_domain_init(int domain, int update_requested, sem_t *r_sem); /* * API to de-initialize domain specific data strcutures used in listener modules */ -void listener_android_domain_deinit(int domain); +void listener_domain_deinit(int domain); #endif diff --git a/src/Makefile.am b/src/Makefile.am index 991058ba..6edf2245 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,7 @@ LIBDSPRPC_SOURCES = \ dspsignal.c \ dspqueue/dspqueue_cpu.c \ dspqueue/dspqueue_rpc_stub.c \ - listener_android.c \ + listener.c \ apps_std_imp.c \ apps_mem_imp.c \ apps_mem_skel.c \ diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index f90211d6..2c550f45 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -63,7 +63,7 @@ #include "fastrpc_perf.h" #include "fastrpc_pm.h" #include "fastrpc_procbuf.h" -#include "listener_android.h" +#include "listener.h" #include "log_config.h" #include "platform_libs.h" #include "remotectl.h" @@ -1606,7 +1606,7 @@ int remote_handle64_invoke_async(remote_handle64 local, return nErr; } -int listener_android_geteventfd(int domain, int *fd); +int listener_geteventfd(int domain, int *fd); int remote_handle_open_domain(int domain, const char *name, remote_handle *ph, uint64_t *t_spawn, uint64_t *t_load) { char dlerrstr[255]; @@ -1629,7 +1629,7 @@ int remote_handle_open_domain(int domain, const char *name, remote_handle *ph, if (!strncmp(name, ITRANSPORT_PREFIX "geteventfd", strlen(ITRANSPORT_PREFIX "geteventfd"))) { FARF(RUNTIME_RPC_HIGH, "getting event fd"); - return listener_android_geteventfd(domain, (int *)ph); + return listener_geteventfd(domain, (int *)ph); } if (!strncmp(name, ITRANSPORT_PREFIX "attachguestos", strlen(ITRANSPORT_PREFIX "attachguestos"))) { @@ -3110,7 +3110,7 @@ PL_DEP(fastrpc_apps_user); PL_DEP(gpls); PL_DEP(apps_std); PL_DEP(rpcmem); -PL_DEP(listener_android); +PL_DEP(listener); PL_DEP(fastrpc_async); static int attach_guestos(int domain) { @@ -3160,7 +3160,7 @@ static void domain_deinit(int domain) { pthread_mutex_unlock(&hlist[domain].mut); dspsignal_domain_deinit(domain); - listener_android_domain_deinit(domain); + listener_domain_deinit(domain); hlist[domain].first_revrpc_done = 0; pthread_mutex_lock(&hlist[domain].async_init_deinit_mut); fastrpc_async_domain_deinit(domain); @@ -3957,7 +3957,7 @@ static int domain_init(int domain, int *dev) { hlist[domain].state = FASTRPC_DOMAIN_STATE_INIT; hlist[domain].ref = 0; pthread_mutex_unlock(&hlist[domain].mut); - VERIFY(AEE_SUCCESS == (nErr = listener_android_domain_init( + VERIFY(AEE_SUCCESS == (nErr = listener_domain_init( domain, hlist[domain].th_params.update_requested, &hlist[domain].th_params.r_sem))); if ((dom != SDSP_DOMAIN_ID) && hlist[domain].dsppd == ROOT_PD) { @@ -4010,7 +4010,7 @@ static void fastrpc_apps_user_deinit(void) { pthread_mutex_destroy(&hlist[i].init); pthread_mutex_destroy(&hlist[i].async_init_deinit_mut); } - listener_android_deinit(); + listener_deinit(); free(hlist); hlist = NULL; } @@ -4116,7 +4116,7 @@ static int fastrpc_apps_user_init(void) { pthread_mutex_init(&hlist[i].init, 0); pthread_mutex_init(&hlist[i].async_init_deinit_mut, 0); } - listener_android_init(); + listener_init(); VERIFY(AEE_SUCCESS == (nErr = PL_INIT(apps_std))); GenCrc32Tab(POLY32, crc_table); fastrpc_notif_init(); diff --git a/src/listener_android.c b/src/listener.c similarity index 97% rename from src/listener_android.c rename to src/listener.c index 712945ce..d86ea888 100644 --- a/src/listener_android.c +++ b/src/listener.c @@ -378,13 +378,13 @@ static void *listener_start_thread(void *arg) { return (void *)(uintptr_t)nErr; } -void listener_android_deinit(void) { +void listener_deinit(void) { HASH_TABLE_CLEANUP(listener_config); PL_DEINIT(mod_table); PL_DEINIT(apps_std); } -int listener_android_init(void) { +int listener_init(void) { int nErr = 0; HASH_TABLE_INIT(listener_config); @@ -401,13 +401,13 @@ int listener_android_init(void) { "adspmsgd_apps", adspmsgd_apps_skel_invoke))); bail: if (nErr != AEE_SUCCESS) { - listener_android_deinit(); + listener_deinit(); VERIFY_EPRINTF("Error %x: fastrpc listener initialization error", nErr); } return nErr; } -void listener_android_domain_deinit(int domain) { +void listener_domain_deinit(int domain) { listener_config *me = NULL; GET_HASH_NODE(listener_config, domain, me); @@ -429,7 +429,7 @@ void listener_android_domain_deinit(int domain) { } } -int listener_android_domain_init(int domain, int update_requested, +int listener_domain_init(int domain, int update_requested, sem_t *r_sem) { listener_config *me = NULL; int nErr = AEE_SUCCESS; @@ -464,7 +464,7 @@ int listener_android_domain_init(int domain, int update_requested, if (nErr != AEE_SUCCESS) { VERIFY_EPRINTF("Error 0x%x: %s failed for domain %d\n", nErr, __func__, domain); - listener_android_domain_deinit(domain); + listener_domain_deinit(domain); } return nErr; } @@ -474,7 +474,7 @@ int close_reverse_handle(remote_handle64 h, char *dlerr, int dlerrorLen, return apps_remotectl_close((uint32_t)h, dlerr, dlerrorLen, dlErr); } -int listener_android_geteventfd(int domain, int *fd) { +int listener_geteventfd(int domain, int *fd) { listener_config *me = NULL; int nErr = 0; @@ -484,11 +484,11 @@ int listener_android_geteventfd(int domain, int *fd) { *fd = me->eventfd; bail: if (nErr != AEE_SUCCESS) { - VERIFY_EPRINTF("Error %x: listener android getevent file descriptor failed " + VERIFY_EPRINTF("Error %x: listener getevent file descriptor failed " "for domain %d\n", nErr, domain); } return nErr; } -PL_DEFINE(listener_android, listener_android_init, listener_android_deinit) +PL_DEFINE(listener, listener_init, listener_deinit) diff --git a/src/pl_list.c b/src/pl_list.c index 97a404a8..d9c1662a 100644 --- a/src/pl_list.c +++ b/src/pl_list.c @@ -4,7 +4,7 @@ #include "platform_libs.h" PL_DEP(gpls) -PL_DEP(listener_android) +PL_DEP(listener) struct platform_lib *(*pl_list[])(void) = {PL_ENTRY(gpls), - PL_ENTRY(listener_android), 0}; + PL_ENTRY(listener), 0}; From e0b0293e530b4ef46fcc396399e28451e5886162 Mon Sep 17 00:00:00 2001 From: Vinayak Katoch Date: Fri, 25 Apr 2025 12:28:52 +0530 Subject: [PATCH 4/5] Clean up unused code, TODO comments, and Android references Remove unused convert_level_to_android_priority() function, TODO comments referencing Android-specific code, and Android include statements. Update AEE_EINVHANDLE comment to remove vendor-specific reference and clean up conditional compilation blocks for Android platforms. Signed-off-by: Vinayak Katoch --- inc/AEEStdErr.h | 2 +- inc/fastrpc_trace.h | 3 --- src/adspmsgd_printf.c | 21 --------------------- src/apps_std_imp.c | 9 +-------- src/fastrpc_apps_user.c | 9 --------- src/fastrpc_mem.c | 9 --------- 6 files changed, 2 insertions(+), 51 deletions(-) diff --git a/inc/AEEStdErr.h b/inc/AEEStdErr.h index 8b7d5ff0..1f022aeb 100644 --- a/inc/AEEStdErr.h +++ b/inc/AEEStdErr.h @@ -84,7 +84,7 @@ #define AEE_EINVALIDITEM (AEE_EOFFSET + 0x02A) ///< Current item is invalid, it can be a switch case or a pointer to memory #define AEE_ENOTALLOWED (AEE_EOFFSET + 0x02B) ///< Not allowed to perform the ///< operation -#define AEE_EINVHANDLE (AEE_EOFFSET + 0x02C) ///< Invalid handle - adding here as its defined in vendor AEEStdErr.h - needed to check valid handle in stub.c +#define AEE_EINVHANDLE (AEE_EOFFSET + 0x02C) ///< Invalid handle - needed to check valid handle in stub.c #define AEE_EOUTOFHANDLES (AEE_EOFFSET + 0x02D) ///< Out of handles (Handle list is already full) //Hole here #define AEE_ENOMORE (AEE_EOFFSET + 0x02F) ///< No more items available -- diff --git a/inc/fastrpc_trace.h b/inc/fastrpc_trace.h index 0f8246b9..e6f0ac6f 100644 --- a/inc/fastrpc_trace.h +++ b/inc/fastrpc_trace.h @@ -4,9 +4,6 @@ #ifndef FASTRPC_TRACE_H #define FASTRPC_TRACE_H -#if ((defined _ANDROID) || (defined ANDROID)) || (defined DISABLE_ATRACE) && !defined(LE_ENABLE) -//TODO: Bharath #include "cutils/trace.h" //for systrace support -#endif #include "HAP_farf.h" //for systrace support diff --git a/src/adspmsgd_printf.c b/src/adspmsgd_printf.c index 787d9c1c..4f734b8a 100644 --- a/src/adspmsgd_printf.c +++ b/src/adspmsgd_printf.c @@ -20,27 +20,6 @@ typedef struct __attribute__((packed)) { char file[LOG_FILENAME_SIZE]; } LogNode; -#if 0 -static inline android_LogPriority convert_level_to_android_priority( - enum adspmsgd_apps_Level level) -{ - switch (level) { - case LOW: - return LOW; - case MEDIUM: - return MEDIUM; - case HIGH: - return HIGH; - case ERROR: - return ERROR; - case FATAL: - return FATAL; - default: - return 0; - } -} -#endif - int adspmsgd_apps_log(const unsigned char *log_message_buffer, int log_message_bufferLen) { LogNode *logMessage = (LogNode *)log_message_buffer; diff --git a/src/apps_std_imp.c b/src/apps_std_imp.c index 7b1068d8..bbb697ce 100644 --- a/src/apps_std_imp.c +++ b/src/apps_std_imp.c @@ -1172,14 +1172,7 @@ __QAIC_IMPL_EXPORT int __QAIC_IMPL(apps_std_fopen_with_env_fd)( VERIFYC(NULL != delim, AEE_EBADPARM); VERIFYC(NULL != name, AEE_EBADPARM); VERIFYC(NULL != envvarname, AEE_EBADPARM); -#if 0 //TODO: Bharath - char *tempName = name; - tempName += 2; - if (tempName[0] == '\0') { - nErr = AEE_EBADPARM; - goto bail; - } -#endif + FASTRPC_ATRACE_BEGIN_L("%s for %s in %s mode from path in environment " "variable %s delimited with %s", __func__, name, mode, envvarname, delim); diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index 2c550f45..74019f5e 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -78,16 +78,7 @@ char DSP_LIBS_LOCATION[PATH_MAX] = DEFAULT_DSP_SEARCH_PATHS; -#ifdef LE_ENABLE -#define PROPERTY_VALUE_MAX \ - 92 // as this macro is defined in cutils for Android platforms, defined - // explicitly for LE platform -#elif (defined _ANDROID) || (defined ANDROID) -/// TODO: Bharath #include "cutils/properties.h" #define PROPERTY_VALUE_MAX 92 -#else -#define PROPERTY_VALUE_MAX 92 -#endif #ifndef _WIN32 #include diff --git a/src/fastrpc_mem.c b/src/fastrpc_mem.c index 8f62fc25..33282420 100644 --- a/src/fastrpc_mem.c +++ b/src/fastrpc_mem.c @@ -41,16 +41,7 @@ #include "shared.h" #include "verify.h" -#ifdef LE_ENABLE -#define PROPERTY_VALUE_MAX \ - 92 // as this macro is defined in cutils for Android platforms, defined - // explicitly for LE platform -#elif (defined _ANDROID) || (defined ANDROID) -// TODO: Bharath #include "cutils/properties.h" #define PROPERTY_VALUE_MAX 92 -#else -#define PROPERTY_VALUE_MAX 92 -#endif #ifndef _WIN32 #include From e4aee3375235d16c48cb9308ee5d3efdbbdcc635 Mon Sep 17 00:00:00 2001 From: Vinayak Katoch Date: Fri, 25 Apr 2025 13:22:40 +0530 Subject: [PATCH 5/5] Move Android property handling to fastrpc_android Create fastrpc_android.h and fastrpc_android.c with Android-specific property handling. Move ANDROIDP_DEBUG_VAR_NAME array and implement platform_get_property_int() and platform_get_property_string(). Remove ANDROID_DEBUG_VAR_NAME array and SYSTEM_RPC_LIBRARY conditional compilation from fastrpc_apps_user.c. Simplify fastrpc_get_property_int() and fastrpc_get_property_string() to call platform functions. Update Makefiles to include fastrpc_android.h and conditionally compile fastrpc_android.c for Android builds. Signed-off-by: Vinayak Katoch --- inc/Makefile.am | 1 + inc/fastrpc_android.h | 17 +++++++++ src/Makefile.am | 2 +- src/fastrpc_android.c | 58 +++++++++++++++++++++++++++++++ src/fastrpc_apps_user.c | 76 +++++------------------------------------ src/fastrpc_log.c | 3 +- 6 files changed, 87 insertions(+), 70 deletions(-) create mode 100644 inc/fastrpc_android.h create mode 100644 src/fastrpc_android.c diff --git a/inc/Makefile.am b/inc/Makefile.am index 5f04dc24..a856399e 100644 --- a/inc/Makefile.am +++ b/inc/Makefile.am @@ -35,6 +35,7 @@ noinst_HEADERS = \ dspqueue_rpc.h \ dspqueue_shared.h \ dspsignal.h \ + fastrpc_android.h \ fastrpc_apps_user.h \ fastrpc_async.h \ fastrpc_cap.h \ diff --git a/inc/fastrpc_android.h b/inc/fastrpc_android.h new file mode 100644 index 00000000..1356aabf --- /dev/null +++ b/inc/fastrpc_android.h @@ -0,0 +1,17 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause-Clear + +#ifndef FASTRPC_ANDROID_H +#define FASTRPC_ANDROID_H + +#include "fastrpc_common.h" + +/* Platform property system functions */ +int property_get_int32(const char *name, int value); +int property_get(const char *name, int *def, int *value); + +/* Platform-specific property getter functions */ +int platform_get_property_int(fastrpc_properties UserPropKey, int defValue); +int platform_get_property_string(fastrpc_properties UserPropKey, char *value, char *defValue); + +#endif /*FASTRPC_ANDROID_H*/ diff --git a/src/Makefile.am b/src/Makefile.am index 6edf2245..1c87ad24 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,7 @@ LIBDSPRPC_SOURCES = \ fastrpc_context.c if ANDROID_CC -# Do nothing (or Android-specific sources) +LIBDSPRPC_SOURCES += fastrpc_android.c else LIBDSPRPC_SOURCES += fastrpc_config_parser.c endif diff --git a/src/fastrpc_android.c b/src/fastrpc_android.c new file mode 100644 index 00000000..53d8e417 --- /dev/null +++ b/src/fastrpc_android.c @@ -0,0 +1,58 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause-Clear + +#include "fastrpc_android.h" +#include "HAP_farf.h" +#include + +#define PROPERTY_VALUE_MAX 92 + +/* Android P (vendor) property names */ +const char *ANDROIDP_DEBUG_VAR_NAME[] = {"vendor.fastrpc.process.attrs", + "vendor.fastrpc.debug.trace", + "vendor.fastrpc.debug.testsig", + "vendor.fastrpc.perf.kernel", + "vendor.fastrpc.perf.adsp", + "vendor.fastrpc.perf.freq", + "vendor.fastrpc.debug.systrace", + "vendor.fastrpc.debug.pddump", + "persist.vendor.fastrpc.process.attrs", + "ro.build.type"}; + +int NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS = + sizeof(ANDROIDP_DEBUG_VAR_NAME) / sizeof(char *); + +/* Stub implementations for property functions - to be implemented with actual Android property API */ +int property_get_int32(const char *name, int value) { + return 0; +} + +int property_get(const char *name, int *def, int *value) { + return 0; +} + +int platform_get_property_int(fastrpc_properties UserPropKey, int defValue) { + if (((int)UserPropKey > NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { + FARF( + ERROR, + "%s: Index %d out-of-bound for ANDROIDP_DEBUG_VAR_NAME array of len %d", + __func__, UserPropKey, NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS); + return defValue; + } + return (int)property_get_int32(ANDROIDP_DEBUG_VAR_NAME[UserPropKey], + defValue); +} + +int platform_get_property_string(fastrpc_properties UserPropKey, char *value, + char *defValue) { + int len = 0; + if (((int)UserPropKey > NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { + FARF( + ERROR, + "%s: Index %d out-of-bound for ANDROIDP_DEBUG_VAR_NAME array of len %d", + __func__, UserPropKey, NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS); + return len; + } + return property_get(ANDROIDP_DEBUG_VAR_NAME[UserPropKey], (int *)value, + (int *)defValue); +} diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index 74019f5e..f32ea57c 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -74,7 +74,12 @@ #include "fastrpc_context.h" #include "fastrpc_process_attributes.h" #include "fastrpc_trace.h" + +#if defined(ANDROID) || defined(_ANDROID) +#include "fastrpc_android.h" +#else #include "fastrpc_config_parser.h" +#endif char DSP_LIBS_LOCATION[PATH_MAX] = DEFAULT_DSP_SEARCH_PATHS; @@ -220,28 +225,7 @@ const char *ENV_DEBUG_VAR_NAME[] = {"FASTRPC_PROCESS_ATTRS", "FASTRPC_PERF_FREQ", "FASTRPC_DEBUG_SYSTRACE", "FASTRPC_DEBUG_PDDUMP", - "FASTRPC_PROCESS_ATTRS_PERSISTENT", - "ro.debuggable"}; -const char *ANDROIDP_DEBUG_VAR_NAME[] = {"vendor.fastrpc.process.attrs", - "vendor.fastrpc.debug.trace", - "vendor.fastrpc.debug.testsig", - "vendor.fastrpc.perf.kernel", - "vendor.fastrpc.perf.adsp", - "vendor.fastrpc.perf.freq", - "vendor.fastrpc.debug.systrace", - "vendor.fastrpc.debug.pddump", - "persist.vendor.fastrpc.process.attrs", - "ro.build.type"}; -const char *ANDROID_DEBUG_VAR_NAME[] = {"fastrpc.process.attrs", - "fastrpc.debug.trace", - "fastrpc.debug.testsig", - "fastrpc.perf.kernel", - "fastrpc.perf.adsp", - "fastrpc.perf.freq", - "fastrpc.debug.systrace", - "fastrpc.debug.pddump", - "persist.fastrpc.process.attrs", - "ro.build.type"}; + "FASTRPC_PROCESS_ATTRS_PERSISTENT"}; const char *SUBSYSTEM_NAME[] = {"adsp", "mdsp", "sdsp", "cdsp", "cdsp1", "gdsp0", "gdsp1", "reserved"}; @@ -255,10 +239,6 @@ static const size_t invoke_end_trace_strlen = sizeof(INVOKE_END_TRACE_STR) - 1; int NO_ENV_DEBUG_VAR_NAME_ARRAY_ELEMENTS = sizeof(ENV_DEBUG_VAR_NAME) / sizeof(char *); -int NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS = - sizeof(ANDROIDP_DEBUG_VAR_NAME) / sizeof(char *); -int NO_ANDROID_DEBUG_VAR_NAME_ARRAY_ELEMENTS = - sizeof(ANDROID_DEBUG_VAR_NAME) / sizeof(char *); /* Shell prefix for signed and unsigned */ const char *const SIGNED_SHELL = "fastrpc_shell_"; @@ -466,10 +446,6 @@ static uint32_t crc32_lut(unsigned char *data, int nbyte, uint32_t *crctab) { return crc; } -int property_get_int32(const char *name, int value) { return 0; } - -int property_get(const char *name, int *def, int *value) { return 0; } - int fastrpc_get_property_int(fastrpc_properties UserPropKey, int defValue) { if (((int)UserPropKey > NO_ENV_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { FARF(ERROR, @@ -481,25 +457,7 @@ int fastrpc_get_property_int(fastrpc_properties UserPropKey, int defValue) { if (env != 0) return (int)atoi(env); #if !defined(LE_ENABLE) // Android platform -#if !defined(SYSTEM_RPC_LIBRARY) // vendor library - if (((int)UserPropKey > NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { - FARF( - ERROR, - "%s: Index %d out-of-bound for ANDROIDP_DEBUG_VAR_NAME array of len %d", - __func__, UserPropKey, NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS); - return defValue; - } - return (int)property_get_int32(ANDROIDP_DEBUG_VAR_NAME[UserPropKey], - defValue); -#else // system library - if (((int)UserPropKey > NO_ANDROID_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { - FARF(ERROR, - "%s: Index %d out-of-bound for ANDROID_DEBUG_VAR_NAME array of len %d", - __func__, UserPropKey, NO_ANDROID_DEBUG_VAR_NAME_ARRAY_ELEMENTS); - return defValue; - } - return (int)property_get_int32(ANDROID_DEBUG_VAR_NAME[UserPropKey], defValue); -#endif + return platform_get_property_int(UserPropKey, defValue); #else // non-Android platforms return defValue; #endif @@ -520,25 +478,7 @@ int fastrpc_get_property_string(fastrpc_properties UserPropKey, char *value, return strlen(env); } #if !defined(LE_ENABLE) // Android platform -#if !defined(SYSTEM_RPC_LIBRARY) // vendor library - if (((int)UserPropKey > NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { - FARF( - ERROR, - "%s: Index %d out-of-bound for ANDROIDP_DEBUG_VAR_NAME array of len %d", - __func__, UserPropKey, NO_ANDROIDP_DEBUG_VAR_NAME_ARRAY_ELEMENTS); - return len; - } - return property_get(ANDROIDP_DEBUG_VAR_NAME[UserPropKey], (int *)value, - (int *)defValue); -#else // system library - if (((int)UserPropKey > NO_ANDROID_DEBUG_VAR_NAME_ARRAY_ELEMENTS)) { - FARF(ERROR, - "%s: Index %d out-of-bound for ANDROID_DEBUG_VAR_NAME array of len %d", - __func__, UserPropKey, NO_ANDROID_DEBUG_VAR_NAME_ARRAY_ELEMENTS); - return len; - } - return property_get(ANDROID_DEBUG_VAR_NAME[UserPropKey], value, defValue); -#endif + return platform_get_property_string(UserPropKey, value, defValue); #else // non-Android platforms if (defValue != NULL) { strncpy(value, defValue, PROPERTY_VALUE_MAX - 1); diff --git a/src/fastrpc_log.c b/src/fastrpc_log.c index de773f4d..a428d551 100644 --- a/src/fastrpc_log.c +++ b/src/fastrpc_log.c @@ -288,7 +288,7 @@ void fastrpc_log_init() { pthread_mutex_lock(&persist_buf.mut); /* * Get build type by reading the target properties, - * if buuid type is eng or userdebug allocate 1 MB persist buf. + * if build type is eng or userdebug allocate 1 MB persist buf. */ if (fastrpc_get_property_string(FASTRPC_BUILD_TYPE, build_type, NULL)) { #if !defined(LE_ENABLE) @@ -300,6 +300,7 @@ void fastrpc_log_init() { debug_build_type = true; #endif } + if (persist_buf.buf == NULL && debug_build_type) { /* Create a debug buffer to append DEBUG FARF level message. */ persist_buf.buf = (char *)rpcmem_alloc_internal(