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