|
34 | 34 |
|
35 | 35 | typedef int (*dsp_default_listener_start_t)(int argc, char *argv[]); |
36 | 36 |
|
| 37 | +/** |
| 38 | + * Prints help information about the daemon. |
| 39 | + */ |
| 40 | +static void print_help(const char *program_name, const char *dsp_name) { |
| 41 | + printf("Usage: %s [OPTIONS]\n\n", program_name); |
| 42 | + printf("Description:\n"); |
| 43 | + printf(" %s is a daemon that establishes a connection to the guest PD\n", program_name); |
| 44 | + printf(" (Process Domain) on the %s, functioning similarly to the root\n", dsp_name); |
| 45 | + printf(" process in Linux.\n\n"); |
| 46 | + printf("Functionality:\n"); |
| 47 | + printf(" - DSP Process Exception Logs:\n"); |
| 48 | + printf(" Facilitates transfer of %s process exception logs to the HLOS\n", dsp_name); |
| 49 | + printf(" (High-Level Operating System) logging infrastructure for effective\n"); |
| 50 | + printf(" monitoring and debugging.\n\n"); |
| 51 | + printf(" - Fastrpc Shell File Execution:\n"); |
| 52 | + printf(" Enables execution of fastrpc shell file (executable file that runs\n"); |
| 53 | + printf(" as a process on the %s). When applications offload tasks to the %s\n", dsp_name, dsp_name); |
| 54 | + printf(" but cannot access shell file directly, the daemon reads the shell\n"); |
| 55 | + printf(" file from the HLOS file system and creates the necessary process on\n"); |
| 56 | + printf(" the %s.\n\n", dsp_name); |
| 57 | + printf(" Shell file naming format:\n"); |
| 58 | +#ifdef USE_ADSP |
| 59 | + printf(" - Signed: fastrpc_shell_<domain_id> (ADSP supports signed only)\n\n"); |
| 60 | +#elif defined(USE_SDSP) |
| 61 | + printf(" - Signed: fastrpc_shell_<domain_id> (SDSP supports signed only)\n\n"); |
| 62 | +#elif defined(USE_CDSP) |
| 63 | + printf(" - Signed: fastrpc_shell_<domain_id>\n"); |
| 64 | + printf(" - Unsigned: fastrpc_shell_unsigned_<domain_id>\n\n"); |
| 65 | +#elif defined(USE_GDSP) |
| 66 | + printf(" - Signed: fastrpc_shell_<domain_id>\n"); |
| 67 | + printf(" - Unsigned: fastrpc_shell_unsigned_<domain_id>\n\n"); |
| 68 | +#endif |
| 69 | + printf("Options:\n"); |
| 70 | + printf(" -h, --help Display this help message and exit\n"); |
| 71 | + printf(" <pd_name> <domain> Start daemon for specific PD and domain\n"); |
| 72 | +#ifdef USE_ADSP |
| 73 | + printf(" Example: %s audiopd adsp\n", program_name); |
| 74 | +#elif defined(USE_SDSP) |
| 75 | + printf(" Example: %s rootpd sdsp\n", program_name); |
| 76 | +#elif defined(USE_CDSP) |
| 77 | + printf(" Example: %s rootpd cdsp (or cdsp1)\n", program_name); |
| 78 | +#elif defined(USE_GDSP) |
| 79 | + printf(" Example: %s rootpd gdsp0 (or gdsp1)\n", program_name); |
| 80 | +#endif |
| 81 | + printf(" <pd_name> Start daemon for specific PD (uses default domain)\n"); |
| 82 | +#ifdef USE_ADSP |
| 83 | + printf(" Example: %s audiopd\n", program_name); |
| 84 | +#else |
| 85 | + printf(" Example: %s rootpd\n", program_name); |
| 86 | +#endif |
| 87 | + printf(" (no arguments) Start daemon for root PD (default/guest OS)\n\n"); |
| 88 | + printf("Notes:\n"); |
| 89 | + printf(" - This daemon runs continuously and automatically restarts on errors\n"); |
| 90 | + printf(" - It exits only when the fastRPC device node is not accessible\n\n"); |
| 91 | +} |
| 92 | + |
37 | 93 | // Result struct for dlopen. |
38 | 94 | struct dlopen_result { |
39 | 95 | void *handle; |
@@ -93,6 +149,15 @@ int main(int argc, char *argv[]) { |
93 | 149 | #else |
94 | 150 | goto bail; |
95 | 151 | #endif |
| 152 | + |
| 153 | + // Check for help flag |
| 154 | + if (argc > 1) { |
| 155 | + if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { |
| 156 | + print_help(argv[0], dsp_name); |
| 157 | + return 0; |
| 158 | + } |
| 159 | + } |
| 160 | + |
96 | 161 | VERIFY_EPRINTF("%s daemon starting", dsp_name); |
97 | 162 |
|
98 | 163 | while (1) { |
|
0 commit comments