aboutsummaryrefslogtreecommitdiff
path: root/lib/trusted_os/trusted_os.c
blob: b24c3d395210a0dce139165fd368fe3af3b26d90 (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
/*
 * Copyright (c) 2018, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <smccc.h>
#include <stdint.h>
#include <tftf.h>
#include <trusted_os.h>
#include <uuid_utils.h>

unsigned int is_trusted_os_present(uuid_t *tos_uuid)
{
	smc_args tos_uid_args = { SMC_TOS_UID };
	smc_ret_values ret;
	uint32_t *tos_uuid32;

	ret = tftf_smc(&tos_uid_args);

	if ((ret.ret0 == SMC_UNKNOWN) ||
	    ((ret.ret0 == 0) && (ret.ret1 == 0) && (ret.ret2 == 0) &&
	     (ret.ret3 == 0)))
		return 0;

	tos_uuid32 = (uint32_t *) tos_uuid;
	tos_uuid32[0] = ret.ret0;
	tos_uuid32[1] = ret.ret1;
	tos_uuid32[2] = ret.ret2;
	tos_uuid32[3] = ret.ret3;

	return 1;
}