1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4  */
5 
6 #ifndef APP_COMMON_H
7 #define APP_COMMON_H
8 
9 #ifndef __ASSEMBLER__
10 #include <stddef.h>
11 #include <stdint.h>
12 #endif /* __ASSEMBLER__ */
13 #include <utils_def.h>
14 
15 /* The heap properties are encoded in a single unsigned long.
16  * It is assumed that the heap_va is granule aligned, so at
17  * least the lower 12 bits are always zero.
18  */
19 #define HEAP_PAGE_COUNT_MASK ((1UL << 12U) - 1UL)
20 #define HEAP_VA_MASK (~HEAP_PAGE_COUNT_MASK)
21 
22 #define APP_EXIT_CALL		UL(23)
23 #define APP_YIELD_CALL		UL(24)
24 #define APP_SERVICE_CALL	UL(47)
25 
26 #define APP_SERVICE_COUNT			16U
27 #define APP_SERVICE_PRINT			2U
28 #define APP_SERVICE_RANDOM			3U
29 #define APP_SERVICE_GET_REALM_ATTESTATION_KEY	4U
30 #define APP_SERVICE_GET_PLATFORM_TOKEN		5U
31 #define APP_SERVICE_GET_REALM_ATTEST_PUB_KEY_FROM_EL3	6U
32 #define APP_SERVICE_EL3_TOKEN_SIGN_QUEUE_TRY_ENQUEUE	7U
33 #define APP_SERVICE_EL3_IFC_EL3_TOKEN_SIGN_SUPPORTED	8U
34 #define APP_SERVICE_WRITE_TO_NS_BUF			9U
35 #define APP_SERVICE_READ_FROM_NS_BUF_ALIGNED		10U
36 
37 #define APP_SERVICE_RW_NS_BUF_SHARED		0U
38 #define APP_SERVICE_RW_NS_BUF_HEAP		1U
39 
40 #ifndef __ASSEMBLER__
41 
42 struct service_get_realm_attestation_key_struct {
43 	size_t attest_key_buf_size;
44 	uint8_t attest_key_buf[GRANULE_SIZE - 8U];
45 };
46 COMPILER_ASSERT(sizeof(struct service_get_realm_attestation_key_struct) == GRANULE_SIZE);
47 
48 struct service_get_realm_attestation_pub_key_struct {
49 	size_t attest_pub_key_buf_size;
50 	uint8_t attest_pub_key_buf[GRANULE_SIZE - 8U];
51 };
52 COMPILER_ASSERT(sizeof(struct service_get_realm_attestation_pub_key_struct) == GRANULE_SIZE);
53 
54 struct service_get_platform_token_struct {
55 	size_t token_hunk_len;
56 	size_t remaining_len;
57 	uint8_t token_hunk_buf[GRANULE_SIZE - 16U];
58 };
59 COMPILER_ASSERT(sizeof(struct service_get_platform_token_struct) == GRANULE_SIZE);
60 
61 #if ATTEST_EL3_TOKEN_SIGN
62 struct service_el3_token_sign_request {
63 	uint64_t cookie;
64 	uint64_t ticket;
65 	size_t hash_buf_len;
66 	uint8_t hash_buf[GRANULE_SIZE - 24U];
67 };
68 COMPILER_ASSERT(sizeof(struct service_el3_token_sign_request) == GRANULE_SIZE);
69 
70 #endif
71 
72 #endif /* __ASSEMBLER__ */
73 #endif /* APP_COMMON_H */
74