[Cryptech-Commits] [sw/stm32] 01/02: Report SDRAM usage in `task show`

git at cryptech.is git at cryptech.is
Mon Apr 1 00:59:48 UTC 2019


This is an automated email from the git hooks/post-receive script.

paul at psgd.org pushed a commit to branch master
in repository sw/stm32.

commit 73c911dfe407027c1822ac4745405ff22d446c66
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Thu Feb 28 15:01:12 2019 -0500

    Report SDRAM usage in `task show`
---
 projects/hsm/hsm.c       | 11 +++++++++++
 projects/hsm/mgmt-task.c |  6 ++++++
 2 files changed, 17 insertions(+)

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;
 }
 



More information about the Commits mailing list