save memory (2)

This commit is contained in:
NIIBE Yutaka
2011-05-11 09:29:18 +09:00
parent af1067688e
commit 0ef47be2da
2 changed files with 8 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
2011-05-11 NIIBE Yutaka <gniibe@fsij.org> 2011-05-11 NIIBE Yutaka <gniibe@fsij.org>
* src/flash.c (keystore_pool): Remove. Use &_keystore_pool.
* src/ac.c (auth_status): Don't assign 0 as it's automatically * src/ac.c (auth_status): Don't assign 0 as it's automatically
cleared. cleared.

View File

@@ -162,7 +162,7 @@ flash_erase_page (uint32_t addr)
#define FLASH_KEYSTORE_SIZE (512*3) #define FLASH_KEYSTORE_SIZE (512*3)
static const uint8_t *data_pool; static const uint8_t *data_pool;
static const uint8_t *keystore_pool; extern uint8_t _keystore_pool;
static uint8_t *last_p; static uint8_t *last_p;
static const uint8_t *keystore; static const uint8_t *keystore;
@@ -179,7 +179,6 @@ const uint8_t *
flash_init (void) flash_init (void)
{ {
const uint8_t *p; const uint8_t *p;
extern uint8_t _keystore_pool;
uint16_t gen0, gen1; uint16_t gen0, gen1;
uint16_t *gen0_p = (uint16_t *)&_data_pool; uint16_t *gen0_p = (uint16_t *)&_data_pool;
uint16_t *gen1_p = (uint16_t *)(&_data_pool + FLASH_PAGE_SIZE); uint16_t *gen1_p = (uint16_t *)(&_data_pool + FLASH_PAGE_SIZE);
@@ -196,10 +195,8 @@ flash_init (void)
else else
data_pool = &_data_pool; data_pool = &_data_pool;
keystore_pool = &_keystore_pool;
/* Seek empty keystore */ /* Seek empty keystore */
p = keystore_pool; p = &_keystore_pool;
while (*p != 0xff || *(p+1) != 0xff) while (*p != 0xff || *(p+1) != 0xff)
p += 512; p += 512;
@@ -384,7 +381,7 @@ flash_key_alloc (void)
{ {
uint8_t *k = (uint8_t *)keystore; uint8_t *k = (uint8_t *)keystore;
if ((k - keystore_pool) >= FLASH_KEYSTORE_SIZE) if ((k - &_keystore_pool) >= FLASH_KEYSTORE_SIZE)
return NULL; return NULL;
keystore += 512; keystore += 512;
@@ -422,11 +419,11 @@ flash_key_write (uint8_t *key_addr, const uint8_t *key_data,
void void
flash_keystore_release (void) flash_keystore_release (void)
{ {
flash_erase_page ((uint32_t)keystore_pool); flash_erase_page ((uint32_t)&_keystore_pool);
#if FLASH_KEYSTORE_SIZE > FLASH_PAGE_SIZE #if FLASH_KEYSTORE_SIZE > FLASH_PAGE_SIZE
flash_erase_page ((uint32_t)keystore_pool + FLASH_PAGE_SIZE); flash_erase_page ((uint32_t)&_keystore_pool + FLASH_PAGE_SIZE);
#endif #endif
keystore = keystore_pool; keystore = &_keystore_pool;
} }
void void