We're being a bit tricky when we change the prototype of halt() to take 'code' as an argument. Doing this gives us a last chance to see it when inspecting the halted unit test state (it'll be in r0/x0 for arm/arm64 and r3 for powerpc.) Let's comment this trick to avoid confusion. Suggested-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> --- lib/arm/io.c | 10 ++++++++-- lib/powerpc/io.c | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/arm/io.c b/lib/arm/io.c index 8226b765bdc5..99fd31560084 100644 --- a/lib/arm/io.c +++ b/lib/arm/io.c @@ -18,8 +18,6 @@ #include "io.h" -extern void halt(int code); - static struct spinlock uart_lock; /* * Use this guess for the uart base in order to make an attempt at @@ -89,6 +87,14 @@ void puts(const char *s) spin_unlock(&uart_lock); } + +/* + * Defining halt to take 'code' as an argument guarantees that it will + * be in x0/r0 when we halt. That gives us a final chance to see the exit + * status while inspecting the halted unit test state. + */ +extern void halt(int code); + void exit(int code) { chr_testdev_exit(code); diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c index 217eb0770ef5..a381688bce51 100644 --- a/lib/powerpc/io.c +++ b/lib/powerpc/io.c @@ -11,8 +11,6 @@ #include <asm/setup.h> #include "io.h" -extern void halt(int code); - static struct spinlock print_lock; void io_init(void) @@ -28,6 +26,13 @@ void puts(const char *s) spin_unlock(&print_lock); } +/* + * Defining halt to take 'code' as an argument guarantees that it will + * be in r3 when we halt. That gives us a final chance to see the exit + * status while inspecting the halted unit test state. + */ +extern void halt(int code); + void exit(int code) { // FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit(), -- 2.20.1