Skip to content

Commit e947593

Browse files
oohalstewartsmith
authored andcommitted
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 <[email protected]> Signed-off-by: Stewart Smith <[email protected]>
1 parent eb76931 commit e947593

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

external/gard/gard.c

+31
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
#define SYSFS_MTD_PATH "/sys/class/mtd/"
5151
#define FLASH_GARD_PART "GUARD"
5252

53+
#define VPNOR_GARD_DIR "/media/pnor-prsv"
54+
#define VPNOR_GARD_FILE VPNOR_GARD_DIR"/GUARD"
55+
5356
/* Full gard version number (possibly includes gitid). */
5457
extern const char version[];
5558

@@ -879,6 +882,34 @@ int main(int argc, char **argv)
879882
#endif
880883
}
881884

885+
#ifdef __arm__
886+
/*
887+
* HACK: Look for a vPNOR GUARD file if we haven't been given anything
888+
* explitly. If it exists then we can safely assume that:
889+
* a) The host is a P9
890+
* b) The file is ECC protected
891+
* c) The file is a bare partition.
892+
*
893+
* This is a stupid hack, but there's not other sane place for it.
894+
* arch_init_flash() always looks for a FFS formatted PNOR when
895+
* filename is NULL
896+
*/
897+
if (!filename) {
898+
struct stat buf;
899+
900+
if (!stat(VPNOR_GARD_FILE, &buf)) {
901+
filename = strdup(VPNOR_GARD_FILE);
902+
/* BUG: This ignores the command line settings */
903+
part = true;
904+
ecc = true;
905+
set_chip_gen(p9_chip_units);
906+
} else if (!stat(VPNOR_GARD_DIR, &buf)) {
907+
printf(VPNOR_GARD_FILE" is missing. Nothing to do\n");
908+
return 0;
909+
}
910+
}
911+
#endif
912+
882913
/*
883914
* Force libflash to do flash accesses via the MTD. Direct mode is
884915
* generally unsafe since it fiddles with the flash controller state

0 commit comments

Comments
 (0)