]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
SPMD: introduce SPMC to SPMD messages
authorOlivier Deprez <olivier.deprez@arm.com>
Thu, 16 Apr 2020 14:59:21 +0000 (16:59 +0200)
committerMax Shvetsov <maksims.svecovs@arm.com>
Thu, 20 Aug 2020 17:06:06 +0000 (18:06 +0100)
FF-A interface to handle SPMC to SPMD direct messages requests.

Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Signed-off-by: Max Shvetsov <maksims.svecovs@arm.com>
Change-Id: Ia707a308c55561a31dcfa86e554ea1c9e23f862a

include/services/ffa_svc.h
services/std_svc/spmd/spmd_main.c
services/std_svc/spmd/spmd_private.h

index 728507749b07011bc47c0e428b46f95524275ce4..0513eab5e93dea3184586913ae9151c406f0cae4 100644 (file)
  */
 #define FFA_PARAM_MBZ                  U(0x0)
 
+/*
+ * Maximum FF-A endpoint id value
+ */
+#define FFA_ENDPOINT_ID_MAX                    U(1 << 16)
+
+/*
+ * Mask for source and destination endpoint id in
+ * a direct message request/response.
+ */
+#define FFA_DIRECT_MSG_ENDPOINT_ID_MASK                U(0xffff)
+
+/*
+ * Bit shift for destination endpoint id in a direct message request/response.
+ */
+#define FFA_DIRECT_MSG_DESTINATION_SHIFT       U(0)
+
+/*
+ * Bit shift for source endpoint id in a direct message request/response.
+ */
+#define FFA_DIRECT_MSG_SOURCE_SHIFT            U(16)
+
+/******************************************************************************
+ * ffa_endpoint_destination
+ *****************************************************************************/
+static inline uint16_t ffa_endpoint_destination(unsigned int ep)
+{
+       return (ep >> FFA_DIRECT_MSG_DESTINATION_SHIFT) &
+               FFA_DIRECT_MSG_ENDPOINT_ID_MASK;
+}
+
+/******************************************************************************
+ * ffa_endpoint_source
+ *****************************************************************************/
+static inline uint16_t ffa_endpoint_source(unsigned int ep)
+{
+       return (ep >> FFA_DIRECT_MSG_SOURCE_SHIFT) &
+               FFA_DIRECT_MSG_ENDPOINT_ID_MASK;
+}
+
 #endif /* FFA_SVC_H */
index 93a0203c5e54ad1b8171830a5b95a767c2fe38ab..cdbb9ca6e403806c6d2b2dc54c093539e4f4cb10 100644 (file)
@@ -322,8 +322,8 @@ static uint64_t spmd_smc_forward(uint32_t smc_fid,
                                 uint64_t x4,
                                 void *handle)
 {
-       uint32_t secure_state_in = (secure_origin) ? SECURE : NON_SECURE;
-       uint32_t secure_state_out = (!secure_origin) ? SECURE : NON_SECURE;
+       unsigned int secure_state_in = (secure_origin) ? SECURE : NON_SECURE;
+       unsigned int secure_state_out = (!secure_origin) ? SECURE : NON_SECURE;
 
        /* Save incoming security state */
        cm_el1_sysregs_context_save(secure_state_in);
@@ -355,6 +355,15 @@ static uint64_t spmd_ffa_error_return(void *handle, int error_code)
                 FFA_PARAM_MBZ, FFA_PARAM_MBZ);
 }
 
+/******************************************************************************
+ * spmd_is_spmc_message
+ *****************************************************************************/
+static bool spmd_is_spmc_message(unsigned int ep)
+{
+       return ((ffa_endpoint_destination(ep) == SPMD_DIRECT_MSG_ENDPOINT_ID)
+               && (ffa_endpoint_source(ep) == spmc_attrs.spmc_id));
+}
+
 /*******************************************************************************
  * This function handles all SMCs in the range reserved for FFA. Each call is
  * either forwarded to the other security state or handled by the SPM dispatcher
index e13a5f021c682dc830a19c7cce6d6cfd41113af4..7d5f47662e7c398499a8f375b97b508061980982 100644 (file)
@@ -55,11 +55,14 @@ typedef struct spmd_spm_core_context {
 /*
  * Reserve ID for NS physical FFA Endpoint.
  */
-#define FFA_NS_ENDPOINT_ID             U(0)
+#define FFA_NS_ENDPOINT_ID                     U(0)
 
-/* Mask and shift to check valid secure FFA Endpoint ID. */
-#define SPMC_SECURE_ID_MASK            U(1)
-#define SPMC_SECURE_ID_SHIFT           U(15)
+/* Mask and shift to check valid secure FF-A Endpoint ID. */
+#define SPMC_SECURE_ID_MASK                    U(1)
+#define SPMC_SECURE_ID_SHIFT                   U(15)
+
+#define SPMD_DIRECT_MSG_ENDPOINT_ID            U(FFA_ENDPOINT_ID_MAX - 1)
+#define SPMD_DIRECT_MSG_SET_ENTRY_POINT                U(1)
 
 /* Functions used to enter/exit SPMC synchronously */
 uint64_t spmd_spm_core_sync_entry(spmd_spm_core_context_t *ctx);