diff --git a/src/dsprpcd.c b/src/dsprpcd.c index 348049a6..48ad70d3 100644 --- a/src/dsprpcd.c +++ b/src/dsprpcd.c @@ -34,6 +34,62 @@ typedef int (*dsp_default_listener_start_t)(int argc, char *argv[]); +/** + * Prints help information about the daemon. + */ +static void print_help(const char *program_name, const char *dsp_name) { + printf("Usage: %s [OPTIONS]\n\n", program_name); + printf("Description:\n"); + printf(" %s is a daemon that establishes a connection to the guest PD\n", program_name); + printf(" (Process Domain) on the %s, functioning similarly to the root\n", dsp_name); + printf(" process in Linux.\n\n"); + printf("Functionality:\n"); + printf(" - DSP Process Exception Logs:\n"); + printf(" Facilitates transfer of %s process exception logs to the HLOS\n", dsp_name); + printf(" (High-Level Operating System) logging infrastructure for effective\n"); + printf(" monitoring and debugging.\n\n"); + printf(" - Fastrpc Shell File Execution:\n"); + printf(" Enables execution of fastrpc shell file (executable file that runs\n"); + printf(" as a process on the %s). When applications offload tasks to the %s\n", dsp_name, dsp_name); + printf(" but cannot access shell file directly, the daemon reads the shell\n"); + printf(" file from the HLOS file system and creates the necessary process on\n"); + printf(" the %s.\n\n", dsp_name); + printf(" Shell file naming format:\n"); +#ifdef USE_ADSP + printf(" - Signed: fastrpc_shell_ (ADSP supports signed only)\n\n"); +#elif defined(USE_SDSP) + printf(" - Signed: fastrpc_shell_ (SDSP supports signed only)\n\n"); +#elif defined(USE_CDSP) + printf(" - Signed: fastrpc_shell_\n"); + printf(" - Unsigned: fastrpc_shell_unsigned_\n\n"); +#elif defined(USE_GDSP) + printf(" - Signed: fastrpc_shell_\n"); + printf(" - Unsigned: fastrpc_shell_unsigned_\n\n"); +#endif + printf("Options:\n"); + printf(" -h, --help Display this help message and exit\n"); + printf(" Start daemon for specific PD and domain\n"); +#ifdef USE_ADSP + printf(" Example: %s audiopd adsp\n", program_name); +#elif defined(USE_SDSP) + printf(" Example: %s rootpd sdsp\n", program_name); +#elif defined(USE_CDSP) + printf(" Example: %s rootpd cdsp (or cdsp1)\n", program_name); +#elif defined(USE_GDSP) + printf(" Example: %s rootpd gdsp0 (or gdsp1)\n", program_name); +#endif + printf(" Start daemon for specific PD (uses default domain)\n"); +#ifdef USE_ADSP + printf(" Example: %s audiopd\n", program_name); +#else + printf(" Example: %s rootpd\n", program_name); +#endif + printf(" (no arguments) Start daemon for root PD (default/guest OS)\n\n"); + printf("Notes:\n"); + printf(" - This daemon runs continuously and automatically restarts on errors\n"); + printf(" - It exits only when the fastRPC device node is not accessible\n\n"); +} + // Result struct for dlopen. struct dlopen_result { void *handle; @@ -93,6 +149,15 @@ int main(int argc, char *argv[]) { #else goto bail; #endif + + // Check for help flag + if (argc > 1) { + if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { + print_help(argv[0], dsp_name); + return 0; + } + } + VERIFY_EPRINTF("%s daemon starting", dsp_name); while (1) {