[Cryptech-Commits] [sw/libhal] 02/03: Reset table of cores, e.g. after resetting FPGA from CLI.

git at cryptech.is git at cryptech.is
Tue Aug 23 16:36:32 UTC 2016


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/libhal.

commit 99b022abb09ffd17fc54b4e479086444f0eeb79f
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Wed Aug 10 17:56:37 2016 -0400

    Reset table of cores, e.g. after resetting FPGA from CLI.
---
 core.c | 18 ++++++++++++++++--
 hal.h  |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/core.c b/core.c
index 3c840d4..378f085 100644
--- a/core.c
+++ b/core.c
@@ -93,10 +93,10 @@ static const struct { const char *name; hal_addr_t extra; } gaps[] = {
   { "modexpa7", 3 * CORE_SIZE }, /* ModexpA7 uses four slots */
 };
 
+static hal_core_t *head = NULL;
+
 static hal_core_t *probe_cores(void)
 {
-  static hal_core_t *head = NULL;
-
   if (head != NULL)
     return head;
 
@@ -167,6 +167,20 @@ static hal_core_t *probe_cores(void)
   return NULL;
 }
 
+void hal_core_reset_table(void)
+{
+#if HAL_STATIC_CORE_STATE_BLOCKS > 0
+    head = NULL;
+    memset(core_table, 0, sizeof(core_table));
+#else
+    while (head != NULL) {
+        hal_core_t *next = head->next;
+        free(head);
+        head = next;
+    }
+#endif
+}
+
 hal_core_t * hal_core_iterate(hal_core_t *core)
 {
   return core == NULL ? probe_cores() : core->next;
diff --git a/hal.h b/hal.h
index 04333b9..9d5a32b 100644
--- a/hal.h
+++ b/hal.h
@@ -209,6 +209,7 @@ extern hal_core_t *hal_core_find(const char *name, hal_core_t *core);
 extern const hal_core_info_t *hal_core_info(const hal_core_t *core);
 extern hal_addr_t hal_core_base(const hal_core_t *core);
 extern hal_core_t * hal_core_iterate(hal_core_t *core);
+extern void hal_core_reset_table(void);
 extern hal_error_t hal_core_alloc(const char *name, hal_core_t **core);
 extern void hal_core_free(hal_core_t *core);
 extern void hal_critical_section_start(void);



More information about the Commits mailing list