aboutsummaryrefslogtreecommitdiff
path: root/external/gard
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-11-08 19:59:18 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-11-20 20:35:24 -0600
commite947593a38a15d4e80a108ae90a8fa9066d20837 (patch)
tree06d5a3b402992db13413ea534d59e3f97ec007f8 /external/gard
parenteb76931e7ae7ddd2eefd0d35ebea9c9b3cb276d9 (diff)
downloadskiboot-e947593a38a15d4e80a108ae90a8fa9066d20837.zip
skiboot-e947593a38a15d4e80a108ae90a8fa9066d20837.tar.gz
skiboot-e947593a38a15d4e80a108ae90a8fa9066d20837.tar.bz2
gard: Add OpenBMC vPNOR support
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@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external/gard')
-rw-r--r--external/gard/gard.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c
index 8152434..a491516 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