[Skiboot] [PATCH 2/6] nvram: Add extra debug printing when NVRAM needs formatting
Cyril Bur
cyril.bur at au1.ibm.com
Tue Jul 26 13:49:31 AEST 2016
Be more verbose (at debug level) when formatting the NVRAM, this can
help catch errors at other levels of the stack.
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
core/nvram-format.c | 12 +++++++++---
core/nvram.c | 3 ++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/core/nvram-format.c b/core/nvram-format.c
index 899fab4..1c164d4 100644
--- a/core/nvram-format.c
+++ b/core/nvram-format.c
@@ -65,7 +65,7 @@ int nvram_format(void *nvram_image, uint32_t nvram_size)
struct chrp_nvram_hdr *h;
unsigned int offset = 0;
- prerror("NVRAM: Re-initializing\n");
+ prerror("NVRAM: Re-initializing (size: 0x%08x)\n", nvram_size);
memset(nvram_image, 0, nvram_size);
/* Create private partition */
@@ -76,6 +76,8 @@ int nvram_format(void *nvram_image, uint32_t nvram_size)
h->len = NVRAM_SIZE_FW_PRIV >> 4;
strcpy(h->name, NVRAM_NAME_FW_PRIV);
h->cksum = chrp_nv_cksum(h);
+ prlog(PR_DEBUG, "NVRAM: Created '%s' partition at 0x%08x for size 0x%08x"
+ " with cksum 0x%02x\n", NVRAM_NAME_FW_PRIV, offset, h->len, h->cksum);
offset += NVRAM_SIZE_FW_PRIV;
/* Create common partition */
@@ -86,6 +88,8 @@ int nvram_format(void *nvram_image, uint32_t nvram_size)
h->len = NVRAM_SIZE_COMMON >> 4;
strcpy(h->name, NVRAM_NAME_COMMON);
h->cksum = chrp_nv_cksum(h);
+ prlog(PR_DEBUG, "NVRAM: Created '%s' partition at 0x%08x for size 0x%08x"
+ " with cksum 0x%02x\n", NVRAM_NAME_COMMON, offset, h->len, h->cksum);
offset += NVRAM_SIZE_COMMON;
/* Create free space partition */
@@ -97,7 +101,8 @@ int nvram_format(void *nvram_image, uint32_t nvram_size)
/* We have the full 12 bytes here */
memcpy(h->name, NVRAM_NAME_FREE, 12);
h->cksum = chrp_nv_cksum(h);
-
+ prlog(PR_DEBUG, "NVRAM: Created '%s' partition at 0x%08x for size 0x%08x"
+ " with cksum 0x%02x\n", NVRAM_NAME_FREE, offset, h->len, h->cksum);
return 0;
}
@@ -117,7 +122,8 @@ int nvram_check(void *nvram_image, const uint32_t nvram_size)
if (chrp_nv_cksum(h) != h->cksum) {
prerror("NVRAM: Partition at offset 0x%x"
- " has bad checksum\n", offset);
+ " has bad checksum: 0x%02x vs 0x%02x\n",
+ offset, h->cksum, chrp_nv_cksum(h));
goto failed;
}
if (h->len < 1) {
diff --git a/core/nvram.c b/core/nvram.c
index bde2dce..38babcc 100644
--- a/core/nvram.c
+++ b/core/nvram.c
@@ -64,7 +64,8 @@ void nvram_read_complete(bool success)
/* Check and maybe format nvram */
if (nvram_check(nvram_image, nvram_size)) {
- nvram_format(nvram_image, nvram_size);
+ if (nvram_format(nvram_image, nvram_size))
+ prerror("NVRAM: Failed to format NVRAM!\n");
/* Write the whole thing back */
if (platform.nvram_write)
--
2.9.0
More information about the Skiboot
mailing list