You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/08/18 19:48:35 UTC

[GitHub] [mynewt-core] utzig commented on a change in pull request #2664: Updates to the kinetis TRNG driver

utzig commented on a change in pull request #2664:
URL: https://github.com/apache/mynewt-core/pull/2664#discussion_r691555555



##########
File path: hw/drivers/trng/trng_kinetis/src/trng_kinetis.c
##########
@@ -35,88 +35,138 @@
     do {                                                              \
         (base)->MCTL |= (TRNG_MCTL_PRGM_MASK | TRNG_MCTL_ERR_MASK);   \
     } while (0)
+#define TRNG_CLEAR_AND_ENABLE_INTS(base)                              \
+    do {                                                              \
+        (base)->INT_CTRL &= ~(TRNG_INT_CTRL_HW_ERR_MASK |             \
+                              TRNG_INT_CTRL_ENT_VAL_MASK);            \
+        (base)->INT_MASK |= TRNG_INT_MASK_HW_ERR_MASK |               \
+                            TRNG_INT_MASK_ENT_VAL_MASK;               \
+    } while (0)
+#define TRNG_CLEAR_AND_ENABLE_ENTROPY_INT(base)                       \
+    do {                                                              \
+        (base)->INT_CTRL &= ~TRNG_INT_CTRL_ENT_VAL_MASK;              \
+        (base)->INT_MASK |= TRNG_INT_MASK_ENT_VAL_MASK;               \
+    } while (0)
+#define TRNG_DISABLE_ENTROPY_INT(base)                                \
+    do {                                                              \
+        (base)->INT_MASK &= ~TRNG_INT_MASK_ENT_VAL_MASK;              \
+    } while (0)
 #else
 #error "Unsupported TRNG interface"
 #endif
 
 #include "trng/trng.h"
 #include "trng_kinetis/trng_kinetis.h"
 
-static uint8_t rng_cache[ MYNEWT_VAL(KINETIS_TRNG_CACHE_LEN) ];
-static uint16_t rng_cache_out;
-static uint16_t rng_cache_in;
-static struct os_mutex rng_cache_mu;
-static os_stack_t *pstack;
+#define TRNG_CACHE_LEN MYNEWT_VAL(KINETIS_TRNG_CACHE_LEN)
+static struct {
+    uint8_t cache[TRNG_CACHE_LEN];
+    uint16_t out;
+    uint16_t in;
+    uint16_t used;
+    struct os_mutex mu;

Review comment:
       I moved it to the end.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org