[Skiboot] [PATCH 13/13] gard: Add OpenBMC vPNOR support
Oliver O'Halloran
oohall at gmail.com
Wed Nov 8 19:59:18 AEDT 2017
A big-ol-hack to add some checking for OpenBMC's vPNOR GUARD files under
/media/pnor-prsv. This isn't ideal since it doesn't handle the create
case well, but it's better than nothing.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
external/gard/gard.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/external/gard/gard.c b/external/gard/gard.c
index 815243457cf5..a49151653aa0 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -50,6 +50,9 @@
#define SYSFS_MTD_PATH "/sys/class/mtd/"
#define FLASH_GARD_PART "GUARD"
+#define VPNOR_GARD_DIR "/media/pnor-prsv"
+#define VPNOR_GARD_FILE VPNOR_GARD_DIR"/GUARD"
+
/* Full gard version number (possibly includes gitid). */
extern const char version[];
@@ -879,6 +882,34 @@ int main(int argc, char **argv)
#endif
}
+#ifdef __arm__
+ /*
+ * HACK: Look for a vPNOR GUARD file if we haven't been given anything
+ * explitly. If it exists then we can safely assume that:
+ * a) The host is a P9
+ * b) The file is ECC protected
+ * c) The file is a bare partition.
+ *
+ * This is a stupid hack, but there's not other sane place for it.
+ * arch_init_flash() always looks for a FFS formatted PNOR when
+ * filename is NULL
+ */
+ if (!filename) {
+ struct stat buf;
+
+ if (!stat(VPNOR_GARD_FILE, &buf)) {
+ filename = strdup(VPNOR_GARD_FILE);
+ /* BUG: This ignores the command line settings */
+ part = true;
+ ecc = true;
+ set_chip_gen(p9_chip_units);
+ } else if (!stat(VPNOR_GARD_DIR, &buf)) {
+ printf(VPNOR_GARD_FILE" is missing. Nothing to do\n");
+ return 0;
+ }
+ }
+#endif
+
/*
* Force libflash to do flash accesses via the MTD. Direct mode is
* generally unsafe since it fiddles with the flash controller state
--
2.9.5
More information about the Skiboot
mailing list