Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2017, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __SPM_API_H__ |
| 9 | #define __SPM_API_H__ |
| 10 | |
| 11 | /* This file contains the apis exported by the SPM to tfm core */ |
| 12 | #include "service_defs.h" |
| 13 | #include "secure_fw/core/tfm_secure_api.h" |
| 14 | |
| 15 | enum spm_err_t { |
| 16 | SPM_ERR_OK = 0, |
| 17 | SPM_ERR_SERV_DB_NOT_INIT, |
| 18 | SPM_ERR_SERV_ALREADY_ACTIVE, |
| 19 | SPM_ERR_SERV_NOT_AVAILABLE, |
| 20 | SPM_ERR_INVALID_CONFIG, |
| 21 | }; |
| 22 | |
| 23 | /** |
| 24 | * \brief Configure isolated sandbox for a service |
| 25 | * |
| 26 | * \param[in] service_id Service id |
| 27 | * |
| 28 | * \return Error code \ref spm_err_t |
| 29 | * |
| 30 | * \note This function doesn't check if service_id is valid. |
| 31 | */ |
| 32 | enum spm_err_t tfm_spm_service_sandbox_config(uint32_t service_id); |
| 33 | |
| 34 | /** |
| 35 | * \brief Deconfigure sandbox for a service |
| 36 | * |
| 37 | * \param[in] service_id Service id |
| 38 | * |
| 39 | * \return Error code \ref spm_err_t |
| 40 | * |
| 41 | * \note This function doesn't check if service_id is valid. |
| 42 | */ |
| 43 | enum spm_err_t tfm_spm_service_sandbox_deconfig(uint32_t service_id); |
| 44 | |
| 45 | /** |
| 46 | * \brief Get saved stack pointer for a partition |
| 47 | * |
| 48 | * \param[in] service_id Service id |
| 49 | * |
| 50 | * \return Stack pointer value |
| 51 | * |
| 52 | * \note This function doesn't check if service_id is valid. |
| 53 | */ |
| 54 | uint32_t tfm_spm_service_get_stack(uint32_t service_id); |
| 55 | |
| 56 | /** |
| 57 | * \brief Get bottom of stack region for a service |
| 58 | * |
| 59 | * \param[in] service_id Service id |
| 60 | * |
| 61 | * \return Stack region bottom value |
| 62 | * |
| 63 | * \note This function doesn't check if service_id is valid. |
| 64 | */ |
| 65 | uint32_t tfm_spm_service_get_stack_bottom(uint32_t service_id); |
| 66 | |
| 67 | /** |
| 68 | * \brief Get top of stack region for a service |
| 69 | * |
| 70 | * \param[in] service_id Service id |
| 71 | * |
| 72 | * \return Stack region top value |
| 73 | * |
| 74 | * \note This function doesn't check if service_id is valid. |
| 75 | */ |
| 76 | uint32_t tfm_spm_service_get_stack_top(uint32_t service_id); |
| 77 | |
| 78 | /** |
| 79 | * \brief Save stack pointer for service in database |
| 80 | * |
| 81 | * \param[in] service_id Service id |
| 82 | * \param[in] stack_ptr Stack pointer to be stored |
| 83 | * |
| 84 | * \note This function doesn't check if service_id is valid. |
| 85 | */ |
| 86 | void tfm_spm_service_set_stack(uint32_t service_id, uint32_t stack_ptr); |
| 87 | |
| 88 | /** |
| 89 | * \brief Initialize service database |
| 90 | * |
| 91 | * \return Error code \ref spm_err_t |
| 92 | */ |
| 93 | enum spm_err_t tfm_spm_db_init(void); |
| 94 | |
| 95 | /** |
| 96 | * \brief Apply default MPU configuration for execution |
| 97 | * |
| 98 | * \return Error code \ref spm_err_t |
| 99 | */ |
| 100 | enum spm_err_t tfm_spm_mpu_init(void); |
| 101 | |
| 102 | /** |
| 103 | * \brief Execute service init function |
| 104 | * |
| 105 | * \return Error code \ref spm_err_t |
| 106 | */ |
| 107 | enum spm_err_t tfm_spm_service_init(void); |
| 108 | |
| 109 | /** |
| 110 | * \brief Set share region to which the service needs access |
| 111 | * |
| 112 | * \param[in] share Share region id \ref tfm_buffer_share_region_e |
| 113 | * |
| 114 | * \return Error code \ref spm_err_t |
| 115 | * |
| 116 | * \note This function doesn't check if service_id is valid. |
| 117 | */ |
| 118 | enum spm_err_t tfm_spm_set_share_region(enum tfm_buffer_share_region_e share); |
| 119 | |
| 120 | #endif /*__SPM_API_H__ */ |