Tests: Tidy service partitions common code

Change-Id: I3eb64f45c4130f9a60c4402a069a3842f461f18a
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/test/hftest/service_common.c b/test/hftest/service_common.c
new file mode 100644
index 0000000..bd7840d
--- /dev/null
+++ b/test/hftest/service_common.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2021 The Hafnium Authors.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://opensource.org/licenses/BSD-3-Clause.
+ */
+
+#include <stdalign.h>
+#include <stdint.h>
+
+#include "hf/mm.h"
+#include "hf/std.h"
+
+#include "test/hftest.h"
+#include "test/hftest_impl.h"
+
+HFTEST_ENABLE();
+
+static struct hftest_context global_context;
+
+struct hftest_context *hftest_get_context(void)
+{
+	return &global_context;
+}
+
+noreturn void abort(void)
+{
+	HFTEST_LOG("Service contained failures.");
+	/* Cause a fault, as a secondary/SP can't power down the machine. */
+	*((volatile uint8_t *)1) = 1;
+
+	/* This should never be reached, but to make the compiler happy... */
+	for (;;) {
+	}
+}