Core: Move context information to the service db
This commit removes the ctx array, and moves all the service context
related data.
Two new dummy services are added, one for the non-secure PE, and one
for the core. The latter, TFM_SEC_FUNC_CORE_ID, is used as running
service when calling secure tests. This way the checks done at context
switch pass.
Change-Id: I4fc3cad59a57e8dea630c642b8c363cbacfd58f3
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index f6059cf..92263f7 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -20,6 +20,15 @@
SPM_ERR_INVALID_CONFIG,
};
+enum spm_part_state_t {
+ SPM_PART_STATE_UNINIT = 0,
+ SPM_PART_STATE_IDLE,
+ SPM_PART_STATE_RUNNING,
+ SPM_PART_STATE_SUSPENDED,
+ SPM_PART_STATE_BLOCKED,
+ SPM_PART_STATE_CLOSED,
+};
+
/**
* \brief Configure isolated sandbox for a service
*
@@ -76,6 +85,82 @@
uint32_t tfm_spm_service_get_stack_top(uint32_t service_id);
/**
+ * \brief Get the current state of a service
+ *
+ * \param[in] service_id Service id
+ *
+ * \return The state of the specified service
+ *
+ * \note This function doesn't check if service_id is valid.
+ * \note The returned value has the value set of \ref spm_part_state_t.
+ */
+uint32_t tfm_spm_service_get_state(uint32_t service_id);
+
+/**
+ * \brief Get the Id of the caller of the service given
+ *
+ * \param[in] service_id Service id to get the caller of
+ *
+ * \return The Id of the caller service
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+uint32_t tfm_spm_service_get_caller_service_id(uint32_t service_id);
+
+/**
+ * \brief Get the original PSP of the service
+ *
+ * \param[in] service_id Service id
+ *
+ * \return The original PSP of the service
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+uint32_t tfm_spm_service_get_orig_psp(uint32_t service_id);
+
+/**
+ * \brief Get the original PSP limit of the service
+ *
+ * \param[in] service_id Service id
+ *
+ * \return The original PSP limit of the service
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+uint32_t tfm_spm_service_get_orig_psplim(uint32_t service_id);
+
+/**
+ * \brief Get the original link register value of the service
+ *
+ * \param[in] service_id Service id
+ *
+ * \return The original link register value of the service
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+uint32_t tfm_spm_service_get_orig_lr(uint32_t service_id);
+
+/**
+ * \brief Get the buffer share region of the service
+ *
+ * \param[in] service_id Service id
+ *
+ * \return The buffer share region of the service
+ *
+ * \note This function doesn't check if service_id is valid.
+ * \note The returned value has the value set of \ref tfm_buffer_share_region_e
+ */
+uint32_t tfm_spm_service_get_share(uint32_t service_id);
+
+/**
+ * \brief Returns the id of the service that has running state
+ *
+ * \return The Id of the service with the running state, if there is any set.
+ * 0 otherwise.
+ */
+uint32_t tfm_spm_service_get_running_service_id(void);
+
+/**
* \brief Save stack pointer for service in database
*
* \param[in] service_id Service id
@@ -86,6 +171,71 @@
void tfm_spm_service_set_stack(uint32_t service_id, uint32_t stack_ptr);
/**
+ * \brief Set the current state of a service
+ *
+ * \param[in] service_id Service id
+ * \param[in] state The state to be set
+ *
+ * \note This function doesn't check if service_id is valid.
+ * \note The \ref state has to have the value set of \ref spm_part_state_t.
+ */
+void tfm_spm_service_set_state(uint32_t service_id, uint32_t state);
+
+/**
+ * \brief Set the caller service Id for a given service
+ *
+ * \param[in] service_id Service id
+ * \param[in] caller_service_id The Id of the caller service
+ *
+ * \note This function doesn't check if any of the service_ids is valid.
+ */
+void tfm_spm_service_set_caller_service_id(uint32_t service_id,
+ uint32_t caller_service_id);
+
+/**
+ * \brief Set the original PSP value of a service
+ *
+ * \param[in] service_id Service id
+ * \param[in] orig_psp The PSP value to set
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+void tfm_spm_service_set_orig_psp(uint32_t service_id, uint32_t orig_psp);
+
+/**
+ * \brief Set the original PSP limit value of a service
+ *
+ * \param[in] service_id Service id
+ * \param[in] orig_psplim The PSP limit value to set
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+void tfm_spm_service_set_orig_psplim(uint32_t service_id, uint32_t orig_psplim);
+
+/**
+ * \brief Set the original link register value of a service
+ *
+ * \param[in] service_id Service id
+ * \param[in] orig_lr The link register value to set
+ *
+ * \note This function doesn't check if service_id is valid.
+ */
+void tfm_spm_service_set_orig_lr(uint32_t service_id, uint32_t orig_lr);
+
+/**
+ * \brief Set the buffer share region of the service
+ *
+ * \param[in] service_id Service id
+ * \param[in] share The buffer share region to be set
+ *
+ * \return Error code \ref spm_err_t
+ *
+ * \note This function doesn't check if service_id is valid.
+ * \note share has to have the value set of \ref tfm_buffer_share_region_e
+ */
+enum spm_err_t tfm_spm_service_set_share(uint32_t service_id, uint32_t share);
+
+/**
* \brief Initialize service database
*
* \return Error code \ref spm_err_t
@@ -107,14 +257,12 @@
enum spm_err_t tfm_spm_service_init(void);
/**
- * \brief Set share region to which the service needs access
+ * \brief Clears the context info from the database for a service.
*
- * \param[in] share Share region id \ref tfm_buffer_share_region_e
- *
- * \return Error code \ref spm_err_t
+ * \param[in] service_id Service id
*
* \note This function doesn't check if service_id is valid.
*/
-enum spm_err_t tfm_spm_set_share_region(enum tfm_buffer_share_region_e share);
+void tfm_spm_service_cleanup_context(uint32_t service_id);
#endif /*__SPM_API_H__ */