File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <stdio.h>
0037 #include <stdlib.h>
0038 #include <string.h>
0039 #include <errno.h>
0040
0041 #include <rtems.h>
0042 #include <rtems/shell.h>
0043 #include <rtems/version.h>
0044
0045 static void kernel_summary(void) {
0046 printf(
0047 "RTEMS: %d.%d.%d",
0048 rtems_version_major(), rtems_version_minor(), rtems_version_revision());
0049 if (rtems_version_release_label_is_valid()) {
0050 printf(" (%s)", rtems_version_release_label());
0051 }
0052 #if RTEMS_SMP
0053 printf(" SMP:%d cores", rtems_scheduler_get_processor_maximum());
0054 #endif
0055 printf("\n");
0056 }
0057
0058 static void cpu_summary(void) {
0059 printf("CPU: " CPU_NAME " (" CPU_MODEL_NAME ")\n");
0060 }
0061
0062 static void bsp_summary(void) {
0063 printf("BSP: %s\n", rtems_board_support_package());
0064 }
0065
0066 static void tools_summary(void) {
0067 printf( "Tools: " __VERSION__ "\n");
0068 }
0069
0070 static void opts_summary(void) {
0071 printf("Options:"
0072 #if RTEMS_DEBUG
0073 " DEBUG"
0074 #endif
0075 #if RTEMS_MULTIPROCESSING
0076 " MULTIPROCESSING"
0077 #endif
0078 #if RTEMS_NETWORKING
0079 " NETWORKING"
0080 #endif
0081 #if RTEMS_PARAVIRT
0082 " PARAVIRT"
0083 #endif
0084 #if RTEMS_POSIX_API
0085 " POSIX"
0086 #endif
0087 #if RTEMS_PROFILING
0088 " PROFILING"
0089 #endif
0090 #if RTEMS_SMP
0091 " SMP"
0092 #endif
0093 "\n");
0094 }
0095
0096 static void help(void) {
0097 printf( "Usage:: rtems <command>\n");
0098 printf( " where <command> is:\n");
0099 printf( " help : this help\n");
0100 printf( " ver : kernel version\n");
0101 printf( " cpu : kernel version\n");
0102 printf( " bsp : BSP name\n");
0103 printf( " tools : tools version\n");
0104 printf( " opts : options\n");
0105 printf( " all : all commands\n");
0106 }
0107
0108 static int rtems_shell_main_rtems(
0109 int argc, char *argv[]) {
0110
0111 if (argc == 1) {
0112 kernel_summary();
0113 } else if (argc == 2) {
0114 if (strcmp(argv[1], "help") == 0) {
0115 help();
0116 } else if (strcmp(argv[1], "ver") == 0) {
0117 kernel_summary();
0118 } else if (strcmp(argv[1], "cpu") == 0) {
0119 cpu_summary();
0120 } else if (strcmp(argv[1], "bsp") == 0) {
0121 bsp_summary();
0122 } else if (strcmp(argv[1], "tools") == 0) {
0123 tools_summary();
0124 } else if (strcmp(argv[1], "opts") == 0) {
0125 opts_summary();
0126 } else if (strcmp(argv[1], "all") == 0) {
0127 kernel_summary();
0128 cpu_summary();
0129 bsp_summary();
0130 tools_summary();
0131 opts_summary();
0132 } else {
0133 printf("error: invalid command; try `help`\n");
0134 return 1;
0135 }
0136 } else {
0137 printf("error: invalid command; try `help`\n");
0138 return 1;
0139 }
0140 return 0;
0141 }
0142
0143 #define HELP_LINE \
0144 "rtems <command> (eg. help)"
0145
0146 rtems_shell_cmd_t rtems_shell_RTEMS_Command = {
0147 "rtems",
0148 HELP_LINE,
0149 "rtems",
0150 rtems_shell_main_rtems,
0151 NULL,
0152 NULL,
0153 0500,
0154 0,
0155 0
0156 };