diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/init.c | 2 | ||||
-rw-r--r-- | core/nvram-format.c | 9 | ||||
-rw-r--r-- | core/nvram.c | 35 | ||||
-rw-r--r-- | core/test/run-nvram-format.c | 10 |
4 files changed, 55 insertions, 1 deletions
diff --git a/core/init.c b/core/init.c index 89a2758..f2747c6 100644 --- a/core/init.c +++ b/core/init.c @@ -497,7 +497,7 @@ void __noreturn load_and_boot_kernel(bool is_reboot) /* We wait for the nvram read to complete here so we can * grab stuff from there such as the kernel arguments */ - fsp_nvram_wait_open(); + nvram_wait_for_load(); /* Wait for FW VPD data read to complete */ fsp_code_update_wait_vpd(true); diff --git a/core/nvram-format.c b/core/nvram-format.c index 923098a..3d030a3 100644 --- a/core/nvram-format.c +++ b/core/nvram-format.c @@ -216,6 +216,15 @@ const char *nvram_query(const char *key) const char *part_end, *start; int key_len = strlen(key); + if (!nvram_has_loaded()) { + prlog(PR_WARNING, "NVRAM: Query before is done loading\n"); + prlog(PR_WARNING, "NVRAM: Waiting for load\n"); + if (!nvram_wait_for_load()) { + prlog(PR_CRIT, "NVRAM: Failed to load\n"); + return NULL; + } + } + /* * The running OS can modify the NVRAM as it pleases so we need to be * a little paranoid and check that it's ok before we try parse it. diff --git a/core/nvram.c b/core/nvram.c index 2140706..de6cbdd 100644 --- a/core/nvram.c +++ b/core/nvram.c @@ -122,6 +122,41 @@ void nvram_read_complete(bool success) nvram_ready = true; } +bool nvram_wait_for_load(void) +{ + /* Short cut */ + if (nvram_ready) + return true; + + /* Tell the caller it will never happen */ + if (!platform.nvram_info) + return false; + + /* + * One of two things has happened here. + * 1. nvram_wait_for_load() was called before nvram_init() + * 2. The read of NVRAM failed. + * Either way, this is quite a bad event. + */ + if (!nvram_image && !nvram_size) { + prlog(PR_CRIT, "NVRAM: Possible wait before nvram_init()!\n"); + return false; + } + + while (!nvram_ready) { + opal_run_pollers(); + /* If the read fails, tell the caller */ + if (!nvram_image && !nvram_size) + return false; + } + return true; +} + +bool nvram_has_loaded(void) +{ + return nvram_ready; +} + void nvram_init(void) { int rc; diff --git a/core/test/run-nvram-format.c b/core/test/run-nvram-format.c index 5bd8ea2..d86b1dc 100644 --- a/core/test/run-nvram-format.c +++ b/core/test/run-nvram-format.c @@ -18,11 +18,21 @@ #include "../nvram-format.c" +bool nvram_wait_for_load(void) +{ + return true; +} + bool nvram_validate(void) { return true; } +bool nvram_has_loaded(void) +{ + return true; +} + static char *nvram_reset(void *nvram_image, int size) { struct chrp_nvram_hdr *h = nvram_image; |