aboutsummaryrefslogtreecommitdiff
path: root/tftf/tests/runtime_services/standard_service/query_std_svc.c
blob: c8ce6e90c59a97f745844c2bf919cb98f26d728a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright (c) 2018, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <psci.h>
#include <smccc.h>
#include <std_svc.h>
#include <tftf_lib.h>
#include <uuid_utils.h>

/*
 * Standard service UUID as returned by the implementation in the Trusted
 * Firmware.
 */
static const uuid_t armtf_std_svc_uuid = {
	{0x5b, 0x90, 0x8d, 0x10},
	{0x63, 0xf8},
	{0xe8, 0x47},
	0xae, 0x2d,
	{0xc0, 0xfb, 0x56, 0x41, 0xf6, 0xe2}
};

/**
 * @Test_Aim@ Query the Standard Service
 *
 * This test targets the implementation of the Standard Service in the Trusted
 * Firmware. If it is interfaced with a different implementation then this test
 * will most likely fail because the values returned by the service won't be the
 * ones expected.
 *
 * The following queries are performed:
 * 1) Call UID
 * 2) Call count
 * 3) Call revision details
 */
test_result_t test_query_std_svc(void)
{
	smc_args std_svc_args;
	smc_ret_values ret;
	uuid_t std_svc_uuid;
	char uuid_str[UUID_STR_SIZE];
	test_result_t test_result = TEST_RESULT_SUCCESS;

	/* Standard Service Call UID */
	std_svc_args.fid = SMC_STD_SVC_UID;
	ret = tftf_smc(&std_svc_args);

	make_uuid_from_4words(&std_svc_uuid,
			ret.ret0, ret.ret1, ret.ret2, ret.ret3);
	if (!uuid_equal(&std_svc_uuid, &armtf_std_svc_uuid)) {
		tftf_testcase_printf("Wrong UUID: expected %s,\n",
				uuid_to_str(&armtf_std_svc_uuid, uuid_str));
		tftf_testcase_printf("                 got %s\n",
				uuid_to_str(&std_svc_uuid, uuid_str));
		test_result = TEST_RESULT_FAIL;
	}

	/* Standard Service Call Count */
	std_svc_args.fid = SMC_STD_SVC_CALL_COUNT;
	ret = tftf_smc(&std_svc_args);

	if (ret.ret0 == SMC_UNKNOWN) {
		tftf_testcase_printf("Querying STD service call count"
				" failed\n");
		test_result = TEST_RESULT_FAIL;
	} else {
		tftf_testcase_printf("STD Service Call Count reported by firmware:"
			" %llu\n", (unsigned long long)ret.ret0);
	}

	/* Standard Service Call Revision details */
	std_svc_args.fid = SMC_STD_SVC_REVISION;
	ret = tftf_smc(&std_svc_args);

	if ((ret.ret0 != STD_SVC_REVISION_MAJOR) ||
	    (ret.ret1 != STD_SVC_REVISION_MINOR)) {
		tftf_testcase_printf(
			"Wrong Revision: expected {%u.%u}, got {%llu.%llu}\n",
			STD_SVC_REVISION_MAJOR, STD_SVC_REVISION_MINOR,
			(unsigned long long)ret.ret0,
			(unsigned long long)ret.ret1);
		test_result = TEST_RESULT_FAIL;
	}

	return test_result;
}