summaryrefslogtreecommitdiff
path: root/tests/runtime_services
diff options
context:
space:
mode:
authorRoberto Vargas <roberto.vargas@arm.com>2017-08-17 12:33:37 +0100
committerRoberto Vargas <roberto.vargas@arm.com>2017-11-08 08:11:41 +0000
commitbdfa9df9a652db4c472d58a2634f8f50e07f319e (patch)
treeff25498c1462bdb63c863a78708b101b83a026f7 /tests/runtime_services
parentbeff689eb2001ea7891b37296db911dd757a97bf (diff)
Add test for reset2
This is an optional PSCI feature that allows to the caller a bigger control about the type of reset used. Change-Id: Ie7eddce11277e6f558f1c24cbc0dde5beb71d3de Signed-off-by: Roberto Vargas <roberto.vargas@arm.com>
Diffstat (limited to 'tests/runtime_services')
-rw-r--r--tests/runtime_services/standard_service/psci/api_tests/reset2/reset2.c163
1 files changed, 163 insertions, 0 deletions
diff --git a/tests/runtime_services/standard_service/psci/api_tests/reset2/reset2.c b/tests/runtime_services/standard_service/psci/api_tests/reset2/reset2.c
new file mode 100644
index 0000000..e2ee339
--- /dev/null
+++ b/tests/runtime_services/standard_service/psci/api_tests/reset2/reset2.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of ARM nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <psci.h>
+#include <stdlib.h>
+#include <test_helpers.h>
+#include <tftf_lib.h>
+
+#define SENTINEL 0x55
+#define INVALID_ARCH_RESET 0x00000001
+#define INVALID_VENDOR_RESET 0x80000002
+#define MEM_PROTECT_ENABLE 1
+#define MEM_PROTECT_DISABLE 0
+
+
+/*
+ * Test warm reset using PSCI RESET2 call (parameter 0)
+ * Returns:
+ * TEST_RESULT_SUCCESS: The system resets after calling RESET2
+ * TEST_RESULT_FAIL: The RESET2 PSCI call failed
+ */
+test_result_t reset2_warm(void)
+{
+ smc_args args = { SMC_PSCI_RESET2, 0};
+ extern unsigned char __TFTF_END__[];
+ unsigned char value;
+ int ret;
+
+ ret = tftf_get_psci_feature_info(SMC_PSCI_RESET2);
+ if (ret == PSCI_E_NOT_SUPPORTED)
+ return TEST_RESULT_SKIPPED;
+
+ if (tftf_is_rebooted()) {
+ value = *__TFTF_END__;
+ if (value != SENTINEL) {
+ tftf_testcase_printf("Sentinel address modified\n");
+ return TEST_RESULT_FAIL;
+ }
+ return TEST_RESULT_SUCCESS;
+ }
+
+ *__TFTF_END__ = SENTINEL;
+
+
+ tftf_notify_reboot();
+ tftf_smc(&args);
+
+ /* The PSCI RESET2 call is not supposed to return */
+ tftf_testcase_printf("System didn't shutdown properly\n");
+ return TEST_RESULT_FAIL;
+}
+
+/*
+ * Test correct error handling
+ * Returns:
+ * TEST_RESULT_SUCCESS: If the system catches all the wrong calls
+ * TEST_RESULT_FAIL: Some PSCI call failed
+ */
+test_result_t reset2_test_invalid(void)
+{
+ smc_args args = {SMC_PSCI_RESET2};
+ smc_ret_values ret_vals;
+ int ret;
+
+ ret = tftf_get_psci_feature_info(SMC_PSCI_RESET2);
+ if (ret == PSCI_E_NOT_SUPPORTED)
+ return TEST_RESULT_SKIPPED;
+
+ args.arg1 = INVALID_VENDOR_RESET;
+ ret_vals = tftf_smc(&args);
+ ret = ret_vals.ret0;
+
+ if (ret >= 0)
+ return TEST_RESULT_FAIL;
+
+ args.arg1 = INVALID_ARCH_RESET;
+ ret_vals = tftf_smc(&args);
+ ret = ret_vals.ret0;
+
+ if (ret >= 0)
+ return TEST_RESULT_FAIL;
+
+ return TEST_RESULT_SUCCESS;
+}
+
+/*
+ * Test combination of reset2 and mem_protect
+ * Returns:
+ * TEST_RESULT_SUCCESS: if the system is reseted and mem_protect
+ * is disabled.
+ * TEST_RESULT_FAIL: Some PSCI call failed or mem_protect wasn't
+ * disabled
+ */
+test_result_t reset2_mem_protect(void)
+{
+ int ret;
+ unsigned char value;
+ smc_args args = { SMC_PSCI_RESET2, 0};
+ extern unsigned char __TFTF_END__[];
+
+ ret = tftf_get_psci_feature_info(SMC_PSCI_RESET2);
+ if (ret == PSCI_E_NOT_SUPPORTED)
+ return TEST_RESULT_SKIPPED;
+
+ ret = tftf_get_psci_feature_info(SMC_PSCI_MEM_PROTECT);
+ if (ret == PSCI_E_NOT_SUPPORTED)
+ return TEST_RESULT_SKIPPED;
+
+ if (tftf_is_rebooted()) {
+ if (psci_mem_protect(0) != MEM_PROTECT_DISABLE) {
+ tftf_testcase_printf("mem_protect is not disabled");
+ return TEST_RESULT_SUCCESS;
+ }
+ value = *__TFTF_END__;
+ if (value != SENTINEL) {
+ tftf_testcase_printf("Sentinel address modified\n");
+ return TEST_RESULT_FAIL;
+ }
+ return TEST_RESULT_SUCCESS;
+ }
+
+ *__TFTF_END__ = SENTINEL;
+
+ ret = psci_mem_protect(0);
+ if (ret != MEM_PROTECT_ENABLE && ret != MEM_PROTECT_DISABLE) {
+ tftf_testcase_printf("error calling mem_protect");
+ return TEST_RESULT_FAIL;
+ }
+
+ tftf_notify_reboot();
+ tftf_smc(&args);
+
+ /* The PSCI RESET2 call is not supposed to return */
+ tftf_testcase_printf("System didn't shutdown properly\n");
+ return TEST_RESULT_FAIL;
+}