aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdison Ai <edison.ai@arm.com>2018-09-04 19:12:31 +0800
committerEdison Ai <edison.ai@arm.com>2019-01-22 10:38:59 +0800
commitb3e56967fca4a8bde0a55a424cd805ae77b8f8bd (patch)
tree88bca2d810a3083496daa5fc36bb57fd01f10b7c
parent7a3495d5caf16ff6cbadc77156bec0747cc98f36 (diff)
downloadtrusted-firmware-m-b3e56967fca4a8bde0a55a424cd805ae77b8f8bd.tar.gz
Core: Align with PSA FF specification 1.0-beta-0
- Renamed psa_error_t to psa_status_t - All functions that accept or return signals now use the psa_signal_t type - Removed PSA_CONNECTION_ACCEPTED and replaced its use in connection messages by PSA_SUCCESS - Added PSA_CONNECTION_BUSY to indicate transient error conditions during calls to psa_connect() and renumbered the PSA error codes - Removed psa_identity() and replaced it with client_id in psa_msg_t - Renamed psa_end() to psa_reply() - Combine psa_wait_any() and psa_wait_interrupt() into psa_wait(). Change-Id: Id3ba56f145a29aff297cc56e66810e0dbe0f913b Signed-off-by: Edison Ai <edison.ai@arm.com> Co-authored-by: Summer Qin <summer.qin@arm.com>
-rw-r--r--interface/include/psa_client.h129
-rw-r--r--interface/include/psa_service.h327
-rw-r--r--interface/include/tfm_api.h21
-rw-r--r--interface/src/tfm_psa_ns_api.c20
-rw-r--r--secure_fw/core/ipc/psa_api.c9
-rw-r--r--secure_fw/core/ipc/tfm_queue.c6
-rw-r--r--secure_fw/core/ipc/tfm_queue.h6
-rw-r--r--secure_fw/core/tfm_psa_api_client.c22
-rw-r--r--test/suites/ipc/non_secure/ipc_ns_interface_testsuite.c8
-rw-r--r--test/test_services/tfm_ipc_test/ipc_test_service.c18
10 files changed, 298 insertions, 268 deletions
diff --git a/interface/include/psa_client.h b/interface/include/psa_client.h
index dbe0e72a70..70534741a8 100644
--- a/interface/include/psa_client.h
+++ b/interface/include/psa_client.h
@@ -15,116 +15,125 @@ extern "C" {
#include <stdint.h>
#include <stddef.h>
-/* ******** ******** PSA Common API ******** ******** */
+/*********************** PSA Client Macros and Types *************************/
-/* FixMe: PSA FF v0.9 has not been released. All PSA API subject to change */
-#define PSA_FRAMEWORK_VERSION (0x0009)
+#define PSA_FRAMEWORK_VERSION (0x0100)
#define PSA_VERSION_NONE (0)
/* PSA response types */
#define PSA_SUCCESS (0)
#define PSA_CONNECTION_REFUSED (INT32_MIN + 1)
+#define PSA_CONNECTION_BUSY (INT32_MIN + 2)
#define PSA_DROP_CONNECTION (INT32_MIN)
/* PSA message handles */
#define PSA_NULL_HANDLE ((psa_handle_t)0)
-typedef int32_t psa_error_t;
+typedef int32_t psa_status_t;
typedef int32_t psa_handle_t;
/**
- * A read-only input memory region provided to a RoT Service.
+ * A read-only input memory region provided to an RoT Service.
*/
typedef struct psa_invec {
- const void *base; /*!< the start address of the memory buffer */
- size_t len; /*!< the size in bytes */
+ const void *base; /*!< the start address of the memory buffer */
+ size_t len; /*!< the size in bytes */
} psa_invec;
/**
- * A writable output memory region provided to a RoT Service.
+ * A writable output memory region provided to an RoT Service.
*/
typedef struct psa_outvec {
- void *base; /*!< the start address of the memory buffer */
- size_t len; /*!< the size in bytes */
+ void *base; /*!< the start address of the memory buffer */
+ size_t len; /*!< the size in bytes */
} psa_outvec;
+/*************************** PSA Client API **********************************/
+
/**
* \brief Retrieve the version of the PSA Framework API that is implemented.
*
- * \return The version of the PSA Framework implementation that is providing
- * the runtime services to the caller.
- * \return The major and minor version are encoded as follows:
- * \arg version[15:8] -- major version number
- * \arg version[7:0] -- minor version number
+ * \return version The version of the PSA Framework implementation
+ * that is providing the runtime services to the
+ * caller. The major and minor version are encoded
+ * as follows:
+ * \arg version[15:8] -- major version number.
+ * \arg version[7:0] -- minor version number.
*/
uint32_t psa_framework_version(void);
-/* ******** ******** PSA Client API ******** ******** */
-
/**
- * \brief Retrieve the minor version of a RoT Service or indicate that
- * it is not present on this system.
+ * \brief Retrieve the minor version of an RoT Service or indicate that it is
+ * not present on this system.
*
- * \param[in] sid ID of the RoT Service to query
+ * \param[in] sid ID of the RoT Service to query.
*
- * \retval PSA_VERSION_NONE The RoT Service is not implemented, or the
- * caller is not permitted to access the service
- * \retval >0 The minor version of the implemented RoT Service
+ * \retval PSA_VERSION_NONE The RoT Service is not implemented, or the
+ * caller is not permitted to access the service.
+ * \retval > 0 The minor version of the implemented RoT
+ * Service.
*/
uint32_t psa_version(uint32_t sid);
/**
- * \brief Connect to a RoT Service by its SID.
+ * \brief Connect to an RoT Service by its SID.
*
- * \param[in] sid ID of the RoT Service to connect to
- * \param[in] minor_version Requested version of the RoT Service
+ * \param[in] sid ID of the RoT Service to connect to.
+ * \param[in] minor_version Requested version of the RoT Service.
*
- * \retval >0 A handle for the connection
- * \retval PSA_CONNECTION_REFUSED The RoT Service has refused the connection
- * \retval "Does not return" The RoT Service ID and version are not
- * supported, or the caller is not permitted
- * to access the service
+ * \retval > 0 A handle for the connection.
+ * \retval PSA_CONNECTION_REFUSED The SPM or RoT Service has refused the
+ * connection.
+ * \retval PSA_CONNECTION_BUSY The SPM or RoT Service cannot make the
+ * connection at the moment.
+ * \retval "Does not return" The RoT Service ID and version are not
+ * supported, or the caller is not permitted to
+ * access the service.
*/
psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version);
/**
- * \brief Calls a RoT Service on an established connection.
+ * \brief Call an RoT Service on an established connection.
*
- * \param[in] handle A handle to an established connection
- * \param[in] in_vec Array of input \ref psa_invec structures
- * \param[in] in_len Number of input \ref psa_invec structures
- * \param[in] out_vec Array of input \ref psa_outvec structures
- * \param[in] in_len Number of input \ref psa_outvec structures
+ * \param[in] handle A handle to an established connection.
+ * \param[in] in_vec Array of input \ref psa_invec structures.
+ * \param[in] in_len Number of input \ref psa_invec structures.
+ * \param[in/out] out_vec Array of output \ref psa_outvec structures.
+ * \param[in] out_len Number of output \ref psa_outvec structures.
*
- * \retval >=0 Application-specific return code
- * \retval <0 Application-specific error code
- * \retval PSA_DROP_CONNECTION The connection has been dropped by the RoT
- * Service. This indicates that either this or
- * a previous message was invalid
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg An invalid handle was passed
- * \arg An invalid memory reference was provided
- * \arg in_len + out_len > PSA_MAX_IOVEC
- * \arg The message is unrecognized by the RoT Service
- * or incorrectly formatted
+ * \retval >=0 RoT Service-specific status value.
+ * \retval <0 RoT Service-specific error code.
+ * \retval PSA_DROP_CONNECTION The connection has been dropped by the RoT
+ * Service. This indicates that either this or
+ * a previous message was invalid.
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg An invalid handle was passed.
+ * \arg The connection is already handling a request.
+ * \arg An invalid memory reference was provided.
+ * \arg in_len + out_len > PSA_MAX_IOVEC.
+ * \arg The message is unrecognized by the RoT
+ * Service or incorrectly formatted.
*/
-psa_error_t psa_call(psa_handle_t handle,
- const psa_invec *in_vec,
- size_t in_len,
- const psa_outvec *out_vec,
- size_t out_len);
+psa_status_t psa_call(psa_handle_t handle,
+ const psa_invec *in_vec,
+ size_t in_len,
+ psa_outvec *out_vec,
+ size_t out_len);
/**
- * \brief Closes a connection to a RoT Service.
+ * \brief Close a connection to an RoT Service.
*
- * \param[in] handle A handle to an established connection, or the
- * null handle
+ * \param[in] handle A handle to an established connection, or the
+ * null handle.
*
- * \retval void Success
- * \retval "Does not return" An invalid handle was provided that is not the
- * null handle
+ * \retval void Success.
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg An invalid handle was provided that is not
+ * the null handle.
+ * \arg The connection is handling a request.
*/
void psa_close(psa_handle_t handle);
diff --git a/interface/include/psa_service.h b/interface/include/psa_service.h
index 38467b0a7b..753fab76c5 100644
--- a/interface/include/psa_service.h
+++ b/interface/include/psa_service.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -14,11 +14,16 @@ extern "C" {
#include <inttypes.h>
+/********************** PSA Secure Partition Macros and Types ****************/
+
/* PSA wait timeouts */
#define PSA_POLL (0x00000000u)
#define PSA_BLOCK (0x80000000u)
-/* doorbell signal */
+/* A mask value that includes all Secure Partition signals */
+#define PSA_WAIT_ANY (~0u)
+
+/* Doorbell signal */
#define PSA_DOORBELL (0x00000008u)
/* PSA message types */
@@ -26,227 +31,219 @@ extern "C" {
#define PSA_IPC_CALL (2)
#define PSA_IPC_DISCONNECT (3)
-/* PSA response types */
-#define PSA_CONNECTION_ACCEPTED (0)
-
-/* maximum number of input and output vectors */
+/* Maximum number of input and output vectors */
#define PSA_MAX_IOVEC (4)
+/* Return code from psa_get() */
+#define PSA_ERR_NOMSG (INT32_MIN + 3)
+
+/* Store a set of one or more Secure Partition signals */
typedef uint32_t psa_signal_t;
/**
- * Describes a message received by a RoT Service after calling \ref psa_get().
+ * Describe a message received by an RoT Service after calling \ref psa_get().
*/
typedef struct psa_msg_t {
- uint32_t type;
- psa_handle_t handle;
- void *rhandle;
- size_t in_size[PSA_MAX_IOVEC];
- size_t out_size[PSA_MAX_IOVEC];
+ uint32_t type; /* One of the following values:
+ * \ref PSA_IPC_CONNECT
+ * \ref PSA_IPC_CALL
+ * \ref PSA_IPC_DISCONNECT
+ */
+ psa_handle_t handle; /* A reference generated by the SPM to the
+ * message returned by psa_get().
+ */
+ int32_t client_id; /* Partition ID of the sender of the message */
+ void *rhandle; /* Be useful for binding a connection to some
+ * application-specific data or function
+ * pointer within the RoT Service
+ * implementation.
+ */
+ size_t in_size[PSA_MAX_IOVEC]; /* Provide the size of each client input
+ * vector in bytes.
+ */
+ size_t out_size[PSA_MAX_IOVEC];/* Provide the size of each client output
+ * vector in bytes.
+ */
} psa_msg_t;
-/* ******** ******** PSA Secure Function API ******** ******** */
+/************************* PSA Secure Partition API **************************/
/**
- * \brief Returns the set of signals that have been asserted for a Sercure
- * Partition.
+ * \brief Return the Secure Partition interrupt signals that have been asserted
+ * from a subset of signals provided by the caller.
*
- * \param[in] timeout Specify either blocking or polling operation
+ * \param[in] signal_mask A set of signals to query. Signals that are not
+ * in this set will be ignored.
+ * \param[in] timeout Specify either blocking \ref PSA_BLOCK or
+ * polling \ref PSA_POLL operation.
*
- * \retval >0 At least one signal is asserted
- * \retval 0 No signals are asserted. This is only seen if the
- * caller used a polling timeout
+ * \retval >0 At least one signal is asserted.
+ * \retval 0 No signals are asserted. This is only seen when
+ * a polling timeout is used.
*/
-uint32_t psa_wait_any(uint32_t timeout);
+psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout);
/**
- * \brief Returns the Secure Partition interrupt signals that have been
- * asserted from the subset of signals indicated in the bitmask provided.
- *
- * \param[in] signal_mask A set of interrupt and doorbell signals to query.
- * Signals that are not in this set will be ignored
- * \param[in] timeout Specify either blocking or polling operation
- *
- * \retval >0 At least one signal is asserted
- * \retval 0 No signals are asserted. This case is only seen if
- * caller used a polling timeout
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg signal_mask does not include any interrupt or
- * doorbell signals
- * \arg signal_mask includes one or more RoT Service
- * signals
- */
-uint32_t psa_wait_interrupt(psa_signal_t signal_mask, uint32_t timeout);
-
-/**
- * \brief Get the message which corresponds to a given RoT Service signal
+ * \brief Retrieve the message which corresponds to a given RoT Service signal
* and remove the message from the RoT Service queue.
*
- * \param[in] signal The signal value for an asserted RoT Service
- * \param[out] msg Pointer to \ref psa_msg_t object for receiving
- * the message
- *
- * \retval void Success
- * \retval "Does not return" The call is invalid because one or more of the
- * following are true:
- * \arg signal has more than a single bit set
- * \arg signal does not correspond to a RoT Service
- * \arg The RoT Service signal is not currently asserted
- * \arg The msg pointer provided is not a valid memory
- * reference
+ * \param[in] signal The signal value for an asserted RoT Service.
+ * \param[out] msg Pointer to \ref psa_msg_t object for receiving
+ * the message.
+ *
+ * \retval PSA_SUCCESS Success, *msg will contain the delivered
+ * message.
+ * \retval PSA_ERR_NOMSG Message could not be delivered.
+ * \retval "Does not return" The call is invalid because one or more of the
+ * following are true:
+ * \arg signal has more than a single bit set.
+ * \arg signal does not correspond to an RoT Service.
+ * \arg The RoT Service signal is not currently
+ * asserted.
+ * \arg The msg pointer provided is not a valid memory
+ * reference.
*/
-void psa_get(psa_signal_t signal, psa_msg_t *msg);
+psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg);
/**
- * \brief Get the Partition ID of the sender of a message.
- *
- * \param[in] msg_handle Message handle for an incoming message
+ * \brief Associate some RoT Service private data with a client connection.
*
- * \retval >0 ID of a Secure Partition
- * \retval <0 ID of an NSPE client
- * \retval "Does not return" msg_handle is invalid
+ * \param[in] msg_handle Handle for the client's message.
+ * \param[in] rhandle Reverse handle allocated by the RoT Service.
*
- * \note Bit[31] is set if the caller is from the NSPE.
- */
-int32_t psa_identity(psa_handle_t msg_handle);
-
-/**
- * \brief Associates some caller-provided private data with a specified client
- * connection.
- *
- * \param[in] msg_handle Handle for the client's message
- * \param[in] rhandle Reverse handle allocated by the RoT Service
- *
- * \retval void Success, rhandle will be provided with all
- * subsequent messages delivered on this connection
- * \retval "Does not return" msg_handle is invalid
+ * \retval void Success, rhandle will be provided with all
+ * subsequent messages delivered on this
+ * connection.
+ * \retval "Does not return" msg_handle is invalid.
*/
void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle);
/**
- * \brief Read a message parameter or part of a message parameter from the
- * client input vector.
- *
- * \param[in] msg_handle Handle for the client's message
- * \param[in] invec_idx Index of the input vector to read from. Must be
- * less than \ref PSA_MAX_IOVEC
- * \param[out] buffer Buffer in the Secure Partition to copy the
- * requested data to
- * \param[in] num_bytes Maximum number of bytes to be read from the client
- * input vector
- *
- * \retval >0 Number of bytes copied
- * \retval 0 There was no remaining data in this input vector
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg msg_handle is invalid
- * \arg msg_handle does not refer to a \ref PSA_IPC_CALL
- * message
- * \arg invec_idx is equal to or greater than
- * PSA_MAX_IOVEC
- * \arg the memory reference for buffer is invalid or
- * not writable
+ * \brief Read a message parameter or part of a message parameter from a client
+ * input vector.
+ *
+ * \param[in] msg_handle Handle for the client's message.
+ * \param[in] invec_idx Index of the input vector to read from. Must be
+ * less than \ref PSA_MAX_IOVEC.
+ * \param[out] buffer Buffer in the Secure Partition to copy the
+ * requested data to.
+ * \param[in] num_bytes Maximum number of bytes to be read from the
+ * client input vector.
+ *
+ * \retval >0 Number of bytes copied.
+ * \retval 0 There was no remaining data in this input
+ * vector.
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg msg_handle is invalid.
+ * \arg msg_handle does not refer to a
+ * \ref PSA_IPC_CALL message.
+ * \arg invec_idx is equal to or greater than
+ * \ref PSA_MAX_IOVEC.
+ * \arg the memory reference for buffer is invalid or
+ * not writable.
*/
size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
- void *buffer, size_t num_bytes);
+ void *buffer, size_t num_bytes);
/**
- * \brief Skip a given number of bytes for an input vector.
- *
- * \param[in] msg_handle Handle for the client's message
- * \param[in] invec_idx Index of input vector in message to skip from.
- * Must be less than \ref PSA_MAX_IOVEC
- * \param[in] num_bytes Maximum number of bytes to skip in the client input
- * vector
- *
- * \retval >0 Number of bytes skipped
- * \retval 0 There was no remaining data in this input vector
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg msg_handle is invalid
- * \arg msg_handle does not refer to a \ref PSA_IPC_CALL
- * message
- * \arg invec_idx is equal to or greater than
- * PSA_MAX_IOVEC
+ * \brief Skip over part of a client input vector.
+ *
+ * \param[in] msg_handle Handle for the client's message.
+ * \param[in] invec_idx Index of input vector to skip from. Must be
+ * less than \ref PSA_MAX_IOVEC.
+ * \param[in] num_bytes Maximum number of bytes to skip in the client
+ * input vector.
+ *
+ * \retval >0 Number of bytes skipped.
+ * \retval 0 There was no remaining data in this input
+ * vector.
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg msg_handle is invalid.
+ * \arg msg_handle does not refer to a
+ * \ref PSA_IPC_CALL message.
+ * \arg invec_idx is equal to or greater than
+ * \ref PSA_MAX_IOVEC.
*/
size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes);
/**
- * \brief Write a message response to the client output vector.
- *
- * \param[in] msg_handle Handle for the client's message
- * \param[out] outvec_idx Index of output vector in message to write to.
- * Must be less than \ref PSA_MAX_IOVEC
- * \param[in] buffer Buffer with the data to write
- * \param[in] num_bytes Number of bytes to write to the client output
- * vector
- *
- * \retval void Success
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg msg_handle is invalid
- * \arg msg_handle does not refer to a \ref PSA_IPC_CALL
- * message
- * \arg outvec_idx is equal to or greater than
- * \ref PSA_MAX_IOVEC
- * \arg the memory reference for buffer is invalid
- * \arg the call attempts to write data past the end of
- * the client output vector
+ * \brief Write a message response to a client output vector.
+ *
+ * \param[in] msg_handle Handle for the client's message.
+ * \param[out] outvec_idx Index of output vector in message to write to.
+ * Must be less than \ref PSA_MAX_IOVEC.
+ * \param[in] buffer Buffer with the data to write.
+ * \param[in] num_bytes Number of bytes to write to the client output
+ * vector.
+ *
+ * \retval void Success
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg msg_handle is invalid.
+ * \arg msg_handle does not refer to a
+ * \ref PSA_IPC_CALL message.
+ * \arg outvec_idx is equal to or greater than
+ * \ref PSA_MAX_IOVEC.
+ * \arg The memory reference for buffer is invalid.
+ * \arg The call attempts to write data past the end
+ * of the client output vector.
*/
void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
- const void *buffer, size_t num_bytes);
+ const void *buffer, size_t num_bytes);
/**
- * \brief Completes handling of a specific message and unblocks the client.
- *
- * \param[in] msg_handle Handle for the client's message or the null handle
- * \param[in] retval Return value to be reported to the client
- *
- * \retval void Success
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg msg_handle is invalid and is not the null handle
- * \arg An invalid return code is specified for the type
- * of message
+ * \brief Complete handling of a specific message and unblock the client.
+ *
+ * \param[in] msg_handle Handle for the client's message.
+ * \param[in] status Message result value to be reported to the
+ * client.
+ *
+ * \retval void Success.
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg msg_handle is invalid.
+ * \arg An invalid status code is specified for the
+ * type of message.
*/
-void psa_end(psa_handle_t msg_handle, psa_error_t retval);
+void psa_reply(psa_handle_t msg_handle, psa_status_t status);
/**
- * \brief Sends a PSA_DOORBELL signal to a specific Secure Partition.
+ * \brief Send a PSA_DOORBELL signal to a specific Secure Partition.
*
- * \param[in] partition_id Secure Partition ID of the target partition
+ * \param[in] partition_id Secure Partition ID of the target partition.
*
- * \retval void Success
- * \retval "Does not return" partition_id does not correspond to a Secure
- * Partition
+ * \retval void Success.
+ * \retval "Does not return" partition_id does not correspond to a Secure
+ * Partition.
*/
void psa_notify(int32_t partition_id);
/**
- * \brief Clears the PSA_DOORBELL signal.
+ * \brief Clear the PSA_DOORBELL signal.
*
* \param[in] void
*
- * \retval void Success
- * \retval "Does not return" The Secure Partition's doorbell signal is not
- * currently asserted
+ * \retval void Success.
+ * \retval "Does not return" The Secure Partition's doorbell signal is not
+ * currently asserted.
*/
void psa_clear(void);
/**
- * \brief Informs the SPM that an interrupt has been handled (end of interrupt).
+ * \brief Inform the SPM that an interrupt has been handled (end of interrupt).
*
- * \param[in] irq_signal The interrupt signal that has been processed
+ * \param[in] irq_signal The interrupt signal that has been processed.
*
- * \retval void Success
- * \retval "Does not return" The call is invalid, one or more of the following
- * are true:
- * \arg irq_signal is not an interrupt signal
- * \arg irq_signal indicates more than one signal
- * \arg irq_signal is not currently asserted
+ * \retval void Success.
+ * \retval "Does not return" The call is invalid, one or more of the
+ * following are true:
+ * \arg irq_signal is not an interrupt signal.
+ * \arg irq_signal indicates more than one signal.
+ * \arg irq_signal is not currently asserted.
*/
-void psa_eoi(uint32_t irq_signal);
+void psa_eoi(psa_signal_t irq_signal);
#ifdef __cplusplus
}
diff --git a/interface/include/tfm_api.h b/interface/include/tfm_api.h
index 527a433b8a..7656908fa4 100644
--- a/interface/include/tfm_api.h
+++ b/interface/include/tfm_api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -75,6 +75,13 @@ enum tfm_status_e
enum tfm_status_e tfm_register_client_id (int32_t ns_client_id);
/**
+ * \brief Retrieve the version of the PSA Framework API that is implemented
+ *
+ * \return The version of the PSA Framework
+ */
+uint32_t tfm_psa_framework_version_veneer(void);
+
+/**
* \brief Return version of secure function provided by secure binary
*
* \param[in] sid ID of secure service
@@ -100,20 +107,20 @@ psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t minor_version);
* \param[in] in_vecs invec containing pointer/count of input vectors
* \param[in] out_vecs invec containing pointer/count of output vectors
*
- * \return Returns \ref psa_error_t error code
+ * \return Returns \ref psa_status_t status code
*/
-psa_error_t tfm_psa_call_veneer(psa_handle_t handle,
- const psa_invec *in_vecs,
- const psa_invec *out_vecs);
+psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
+ const psa_invec *in_vecs,
+ const psa_invec *out_vecs);
/**
* \brief Close connection to secure function referenced by a connection handle
*
* \param[in] handle Handle to connection
*
- * \return Returns \ref psa_error_t error code
+ * \return Returns \ref psa_status_t status code
*/
-psa_error_t tfm_psa_close_veneer(psa_handle_t handle);
+psa_status_t tfm_psa_close_veneer(psa_handle_t handle);
//================ End Secure function declarations ==========================//
diff --git a/interface/src/tfm_psa_ns_api.c b/interface/src/tfm_psa_ns_api.c
index 45e80821e4..159eef9088 100644
--- a/interface/src/tfm_psa_ns_api.c
+++ b/interface/src/tfm_psa_ns_api.c
@@ -11,6 +11,15 @@
/**** API functions ****/
+uint32_t psa_framework_version(void)
+{
+ return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_framework_version_veneer,
+ 0,
+ 0,
+ 0,
+ 0);
+}
+
uint32_t psa_version(uint32_t sid)
{
return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_version_veneer,
@@ -29,11 +38,11 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version)
0);
}
-psa_error_t psa_call(psa_handle_t handle,
- const psa_invec *in_vec,
- size_t in_len,
- const psa_outvec *out_vec,
- size_t out_len)
+psa_status_t psa_call(psa_handle_t handle,
+ const psa_invec *in_vec,
+ size_t in_len,
+ psa_outvec *out_vec,
+ size_t out_len)
{
/* FixMe: sanity check can be added to offload some NS thread checks from
* TFM secure API
@@ -43,6 +52,7 @@ psa_error_t psa_call(psa_handle_t handle,
* serialization in order for NS to pass arguments to S
*/
psa_invec in_vecs, out_vecs;
+
in_vecs.base = in_vec;
in_vecs.len = in_len;
out_vecs.base = out_vec;
diff --git a/secure_fw/core/ipc/psa_api.c b/secure_fw/core/ipc/psa_api.c
index d0a19840d3..5c5f593d1c 100644
--- a/secure_fw/core/ipc/psa_api.c
+++ b/secure_fw/core/ipc/psa_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Service APIs */
/* FixMe: Initial prototype. */
-uint32_t psa_wait_any(uint32_t timeout)
+psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)
{
uint32_t msg_signals = 0;
@@ -31,14 +31,15 @@ uint32_t psa_wait_any(uint32_t timeout)
return msg_signals;
}
-void psa_get(psa_signal_t signal, psa_msg_t *msg)
+psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg)
{
if (msg) {
tfm_queue_get_msg_body(msg);
}
+ return PSA_SUCCESS;
}
-void psa_end(psa_handle_t msg_handle, psa_error_t retval)
+void psa_reply(psa_handle_t msg_handle, psa_status_t status)
{
struct tfm_msg_queue_item *q_msg = (struct tfm_msg_queue_item *)msg_handle;
diff --git a/secure_fw/core/ipc/tfm_queue.c b/secure_fw/core/ipc/tfm_queue.c
index 4a07aed117..7143801599 100644
--- a/secure_fw/core/ipc/tfm_queue.c
+++ b/secure_fw/core/ipc/tfm_queue.c
@@ -45,9 +45,9 @@ uint32_t tfm_queue_get_msg_signal(void)
return q_used->signal;
}
-psa_error_t tfm_queue_put_msg(psa_signal_t signal, uint32_t type,
- psa_invec *invec, size_t in_len,
- psa_outvec *outvec, size_t out_len)
+psa_status_t tfm_queue_put_msg(psa_signal_t signal, uint32_t type,
+ psa_invec *invec, size_t in_len,
+ psa_outvec *outvec, size_t out_len)
{
uint32_t i;
diff --git a/secure_fw/core/ipc/tfm_queue.h b/secure_fw/core/ipc/tfm_queue.h
index 9711addaff..afa530d6c7 100644
--- a/secure_fw/core/ipc/tfm_queue.h
+++ b/secure_fw/core/ipc/tfm_queue.h
@@ -26,9 +26,9 @@ struct tfm_msg_queue_item {
void tfm_queue_init(void);
uint32_t tfm_queue_get_msg_signal(void);
-psa_error_t tfm_queue_put_msg(psa_signal_t signal, uint32_t type,
- psa_invec *invec, size_t in_len,
- psa_outvec *outvec, size_t out_len);
+psa_status_t tfm_queue_put_msg(psa_signal_t signal, uint32_t type,
+ psa_invec *invec, size_t in_len,
+ psa_outvec *outvec, size_t out_len);
void tfm_queue_get_msg_body(psa_msg_t *msg);
void *memcpy_m(void *dst, const void *src, uint32_t size);
diff --git a/secure_fw/core/tfm_psa_api_client.c b/secure_fw/core/tfm_psa_api_client.c
index e7673e2cc2..fb938298f8 100644
--- a/secure_fw/core/tfm_psa_api_client.c
+++ b/secure_fw/core/tfm_psa_api_client.c
@@ -75,6 +75,12 @@ int32_t tfm_core_ns_ipc_request(void *fn, int32_t arg1, int32_t arg2,
* They won't call legacy SFN but instead will be handlers for TF-M
*/
+__tfm_secure_gateway_attributes__
+uint32_t tfm_psa_framework_version_veneer(void)
+{
+ return PSA_FRAMEWORK_VERSION;
+}
+
uint32_t tfm_psa_version_handler(uint32_t sid)
{
/* perform sanity check */
@@ -116,9 +122,9 @@ psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t minor_version)
0, 0);
}
-psa_error_t tfm_psa_call_handler(psa_handle_t handle,
- const psa_invec *in_vecs,
- const psa_invec *out_vecs)
+psa_status_t tfm_psa_call_handler(psa_handle_t handle,
+ const psa_invec *in_vecs,
+ const psa_invec *out_vecs)
{
/* perform sanity check */
/* In case of library model, call the function referenced by the handle
@@ -135,15 +141,15 @@ psa_error_t tfm_psa_call_handler(psa_handle_t handle,
}
__tfm_secure_gateway_attributes__
-psa_error_t tfm_psa_call_veneer(psa_handle_t handle,
- const psa_invec *in_vecs,
- const psa_invec *out_vecs)
+psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
+ const psa_invec *in_vecs,
+ const psa_invec *out_vecs)
{
TFM_CORE_NS_IPC_REQUEST_VENEER(tfm_psa_call_handler, handle, in_vecs,
out_vecs, 0);
}
-psa_error_t tfm_psa_close_handler(psa_handle_t handle)
+psa_status_t tfm_psa_close_handler(psa_handle_t handle)
{
/* perform sanity check */
/* Close connection referenced by handle */
@@ -156,7 +162,7 @@ psa_error_t tfm_psa_close_handler(psa_handle_t handle)
}
__tfm_secure_gateway_attributes__
-psa_error_t tfm_psa_close_veneer(psa_handle_t handle)
+psa_status_t tfm_psa_close_veneer(psa_handle_t handle)
{
TFM_CORE_NS_IPC_REQUEST_VENEER(tfm_psa_close_handler, handle, 0, 0, 0);
}
diff --git a/test/suites/ipc/non_secure/ipc_ns_interface_testsuite.c b/test/suites/ipc/non_secure/ipc_ns_interface_testsuite.c
index afd6522fd8..157f05157e 100644
--- a/test/suites/ipc/non_secure/ipc_ns_interface_testsuite.c
+++ b/test/suites/ipc/non_secure/ipc_ns_interface_testsuite.c
@@ -114,16 +114,16 @@ static void tfm_ipc_test_1004(struct test_result_t *ret)
struct psa_outvec outvecs[2] = {{str3, sizeof(str3)/sizeof(char)},
{str4, sizeof(str4)/sizeof(char)}};
psa_handle_t handle;
- psa_error_t err;
+ psa_status_t status;
uint32_t min_version;
min_version = psa_version(IPC_TEST_SERVICE1_SID);
TEST_LOG("TFM service support minor version is %d.\r\n", min_version);
handle = psa_connect(IPC_TEST_SERVICE1_SID, IPC_TEST_SERVICE1_MIN_VER);
- err = psa_call(handle, invecs, 2, outvecs, 2);
- if (err >= 0) {
+ status = psa_call(handle, invecs, 2, outvecs, 2);
+ if (status >= 0) {
TEST_LOG("psa_call is successful!\r\n");
- } else if (err == PSA_DROP_CONNECTION) {
+ } else if (status == PSA_DROP_CONNECTION) {
TEST_FAIL("The connection has been dropped by the RoT Service!\r\n");
return;
} else {
diff --git a/test/test_services/tfm_ipc_test/ipc_test_service.c b/test/test_services/tfm_ipc_test/ipc_test_service.c
index 404493f703..5d0af4443a 100644
--- a/test/test_services/tfm_ipc_test/ipc_test_service.c
+++ b/test/test_services/tfm_ipc_test/ipc_test_service.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -19,7 +19,7 @@
static int inuse = 0;
-static int ipc_service_connect(psa_msg_t *msg)
+static psa_status_t ipc_service_connect(psa_msg_t *msg)
{
uint32_t minor_version;
@@ -35,10 +35,10 @@ static int ipc_service_connect(psa_msg_t *msg)
if (minor_version == 0) {
return PSA_CONNECTION_REFUSED;
}
- return PSA_CONNECTION_ACCEPTED;
+ return PSA_SUCCESS;
}
-static psa_error_t ipc_service_call(psa_msg_t *msg)
+static psa_status_t ipc_service_call(psa_msg_t *msg)
{
int i;
uint8_t rec_buf[IPC_SERVICE_BUFFER_LEN];
@@ -62,10 +62,10 @@ static void *ipc_test_partition_main(void *param)
{
uint32_t signals = 0;
psa_msg_t msg;
- int r;
+ psa_status_t r;
while (1) {
- signals = psa_wait_any(PSA_BLOCK);
+ signals = psa_wait(PSA_WAIT_ANY, PSA_BLOCK);
printf("ipc get signals 0x%x\r\n", signals);
@@ -79,15 +79,15 @@ static void *ipc_test_partition_main(void *param)
inuse = 1;
r = ipc_service_connect(&msg);
}
- psa_end(msg.handle, r);
+ psa_reply(msg.handle, r);
break;
case PSA_IPC_CALL:
- psa_end(msg.handle, ipc_service_call(&msg));
+ psa_reply(msg.handle, ipc_service_call(&msg));
break;
case PSA_IPC_DISCONNECT:
assert (inuse == 1);
inuse = 0;
- psa_end(msg.handle, PSA_SUCCESS);
+ psa_reply(msg.handle, PSA_SUCCESS);
break;
default:
/* cannot get here? [broken SPM]. TODO*/