Revision aed3754b
| core/inc/aos_shell.h | ||
|---|---|---|
| 31 | 31 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
| 32 | 32 |
#include <hal.h> |
| 33 | 33 |
#include <aos_types.h> |
| 34 |
#include <aos_debug.h> |
|
| 34 | 35 |
|
| 35 | 36 |
/** |
| 36 | 37 |
* @brief Shell event flag that is emitted when the thread starts. |
| ... | ... | |
| 358 | 359 |
void aosShellChannelInit(AosShellChannel* channel, BaseAsynchronousChannel* asyncchannel); |
| 359 | 360 |
aos_status_t aosShellAddCommand(aos_shell_t* shell, aos_shellcommand_t* cmd); |
| 360 | 361 |
aos_status_t aosShellRemoveCommand(aos_shell_t* shell, char* cmd, aos_shellcommand_t** removed); |
| 362 |
unsigned int aosShellCountCommands(aos_shell_t* shell); |
|
| 361 | 363 |
void aosShellStreamAddChannel(AosShellStream* stream, AosShellChannel* channel); |
| 362 | 364 |
aos_status_t aosShellStreamRemoveChannel(AosShellStream* stream, AosShellChannel* channel); |
| 363 | 365 |
void aosShellChannelInputEnable(AosShellChannel* channel); |
| core/inc/aos_thread.h | ||
|---|---|---|
| 99 | 99 |
extern "C" {
|
| 100 | 100 |
#endif |
| 101 | 101 |
void aosThdSleepUntilS(const aos_timestamp_t* t); |
| 102 |
#if (CH_DBG_FILL_THREADS == TRUE) |
|
| 103 |
size_t aosThdGetStackPeakUtilization(thread_t* thread); |
|
| 104 |
#endif |
|
| 102 | 105 |
#ifdef __cplusplus |
| 103 | 106 |
} |
| 104 | 107 |
#endif |
| ... | ... | |
| 237 | 240 |
return; |
| 238 | 241 |
} |
| 239 | 242 |
|
| 243 |
/** |
|
| 244 |
* @brief Retrieve the stack size of a specific thread in bytes. |
|
| 245 |
* |
|
| 246 |
* @param[in] thread Thread to retrieve the stack size from. |
|
| 247 |
* |
|
| 248 |
* @return Absolute stack size in bytes. |
|
| 249 |
*/ |
|
| 250 |
static inline size_t aosThdGetStacksize(thread_t* thread) |
|
| 251 |
{
|
|
| 252 |
aosDbgCheck(thread != NULL); |
|
| 253 |
|
|
| 254 |
/* |
|
| 255 |
* Working area is structured like: |
|
| 256 |
* thread.wabase (LSB)->[ stack | port specific data | thread structure ] |
|
| 257 |
* See the following macros for details: |
|
| 258 |
* - THD_WORKING_AREA |
|
| 259 |
* - THD_WORKING_AREA_SIZE |
|
| 260 |
* - PORT_WA_SIZE |
|
| 261 |
*/ |
|
| 262 |
return ((uintptr_t)(thread) - (uintptr_t)(thread->wabase)) - |
|
| 263 |
((size_t)PORT_GUARD_PAGE_SIZE + sizeof(struct port_intctx) + sizeof(struct port_extctx) + (size_t)PORT_INT_REQUIRED_STACK); |
|
| 264 |
} |
|
| 265 |
|
|
| 240 | 266 |
#endif /* _AMIROOS_THREAD_H_ */ |
| 241 | 267 |
|
| 242 | 268 |
/** @} */ |
| core/src/aos_shell.c | ||
|---|---|---|
| 1278 | 1278 |
} |
| 1279 | 1279 |
|
| 1280 | 1280 |
/** |
| 1281 |
* @brief Count the number of commands assigned to the shell. |
|
| 1282 |
* |
|
| 1283 |
* @param[in] shell The shell to count the commands for. |
|
| 1284 |
* |
|
| 1285 |
* @return The number of commands associated to the shell. |
|
| 1286 |
*/ |
|
| 1287 |
unsigned int aosShellCountCommands(aos_shell_t* shell) |
|
| 1288 |
{
|
|
| 1289 |
aosDbgCheck(shell != NULL); |
|
| 1290 |
|
|
| 1291 |
unsigned int count = 0; |
|
| 1292 |
aos_shellcommand_t* cmd = shell->commands; |
|
| 1293 |
while (cmd != NULL) {
|
|
| 1294 |
++count; |
|
| 1295 |
cmd = cmd->next; |
|
| 1296 |
} |
|
| 1297 |
|
|
| 1298 |
return count; |
|
| 1299 |
} |
|
| 1300 |
|
|
| 1301 |
/** |
|
| 1281 | 1302 |
* @brief Add a channel to a AosShellStream. |
| 1282 | 1303 |
* |
| 1283 | 1304 |
* @param[in] stream The AosShellStream to extend. |
| ... | ... | |
| 1303 | 1324 |
* |
| 1304 | 1325 |
* @param[in] stream The AosShellStream to modify. |
| 1305 | 1326 |
* @param[in] channel The channel to remove. |
| 1306 |
* @return |
|
| 1327 |
* |
|
| 1328 |
* @return A status value. |
|
| 1329 |
* @retval AOS_SUCCESS The channel was removed successfully. |
|
| 1330 |
* @retval AOS_ERROR The specified channel was not found to be associated with the shell. |
|
| 1307 | 1331 |
*/ |
| 1308 | 1332 |
aos_status_t aosShellStreamRemoveChannel(AosShellStream* stream, AosShellChannel* channel) |
| 1309 | 1333 |
{
|
| core/src/aos_system.c | ||
|---|---|---|
| 59 | 59 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 60 | 60 |
static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 61 | 61 |
static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 62 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */ |
|
| 63 | 62 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) |
| 64 | 63 |
static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 65 | 64 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
| 65 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */ |
|
| 66 | 66 |
|
| 67 | 67 |
/** |
| 68 | 68 |
* @brief Timer to accumulate system uptime. |
| ... | ... | |
| 498 | 498 |
chprintf(stream, "%10u microseconds\n", (uint16_t)(uptime % MICROSECONDS_PER_MILLISECOND / MICROSECONDS_PER_MICROSECOND)); |
| 499 | 499 |
#if (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) |
| 500 | 500 |
chprintf(stream, "SSSP synchronization offset: %.3fus per %uus\n", _syssyncskew, AMIROOS_CFG_SSSP_SYSSYNCPERIOD); |
| 501 |
#endif |
|
| 501 |
#endif /* AMIROOS_CFG_SSSP_MASTER != true && AMIROOS_CFG_PROFILE == true */
|
|
| 502 | 502 |
_printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH); |
| 503 | 503 |
|
| 504 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
|
| 505 |
// print shell info |
|
| 506 |
chprintf(stream, "System shell information:\n"); |
|
| 507 |
chprintf(stream, "\tnumber of commands: %u\n", aosShellCountCommands(&aos.shell)); |
|
| 508 |
chprintf(stream, "\tmaximum line width: %u characters\n", aos.shell.linesize); |
|
| 509 |
chprintf(stream, "\tmaximum #arguments: %u\n", aos.shell.arglistsize); |
|
| 510 |
chprintf(stream, "\tshell thread stack size: %u bytes\n", aosThdGetStacksize(aos.shell.thread)); |
|
| 511 |
#if (CH_DBG_FILL_THREADS == TRUE) |
|
| 512 |
chprintf(stream, "\tstack peak utilization: %u bytes (%.2f%%)\n", aosThdGetStackPeakUtilization(aos.shell.thread), (float)aosThdGetStackPeakUtilization(aos.shell.thread) / (float)aosThdGetStacksize(aos.shell.thread) * 100.0f); |
|
| 513 |
#endif /* CH_DBG_FILL_THREADS == TRUE */ |
|
| 514 |
_printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH); |
|
| 515 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */ |
|
| 516 |
|
|
| 504 | 517 |
return AOS_OK; |
| 505 | 518 |
} |
| 506 | 519 |
|
| ... | ... | |
| 567 | 580 |
} |
| 568 | 581 |
} |
| 569 | 582 |
} |
| 570 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */ |
|
| 571 | 583 |
|
| 572 | 584 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 573 | 585 |
/** |
| ... | ... | |
| 591 | 603 |
return retval; |
| 592 | 604 |
} |
| 593 | 605 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
| 606 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */ |
|
| 594 | 607 |
|
| 595 | 608 |
/** |
| 596 | 609 |
* @brief Generic callback function for GPIO interrupts. |
| core/src/aos_thread.c | ||
|---|---|---|
| 57 | 57 |
return; |
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 |
#if (CH_DBG_FILL_THREADS == TRUE) || defined(__DOXYGEN__) |
|
| 61 |
/** |
|
| 62 |
* @brief Calculate the peak stack utilization for a specific thread so far in bytes. |
|
| 63 |
* |
|
| 64 |
* @param[in] thread Thread to calculate the stack utilization for. |
|
| 65 |
* |
|
| 66 |
* @return Absolute peak stack utilization in bytes. |
|
| 67 |
*/ |
|
| 68 |
size_t aosThdGetStackPeakUtilization(thread_t* thread) |
|
| 69 |
{
|
|
| 70 |
aosDbgCheck(thread != NULL); |
|
| 71 |
|
|
| 72 |
size_t util; |
|
| 73 |
uint8_t* ptr = (uint8_t*)thread->wabase; |
|
| 74 |
|
|
| 75 |
chSysLock(); |
|
| 76 |
while (*ptr == CH_DBG_STACK_FILL_VALUE && ptr < (uint8_t*)thread->wabase + aosThdGetStacksize(thread)) {
|
|
| 77 |
++ptr; |
|
| 78 |
} |
|
| 79 |
util = aosThdGetStacksize(thread) - (ptr - (uint8_t*)thread->wabase); |
|
| 80 |
chSysUnlock(); |
|
| 81 |
|
|
| 82 |
return util; |
|
| 83 |
} |
|
| 84 |
#endif /* CH_DBG_FILL_THREADS == TRUE */ |
|
| 85 |
|
|
| 60 | 86 |
/** @} */ |
Also available in: Unified diff