Revision 3da12676 core/src/aos_system.c
core/src/aos_system.c | ||
---|---|---|
88 | 88 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[]); |
89 | 89 |
static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]); |
90 | 90 |
static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]); |
91 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
92 |
static int _shellcmd_cpuloadcb(BaseSequentialStream* stream, int argc, char* argv[]); |
|
93 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
91 | 94 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
92 | 95 |
static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]); |
93 | 96 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
... | ... | |
111 | 114 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
112 | 115 |
|
113 | 116 |
/** |
117 |
* @brief System shell name. |
|
118 |
*/ |
|
119 |
static const char _shell_name[] = "system shell"; |
|
120 |
|
|
121 |
/** |
|
114 | 122 |
* @brief Shell thread working area. |
115 | 123 |
*/ |
116 | 124 |
static THD_WORKING_AREA(_shell_wa, AMIROOS_CFG_SHELL_STACKSIZE); |
... | ... | |
139 | 147 |
static AOS_SHELL_COMMAND(_shellcmd_shutdown, "module:shutdown", _shellcmd_shutdowncb); |
140 | 148 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
141 | 149 |
|
150 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
151 |
|
|
152 |
/** |
|
153 |
* @brief Shell command to read out CPU load. |
|
154 |
*/ |
|
155 |
static AOS_SHELL_COMMAND(_shellcmd_cpuload, "module:cpuload", _shellcmd_cpuloadcb); |
|
156 |
|
|
157 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
158 |
|
|
142 | 159 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
143 | 160 |
|
144 | 161 |
/** |
145 |
* @brief Shell kommand to run a test of the ChibiOS/RT kernel.
|
|
162 |
* @brief Shell command to run a test of the ChibiOS/RT kernel.
|
|
146 | 163 |
*/ |
147 | 164 |
static AOS_SHELL_COMMAND(_shellcmd_kerneltest, "kernel:test", _shellcmd_kerneltestcb); |
148 | 165 |
|
... | ... | |
238 | 255 |
_printSystemInfoLine(stream, "Core Variant", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_CORE_VARIANT_NAME); |
239 | 256 |
#endif /* defined(PORT_CORE_VARIANT_NAME) */ |
240 | 257 |
_printSystemInfoLine(stream, "Architecture", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_ARCHITECTURE_NAME); |
258 |
_printSystemInfoLine(stream, "Core Frequency", SYSTEM_INFO_NAMEWIDTH, "%u MHz", SystemCoreClock / 1000000); |
|
241 | 259 |
_printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH); |
242 | 260 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) |
243 | 261 |
_printSystemInfoLine(stream, "AMiRo-OS" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (SSSP %u.%u)", AMIROOS_VERSION_MAJOR, AMIROOS_VERSION_MINOR, AMIROOS_VERSION_PATCH, AMIROOS_RELEASE_TYPE, AOS_SSSP_VERSION_MAJOR, AOS_SSSP_VERSION_MINOR); |
... | ... | |
622 | 640 |
#endif /* (AMIROOS_CFG_BOOTLOADER == X) */ |
623 | 641 |
} |
624 | 642 |
|
643 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
644 |
|
|
645 |
/** |
|
646 |
* @brief Callback function for the module:cpuload shell command. |
|
647 |
* |
|
648 |
* @param[in] stream The I/O stream to use. |
|
649 |
* @param[in] argc Number of arguments. |
|
650 |
* @param[in] argv List of pointers to arguments. |
|
651 |
* |
|
652 |
* @return An exit status. |
|
653 |
*/ |
|
654 |
static int _shellcmd_cpuloadcb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
655 |
{ |
|
656 |
aosDbgCheck(stream != NULL); |
|
657 |
|
|
658 |
(void)argc; |
|
659 |
(void)argv; |
|
660 |
|
|
661 |
// local variables |
|
662 |
rttime_t sum = 0; |
|
663 |
thread_t* thd = chRegFirstThread(); |
|
664 |
|
|
665 |
// accumulate system load |
|
666 |
do { |
|
667 |
sum += thd->stats.cumulative; |
|
668 |
thd = chRegNextThread(thd); |
|
669 |
} while (thd); |
|
670 |
sum += ch.kernel_stats.m_crit_thd.cumulative + ch.kernel_stats.m_crit_isr.cumulative; |
|
671 |
|
|
672 |
// calculate and retreive cpu load per thread |
|
673 |
chprintf(stream, "threads & critical zones:\n"); |
|
674 |
thd = chRegFirstThread(); |
|
675 |
do { |
|
676 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
|
677 |
(thd->name != NULL) ? thd->name : "<unnamed thread>", |
|
678 |
(float)thd->stats.cumulative / (float)sum * 100.f); |
|
679 |
thd = chRegNextThread(thd); |
|
680 |
} while (thd); |
|
681 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
|
682 |
"thread critical zones", |
|
683 |
(float)ch.kernel_stats.m_crit_thd.cumulative / (float)sum * 100.f); |
|
684 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
|
685 |
"ISR critical zones", |
|
686 |
(float)ch.kernel_stats.m_crit_isr.cumulative / (float)sum * 100.f); |
|
687 |
|
|
688 |
// retreive further real-time statistics |
|
689 |
chprintf(stream, "\nworst critical zones:\n"); |
|
690 |
chprintf(stream, "\tthreads: %uus (%u clocks @ %uMHz)\n", |
|
691 |
RTC2US(SystemCoreClock, ch.kernel_stats.m_crit_thd.worst), |
|
692 |
ch.kernel_stats.m_crit_thd.worst, |
|
693 |
SystemCoreClock / 1000000); |
|
694 |
chprintf(stream, "\t ISRs: %uus (%u clocks @ %uMHz)\n", |
|
695 |
RTC2US(SystemCoreClock, ch.kernel_stats.m_crit_isr.worst), |
|
696 |
ch.kernel_stats.m_crit_isr.worst, |
|
697 |
SystemCoreClock / 1000000); |
|
698 |
|
|
699 |
return 0; |
|
700 |
} |
|
701 |
|
|
702 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
703 |
|
|
625 | 704 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
626 | 705 |
|
627 | 706 |
/** |
... | ... | |
750 | 829 |
|
751 | 830 |
/* init shell */ |
752 | 831 |
aosShellInit(&aos.shell, |
832 |
_shell_name, |
|
753 | 833 |
shellPrompt, |
754 | 834 |
_shell_buffer, |
755 | 835 |
SYSTEM_SHELL_BUFFERENTRIES, |
... | ... | |
759 | 839 |
aosShellAddCommand(&aos.shell, &_shellcmd_config); |
760 | 840 |
aosShellAddCommand(&aos.shell, &_shellcmd_info); |
761 | 841 |
aosShellAddCommand(&aos.shell, &_shellcmd_shutdown); |
842 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
843 |
aosShellAddCommand(&aos.shell, &_shellcmd_cpuload); |
|
844 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
762 | 845 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) |
763 | 846 |
aosShellAddCommand(&aos.shell, &_shellcmd_kerneltest); |
764 | 847 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
Also available in: Unified diff