new file mode 100644
@@ -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
@@ -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
@@ -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();
+}
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 <drjones@redhat.com> --- lib/errno.h | 15 +++++++++++++++ lib/libcflat.h | 2 ++ lib/x86/io.c | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 lib/errno.h