aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJessica Clarke <jrtc27@jrtc27.com>2021-11-21 17:30:22 +0000
committerAnup Patel <anup@brainfault.org>2021-12-02 08:50:36 +0530
commit14faee6916bc973b9fdb816c5f4a45096e3f645a (patch)
treef377e445ac06a6a8bbeabc3a5b33fc90fce4515a /platform
parent7e777069664465cb36bb14801c7e17c143911f9b (diff)
downloadopensbi-14faee6916bc973b9fdb816c5f4a45096e3f645a.zip
opensbi-14faee6916bc973b9fdb816c5f4a45096e3f645a.tar.gz
opensbi-14faee6916bc973b9fdb816c5f4a45096e3f645a.tar.bz2
lib: sbi: Improve fatal error handling
BUG and BUG_ON are not informative and are rather lazy interfaces, only telling the user that something went wrong in a given function, but not what, requiring the user to find the sources corresponding to their firmware (which may not be available) and figure out how that BUG(_ON) was hit. Even SBI_ASSERT in its current form, which does include the condition that triggered it in the output, isn't necessarily very informative. In some cases, the error may be fixable by the user, but they need to know the problem in order to have any hope of fixing it. It's also a nuisance for developers, whose development trees may have changed significantly since the release in question being used, and so line numbers can make it harder for them to understand which error case a user has hit. This patch introduces a new sbi_panic function which is printf-like, allowing detailed error messages to be printed to the console. BUG and BUG_ON are removed, since the former is just a worse form of sbi_panic and the latter is a worse version of SBI_ASSERT. Finally, SBI_ASSERT is augmented to take a set of arguments to pass to sbi_panic on failure, used like so (sbi_boot_print_hart's current error case, which currently manually calls sbi_printf and sbi_hart_hang): SBI_ASSERT(xlen >= 1, ("Error %d getting MISA XLEN\n", xlen)); The existing users of BUG are replaced with calls to sbi_panic along with informative error messages. BUG_ON and SBI_ASSERT were unused (and, in the case of SBI_ASSERT, remain unused). Many existing users of sbi_hart_hang should be converted to use either sbi_panic or SBI_ASSERT after this commit. Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/generic/sifive_fu740.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/platform/generic/sifive_fu740.c b/platform/generic/sifive_fu740.c
index 3152152..333b3fb 100644
--- a/platform/generic/sifive_fu740.c
+++ b/platform/generic/sifive_fu740.c
@@ -12,6 +12,7 @@
#include <platform_override.h>
#include <libfdt.h>
#include <sbi/sbi_error.h>
+#include <sbi/sbi_hart.h>
#include <sbi/sbi_system.h>
#include <sbi/sbi_console.h>
#include <sbi_utils/fdt/fdt_helper.h>