blob: dcbbfabe41ae2cd6f57506aaf052964170ce3333 [file] [log] [blame]
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -08001/*
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 ******************************************************************************/
Raghu Krishnamurthy6a305142023-03-03 06:41:29 -080015typedef struct spmd_spm_core_context spmd_spm_core_context_t;
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -080016
17/* Prototype for SPMD logical partition initializing function. */
18typedef int32_t (*ffa_spmd_lp_init_t)(void);
19
20/* SPMD Logical Partition Descriptor. */
21struct spmd_lp_desc {
22 ffa_spmd_lp_init_t init;
23 uint16_t sp_id;
24 uint32_t properties;
25 uint32_t uuid[4]; /* Little Endian. */
26 const char *debug_name;
27};
28
Raghu Krishnamurthy6a305142023-03-03 06:41:29 -080029struct ffa_value {
30 uint64_t func;
31 uint64_t arg1;
32 uint64_t arg2;
33 uint64_t arg3;
34 uint64_t arg4;
35 uint64_t arg5;
36 uint64_t arg6;
37 uint64_t arg7;
38};
39
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -080040/* Convenience macro to declare a SPMD logical partition descriptor. */
41#define DECLARE_SPMD_LOGICAL_PARTITION(_name, _init, _sp_id, _uuid, _properties) \
42 static const struct spmd_lp_desc __partition_desc_ ## _name \
43 __section(".spmd_lp_descs") __used = { \
44 .debug_name = #_name, \
45 .init = (_init), \
46 .sp_id = (_sp_id), \
47 .uuid = _uuid, \
48 .properties = (_properties), \
49 }
50
51IMPORT_SYM(uintptr_t, __SPMD_LP_DESCS_START__, SPMD_LP_DESCS_START);
52IMPORT_SYM(uintptr_t, __SPMD_LP_DESCS_END__, SPMD_LP_DESCS_END);
53
54#define SPMD_LP_DESCS_COUNT ((SPMD_LP_DESCS_END - SPMD_LP_DESCS_START) \
55 / sizeof(struct spmd_lp_desc))
56CASSERT(sizeof(struct spmd_lp_desc) == 40, assert_spmd_lp_desc_size_mismatch);
57
58/*
59 * Reserve 63 IDs for SPMD Logical Partitions. Currently, 0xFFC0 to 0xFFFE
60 * is reserved.
61 */
62#define SPMD_LP_ID_END (SPMD_DIRECT_MSG_ENDPOINT_ID - 1)
63#define SPMD_LP_ID_START (SPMD_LP_ID_END - 62)
64
65static inline bool is_spmd_lp_id(unsigned int id)
66{
Raghu Krishnamurthy6a305142023-03-03 06:41:29 -080067#if ENABLE_SPMD_LP
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -080068 return (id >= SPMD_LP_ID_START && id <= SPMD_LP_ID_END);
Raghu Krishnamurthy6a305142023-03-03 06:41:29 -080069#else
70 return false;
71#endif
72}
73
74static inline bool is_ffa_error(struct ffa_value *retval)
75{
76 return retval->func == FFA_ERROR;
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -080077}
78
Raghu Krishnamurthy6a305142023-03-03 06:41:29 -080079static inline bool is_ffa_direct_msg_resp(struct ffa_value *retval)
80{
81 return (retval->func == FFA_MSG_SEND_DIRECT_RESP_SMC32) ||
82 (retval->func == FFA_MSG_SEND_DIRECT_RESP_SMC64);
83}
84
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -080085void spmd_logical_sp_set_spmc_initialized(void);
86void spmc_logical_sp_set_spmc_failure(void);
87
88int32_t spmd_logical_sp_init(void);
Raghu Krishnamurthy6a305142023-03-03 06:41:29 -080089bool is_spmd_logical_sp_dir_req_in_progress(
90 spmd_spm_core_context_t *ctx);
91
92bool spmd_el3_ffa_msg_direct_req(uint64_t x1,
93 uint64_t x2,
94 uint64_t x3,
95 uint64_t x4,
96 void *handle,
97 struct ffa_value *retval);
Raghu Krishnamurthy7f046c12023-02-25 13:26:10 -080098
99#endif /* EL3_SPMD_LOGICAL_SP_H */