From 73c911dfe407027c1822ac4745405ff22d446c66 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Thu, 28 Feb 2019 15:01:12 -0500 Subject: Report SDRAM usage in `task show` --- projects/hsm/hsm.c | 11 +++++++++++ projects/hsm/mgmt-task.c | 6 ++++++ 2 files changed, 17 insertions(+) (limited to 'projects') diff --git a/projects/hsm/hsm.c b/projects/hsm/hsm.c index a34b1f7..c1ab691 100644 --- a/projects/hsm/hsm.c +++ b/projects/hsm/hsm.c @@ -395,6 +395,17 @@ static hal_error_t sdram_free(uint8_t *ptr) return HAL_ERROR_FORBIDDEN; } +hal_error_t sdram_stats(size_t *used, size_t *available) +{ + if (used == NULL || available == NULL) + return HAL_ERROR_BAD_ARGUMENTS; + + *used = sdram_heap - &_esdram1; + *available = &__end_sdram1 - sdram_heap; + + return LIBHAL_OK; +} + /* Implement static memory allocation for libhal over sdram_malloc(). */ void *hal_allocate_static_memory(const size_t size) diff --git a/projects/hsm/mgmt-task.c b/projects/hsm/mgmt-task.c index c2a3d3f..180c6d9 100644 --- a/projects/hsm/mgmt-task.c +++ b/projects/hsm/mgmt-task.c @@ -74,6 +74,12 @@ static int cmd_task_show(struct cli_def *cli, const char *command, char *argv[], cli_print(cli, " "); cli_print(cli, "UART receive queue maximum length: %u", uart_rx_max); + size_t used, available; + extern void sdram_stats(size_t *used, size_t *available); + sdram_stats(&used, &available); + cli_print(cli, " "); + cli_print(cli, "SDRAM used: %u, available: %u", used, available); + return CLI_OK; } -- cgit v1.2.3