From 52d939886a634e454353a603a6375f7d949a4a65 Mon Sep 17 00:00:00 2001 From: nwhitehorn Date: Tue, 28 Nov 2017 06:31:39 +0000 Subject: [PATCH] Back out OF module installation in the event of failure. PS3 firmware gives some ancient FDT version (2) that fails the init check in OFW_FDT. It is still possible to make progress, but not while the OF layer is going crazy. --- sys/dev/ofw/openfirm.c | 6 ++++++ sys/powerpc/ofw/ofw_machdep.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c index 45545ac34647..dc781d42ad8c 100644 --- a/sys/dev/ofw/openfirm.c +++ b/sys/dev/ofw/openfirm.c @@ -201,6 +201,12 @@ OF_install(char *name, int prio) ofw_def_t *ofwp, **ofwpp; static int curr_prio = 0; + /* Allow OF layer to be uninstalled */ + if (name == NULL) { + ofw_def_impl = NULL; + return (FALSE); + } + /* * Try and locate the OFW kobj corresponding to the name. */ diff --git a/sys/powerpc/ofw/ofw_machdep.c b/sys/powerpc/ofw/ofw_machdep.c index 0a74da038290..804ea7b59e7a 100644 --- a/sys/powerpc/ofw/ofw_machdep.c +++ b/sys/powerpc/ofw/ofw_machdep.c @@ -393,6 +393,7 @@ boolean_t OF_bootstrap() { boolean_t status = FALSE; + int err = 0; #ifdef AIM if (openfirmware_entry != NULL) { @@ -409,7 +410,7 @@ OF_bootstrap() if (status != TRUE) return status; - OF_init(openfirmware); + err = OF_init(openfirmware); } else #endif if (fdt != NULL) { @@ -418,10 +419,16 @@ OF_bootstrap() if (status != TRUE) return status; - OF_init(fdt); - OF_interpret("perform-fixup", 0); + err = OF_init(fdt); + if (err == 0) + OF_interpret("perform-fixup", 0); } + if (err != 0) { + OF_install(NULL, 0); + status = FALSE; + } + return (status); }