From e947593a38a15d4e80a108ae90a8fa9066d20837 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Wed, 8 Nov 2017 19:59:18 +1100 Subject: 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 Signed-off-by: Stewart Smith --- external/gard/gard.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'external') 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 -- cgit v1.1