xref: /rk3399_ARM-atf/include/services/el3_spmd_logical_sp.h (revision 890b5088203e990d683a9c837e976be62c6501aa)
1 /*
2  * Copyright (c) 2023, ARM Limited and Contributors. All rights reserved.
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef EL3_SPMD_LOGICAL_SP_H
6 #define EL3_SPMD_LOGICAL_SP_H
7 
8 #include <common/bl_common.h>
9 #include <lib/cassert.h>
10 #include <services/ffa_svc.h>
11 
12 /*******************************************************************************
13  * Structure definition, typedefs & constants for the SPMD Logical Partitions.
14  ******************************************************************************/
15 
16 /* Prototype for SPMD logical partition initializing function. */
17 typedef int32_t (*ffa_spmd_lp_init_t)(void);
18 
19 /* SPMD Logical Partition Descriptor. */
20 struct spmd_lp_desc {
21 	ffa_spmd_lp_init_t init;
22 	uint16_t sp_id;
23 	uint32_t properties;
24 	uint32_t uuid[4];  /* Little Endian. */
25 	const char *debug_name;
26 };
27 
28 /* Convenience macro to declare a SPMD logical partition descriptor. */
29 #define DECLARE_SPMD_LOGICAL_PARTITION(_name, _init, _sp_id, _uuid, _properties) \
30 	static const struct spmd_lp_desc __partition_desc_ ## _name	    \
31 		__section(".spmd_lp_descs") __used = {			    \
32 			.debug_name = #_name,				    \
33 			.init = (_init),				    \
34 			.sp_id = (_sp_id),				    \
35 			.uuid = _uuid,					    \
36 			.properties = (_properties),			    \
37 		}
38 
39 IMPORT_SYM(uintptr_t, __SPMD_LP_DESCS_START__,	SPMD_LP_DESCS_START);
40 IMPORT_SYM(uintptr_t, __SPMD_LP_DESCS_END__,	SPMD_LP_DESCS_END);
41 
42 #define SPMD_LP_DESCS_COUNT ((SPMD_LP_DESCS_END - SPMD_LP_DESCS_START) \
43 			  / sizeof(struct spmd_lp_desc))
44 CASSERT(sizeof(struct spmd_lp_desc) == 40, assert_spmd_lp_desc_size_mismatch);
45 
46 /*
47  * Reserve 63 IDs for SPMD Logical Partitions. Currently, 0xFFC0 to 0xFFFE
48  * is reserved.
49  */
50 #define SPMD_LP_ID_END		(SPMD_DIRECT_MSG_ENDPOINT_ID - 1)
51 #define SPMD_LP_ID_START	(SPMD_LP_ID_END - 62)
52 
53 static inline bool is_spmd_lp_id(unsigned int id)
54 {
55 	return (id >= SPMD_LP_ID_START && id <= SPMD_LP_ID_END);
56 }
57 
58 void spmd_logical_sp_set_spmc_initialized(void);
59 void spmc_logical_sp_set_spmc_failure(void);
60 
61 int32_t spmd_logical_sp_init(void);
62 
63 #endif /* EL3_SPMD_LOGICAL_SP_H */
64