aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/init.c5
-rw-r--r--core/nvram.c32
-rw-r--r--include/nvram.h1
3 files changed, 28 insertions, 10 deletions
diff --git a/core/init.c b/core/init.c
index d32eea6..d5894ab 100644
--- a/core/init.c
+++ b/core/init.c
@@ -44,6 +44,7 @@
#include <ipmi.h>
#include <sensor.h>
#include <xive.h>
+#include <nvram.h>
enum proc_gen proc_gen;
@@ -444,7 +445,9 @@ void __noreturn load_and_boot_kernel(bool is_reboot)
/* Wait for FW VPD data read to complete */
fsp_code_update_wait_vpd(true);
- }
+ } else
+ nvram_reinit();
+
fsp_console_select_stdout();
/*
diff --git a/core/nvram.c b/core/nvram.c
index 9a9a6ff..3ae0f12 100644
--- a/core/nvram.c
+++ b/core/nvram.c
@@ -59,6 +59,28 @@ static int64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset)
}
opal_call(OPAL_WRITE_NVRAM, opal_write_nvram, 3);
+static void nvram_validate(void)
+{
+ /* Check and maybe format nvram */
+ if (nvram_check(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)
+ platform.nvram_write(0, nvram_image, nvram_size);
+ }
+}
+
+void nvram_reinit(void)
+{
+ /* It's possible we failed to load nvram at boot. */
+ if (!nvram_ready)
+ nvram_init();
+ else
+ nvram_validate();
+}
+
void nvram_read_complete(bool success)
{
struct dt_node *np;
@@ -70,15 +92,7 @@ void nvram_read_complete(bool success)
return;
}
- /* Check and maybe format nvram */
- if (nvram_check(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)
- platform.nvram_write(0, nvram_image, nvram_size);
- }
+ nvram_validate();
/* Add nvram node */
np = dt_new(opal_node, "nvram");
diff --git a/include/nvram.h b/include/nvram.h
index ce33d2f..c90c571 100644
--- a/include/nvram.h
+++ b/include/nvram.h
@@ -19,5 +19,6 @@
int nvram_format(void *nvram_image, uint32_t nvram_size);
int nvram_check(void *nvram_image, uint32_t nvram_size);
+void nvram_reinit(void);
#endif /* __NVRAM_H */