[Cryptech-Commits] [sw/libhal] 03/03: Clean out debugging code (flash I/O ring log).

git at cryptech.is git at cryptech.is
Tue Nov 1 17:41:04 UTC 2016


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

sra at hactrn.net pushed a commit to branch ksng
in repository sw/libhal.

commit e2793cfe01ca0ff16ecf8c211106526b13268976
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Tue Nov 1 13:40:02 2016 -0400

    Clean out debugging code (flash I/O ring log).
---
 ks_flash.c | 48 ------------------------------------------------
 1 file changed, 48 deletions(-)

diff --git a/ks_flash.c b/ks_flash.c
index c12aad4..e4d82ff 100644
--- a/ks_flash.c
+++ b/ks_flash.c
@@ -46,34 +46,6 @@
 #include "stm-keystore.h"
 #undef HAL_OK
 
-#if 1 /* XXX Begin temporary debugging kludge */
-#warning Temporary debugging kludge, remove this
-
-/*
- * Chasing what might be a race condition, except it's a bit too
- * predictable.  Debugger breakpoint or 0.1 second delay is enough to
- * hide it, so need something simple.  So try a simple ring buffer
- * logging block numbers and actions.
- */
-
-static unsigned debug_ring_counter = 0;
-
-static struct {
-  char code;                    /* One letter code describing action */
-  unsigned blockno;             /* Block number */
-  unsigned counter;             /* value of debug_ring_counter when logged */
-} debug_ring_log_buffer[64];
-
-static inline void debug_ring_log_event(const char code, const unsigned blockno)
-{
-  const unsigned i = debug_ring_counter % (sizeof(debug_ring_log_buffer)/sizeof(*debug_ring_log_buffer));
-  debug_ring_log_buffer[i].code    = code;
-  debug_ring_log_buffer[i].blockno = blockno;
-  debug_ring_log_buffer[i].counter = debug_ring_counter++;
-}
-
-#endif /* XXX End temporary debugging kludge */
-
 /*
  * Known block states.
  *
@@ -360,8 +332,6 @@ static hal_error_t block_read(const unsigned blockno, flash_block_t *block)
   if (block == NULL || blockno >= NUM_FLASH_BLOCKS || sizeof(*block) != KEYSTORE_SUBSECTOR_SIZE)
     return HAL_ERROR_IMPOSSIBLE;
 
-  debug_ring_log_event('r', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_read_data(block_offset(blockno),
                          block->bytes,
@@ -388,8 +358,6 @@ static hal_error_t block_read(const unsigned blockno, flash_block_t *block)
     return HAL_ERROR_KEYSTORE_BAD_BLOCK_TYPE;
   }
 
-  debug_ring_log_event('R', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_read_data(block_offset(blockno) + KEYSTORE_PAGE_SIZE,
                          block->bytes + KEYSTORE_PAGE_SIZE,
@@ -413,8 +381,6 @@ static hal_error_t block_read_cached(const unsigned blockno, flash_block_t **blo
   if (block == NULL)
     return HAL_ERROR_IMPOSSIBLE;
 
-  debug_ring_log_event('c', blockno); /* XXX */
-
   if ((*block = cache_find_block(blockno)) != NULL)
     return HAL_OK;
 
@@ -439,16 +405,12 @@ static hal_error_t block_deprecate(const unsigned blockno)
   flash_block_header_t *header = (void *) page;
   uint32_t offset = block_offset(blockno);
 
-  debug_ring_log_event('d', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_read_data(offset, page, sizeof(page)) != 1)
     return HAL_ERROR_KEYSTORE_ACCESS;
 
   header->block_status = BLOCK_STATUS_TOMBSTONE;
 
-  debug_ring_log_event('D', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_write_data(offset, page, sizeof(page)) != 1)
     return HAL_ERROR_KEYSTORE_ACCESS;
@@ -467,8 +429,6 @@ static hal_error_t block_zero(const unsigned blockno)
 
   uint8_t page[KEYSTORE_PAGE_SIZE] = {0};
 
-  debug_ring_log_event('z', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_write_data(block_offset(blockno), page, sizeof(page)) != 1)
     return HAL_ERROR_KEYSTORE_ACCESS;
@@ -485,8 +445,6 @@ static hal_error_t block_erase(const unsigned blockno)
   if (blockno >= NUM_FLASH_BLOCKS)
     return HAL_ERROR_IMPOSSIBLE;
 
-  debug_ring_log_event('e', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_erase_subsectors(blockno, blockno) != 1)
     return HAL_ERROR_KEYSTORE_ACCESS;
@@ -509,8 +467,6 @@ static hal_error_t block_erase_maybe(const unsigned blockno)
   if (blockno >= NUM_FLASH_BLOCKS)
     return HAL_ERROR_IMPOSSIBLE;
 
-  debug_ring_log_event('m', blockno); /* XXX */
-
   uint8_t mask = 0xFF;
 
   for (uint32_t a = block_offset(blockno); a < block_offset(blockno + 1); a += KEYSTORE_PAGE_SIZE) {
@@ -548,8 +504,6 @@ static hal_error_t block_write(const unsigned blockno, flash_block_t *block)
     break;
   }
 
-  debug_ring_log_event('w', blockno); /* XXX */
-
   /* Sigh, magic numeric return codes */
   if (keystore_write_data(block_offset(blockno), block->bytes, sizeof(*block)) != 1)
     return HAL_ERROR_KEYSTORE_ACCESS;
@@ -570,8 +524,6 @@ static hal_error_t block_update(const unsigned b1, flash_block_t *block,
   if (db.ksi.used == db.ksi.size)
     return HAL_ERROR_NO_KEY_INDEX_SLOTS;
 
-  debug_ring_log_event('u', b1); /* XXX */
-
   cache_release(block);
 
   hal_error_t err;



More information about the Commits mailing list