mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
nvmem: provide a function to wipe out nvmem contents
It is important to be able to wipe out the non-volatile memory for various reasons. This patch adds this ability for both when NV memory is kept in SRAM and in flash. Also a minor clean up to eliminate some code duplication and to have normal flow messages printed out with time stamps. BRANCH=none BUG=chrome-os-partner:44745 TEST=just makeall at this time. Change-Id: I59c1909669aeaa9e8ffb3d8ef81b02fa0facb6ab Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/348291 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
723f703fd4
commit
d9f0c13447
@@ -65,14 +65,10 @@ int _plat__NVEnable(void *platParameter)
|
||||
*/
|
||||
s_NV_recoverable = nvmem_get_error_state() != 0;
|
||||
s_NV_unrecoverable = s_NV_recoverable;
|
||||
if (s_NV_unrecoverable)
|
||||
return -1;
|
||||
return s_NV_recoverable;
|
||||
#else
|
||||
if (s_NV_unrecoverable)
|
||||
return -1;
|
||||
return s_NV_recoverable;
|
||||
#endif
|
||||
if (s_NV_unrecoverable)
|
||||
return -1;
|
||||
return s_NV_recoverable;
|
||||
}
|
||||
|
||||
void _plat__NVDisable(void)
|
||||
@@ -217,3 +213,12 @@ void _plat__ClearNvAvail(void)
|
||||
s_NvIsAvailable = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
void wipe_nvram(void)
|
||||
{
|
||||
#ifdef CONFIG_FLASH_NVMEM
|
||||
nvmem_setup(0);
|
||||
#else
|
||||
memset(s_NV, 0xff, sizeof(s_NV));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef __EC_BOARD_CR50_TPM2_MEMORY_H
|
||||
#define __EC_BOARD_CR50_TPM2_MEMORY_H
|
||||
|
||||
/* An empty file to meet expectations of the tpm2 library. */
|
||||
/* A function to reinitialize the TPM NVram. */
|
||||
void wipe_nvram(void);
|
||||
|
||||
#endif /* __EC_BOARD_CR50_TPM2_MEMORY_H */
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "util.h"
|
||||
|
||||
#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ## args)
|
||||
#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ## args)
|
||||
|
||||
#define NVMEM_ACQUIRE_CACHE_SLEEP_MS 25
|
||||
#define NVMEM_ACQUIRE_CACHE_MAX_ATTEMPTS (250 / NVMEM_ACQUIRE_CACHE_SLEEP_MS)
|
||||
@@ -273,7 +274,7 @@ int nvmem_setup(uint8_t starting_version)
|
||||
int part;
|
||||
int ret;
|
||||
|
||||
CPRINTF("Configuring NVMEM FLash Partition\n");
|
||||
CPRINTS("Configuring NVMEM FLash Partition");
|
||||
/*
|
||||
* Initialize NVmem partition. This function will only be called
|
||||
* if during nvmem_init() fails which implies that NvMem is not fully
|
||||
@@ -334,6 +335,7 @@ int nvmem_init(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
CPRINTS("Active NVram partition set to %d", nvmem_act_partition);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user