From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH 5/9] Add halt() and some error codes Date: Mon, 14 Oct 2013 18:23:31 +0200 Message-ID: <1381767815-12510-6-git-send-email-drjones@redhat.com> References: <1381767815-12510-1-git-send-email-drjones@redhat.com> Cc: kvmarm@lists.cs.columbia.edu, gleb@redhat.com, christoffer.dall@linaro.org To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41040 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755616Ab3JNQYG (ORCPT ); Mon, 14 Oct 2013 12:24:06 -0400 In-Reply-To: <1381767815-12510-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Add a halt function that can be used by the test infrastructure on error paths before exit() works. Also add some error codes that can be passed to halt() in case the serial isn't working either. Then, on register inspection of the halted guest we may be able to quickly determine the problem without having to find the halt() call-site using its return address. Signed-off-by: Andrew Jones --- lib/errno.h | 15 +++++++++++++++ lib/libcflat.h | 2 ++ lib/x86/io.c | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 lib/errno.h diff --git a/lib/errno.h b/lib/errno.h new file mode 100644 index 0000000000000..4c7478229baf3 --- /dev/null +++ b/lib/errno.h @@ -0,0 +1,15 @@ +#ifndef _ERRNO_H_ +#define _ERRNO_H_ +/* + * Define some error codes for the test infrastructure's use. + * (Ab)use the standard E* names for syntax highlighting... + */ +#define MAXERR 127 /* exit(-1) */ +#define EINTR (MAXERR - 1) /* unhandled exception */ +#define EIO (MAXERR - 2) /* I/O error */ +#define ENXIO (MAXERR - 3) /* no serial */ +#define ENOEXEC (MAXERR - 4) /* bad test file format */ +#define ENOMEM (MAXERR - 5) /* Out of memory */ +#define ENODEV (MAXERR - 6) /* no testdev device */ +#define EINVAL (MAXERR - 7) /* Invalid argument */ +#endif diff --git a/lib/libcflat.h b/lib/libcflat.h index 140c172e77d54..a1be635ab4ee9 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -37,6 +37,7 @@ typedef _Bool bool; #define true 1 #define false 0 +extern void halt(int code); extern void exit(int code); extern unsigned long strlen(const char *buf); @@ -57,4 +58,5 @@ extern long atol(const char *ptr); #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #define NULL ((void *)0UL) +#include "errno.h" #endif diff --git a/lib/x86/io.c b/lib/x86/io.c index d3b971ef67b0e..7a36c9ca0c951 100644 --- a/lib/x86/io.c +++ b/lib/x86/io.c @@ -1,4 +1,5 @@ #include "libcflat.h" +#include "processor.h" #include "smp.h" #include "io.h" #ifndef USE_SERIAL @@ -81,3 +82,8 @@ void exit(int code) asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4)); #endif } + +void halt(int code) +{ + safe_halt(); +} -- 1.8.1.4