aboutsummaryrefslogtreecommitdiff
path: root/applications/trustzone_inference/secure/mpc_sie_drv.h
diff options
context:
space:
mode:
Diffstat (limited to 'applications/trustzone_inference/secure/mpc_sie_drv.h')
-rw-r--r--applications/trustzone_inference/secure/mpc_sie_drv.h153
1 files changed, 72 insertions, 81 deletions
diff --git a/applications/trustzone_inference/secure/mpc_sie_drv.h b/applications/trustzone_inference/secure/mpc_sie_drv.h
index e2f3611..8c59872 100644
--- a/applications/trustzone_inference/secure/mpc_sie_drv.h
+++ b/applications/trustzone_inference/secure/mpc_sie_drv.h
@@ -23,8 +23,8 @@
#ifndef __MPC_SIE__DRV_H__
#define __MPC_SIE__DRV_H__
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -32,34 +32,34 @@ extern "C" {
/* Error code returned by the driver functions */
enum mpc_sie_error_t {
- MPC_SIE_ERR_NONE, /*!< No error */
- MPC_SIE_INVALID_ARG, /*!< MPC invalid input arguments */
- MPC_SIE_NOT_INIT, /*!< MPC not initialized */
- MPC_SIE_ERR_NOT_IN_RANGE, /*!< Address does not belong to a range
- * controlled by the MPC */
- MPC_SIE_ERR_NOT_ALIGNED, /*!< Address is not aligned on the block size
- * of this MPC
- */
- MPC_SIE_ERR_INVALID_RANGE, /*!< The given address range to configure
- * is invalid. This could be because:
- * - The base and limit swapped
- * - The base and limit addresses
- * are in different ranges
- */
+ MPC_SIE_ERR_NONE, /*!< No error */
+ MPC_SIE_INVALID_ARG, /*!< MPC invalid input arguments */
+ MPC_SIE_NOT_INIT, /*!< MPC not initialized */
+ MPC_SIE_ERR_NOT_IN_RANGE, /*!< Address does not belong to a range
+ * controlled by the MPC */
+ MPC_SIE_ERR_NOT_ALIGNED, /*!< Address is not aligned on the block size
+ * of this MPC
+ */
+ MPC_SIE_ERR_INVALID_RANGE, /*!< The given address range to configure
+ * is invalid. This could be because:
+ * - The base and limit swapped
+ * - The base and limit addresses
+ * are in different ranges
+ */
MPC_SIE_ERR_RANGE_SEC_ATTR_NON_COMPATIBLE, /*!< The given range cannot be
- * accessed with the wanted
- * security attributes
- */
- MPC_SIE_UNSUPPORTED_HARDWARE_VERSION, /*!< MPC hardware version read from
- * PIDR0 is not supported
- */
- MPC_SIE_ERR_GATING_NOT_PRESENT /*!< MPC gating not present in HW */
+ * accessed with the wanted
+ * security attributes
+ */
+ MPC_SIE_UNSUPPORTED_HARDWARE_VERSION, /*!< MPC hardware version read from
+ * PIDR0 is not supported
+ */
+ MPC_SIE_ERR_GATING_NOT_PRESENT /*!< MPC gating not present in HW */
};
/* Security attribute used in various place of the API */
enum mpc_sie_sec_attr_t {
- MPC_SIE_SEC_ATTR_SECURE, /*!< Secure attribute */
- MPC_SIE_SEC_ATTR_NONSECURE, /*!< Non-secure attribute */
+ MPC_SIE_SEC_ATTR_SECURE, /*!< Secure attribute */
+ MPC_SIE_SEC_ATTR_NONSECURE, /*!< Non-secure attribute */
/*!< Used when getting the configuration of a memory range and some blocks
* are secure whereas some other are non secure
*/
@@ -68,52 +68,52 @@ enum mpc_sie_sec_attr_t {
/* What can happen when trying to do an illegal memory access */
enum mpc_sie_sec_resp_t {
- MPC_SIE_RESP_RAZ_WI, /*!< Read As Zero, Write Ignored */
- MPC_SIE_RESP_BUS_ERROR, /*!< Bus error */
- MPC_SIE_RESP_WAIT_GATING_DISABLED /*!< Wait until gating is disabled */
+ MPC_SIE_RESP_RAZ_WI, /*!< Read As Zero, Write Ignored */
+ MPC_SIE_RESP_BUS_ERROR, /*!< Bus error */
+ MPC_SIE_RESP_WAIT_GATING_DISABLED /*!< Wait until gating is disabled */
};
/* Description of a memory range controlled by the MPC */
struct mpc_sie_memory_range_t {
- const uint32_t base; /*!< Base address (included in the range) */
- const uint32_t limit; /*!< Limit address (included in the range) */
- const uint32_t range_offset; /*!< Offset of current range area to the 0
- * point of the whole area (the sum of the
- * sizes of the previous memory ranges
- * covered by the same MPC)
- */
+ const uint32_t base; /*!< Base address (included in the range) */
+ const uint32_t limit; /*!< Limit address (included in the range) */
+ const uint32_t range_offset; /*!< Offset of current range area to the 0
+ * point of the whole area (the sum of the
+ * sizes of the previous memory ranges
+ * covered by the same MPC)
+ */
const enum mpc_sie_sec_attr_t attr; /*!< Optional security attribute
- * needed to be matched when
- * accessing this range.
- * For example, the non-secure
- * alias of a memory region can not
- * be accessed using secure access,
- * and configuring the MPC to
- * secure using that range will not
- * be permitted by the driver.
- */
+ * needed to be matched when
+ * accessing this range.
+ * For example, the non-secure
+ * alias of a memory region can not
+ * be accessed using secure access,
+ * and configuring the MPC to
+ * secure using that range will not
+ * be permitted by the driver.
+ */
};
/* ARM MPC SIE device configuration structure */
struct mpc_sie_dev_cfg_t {
- const uint32_t base; /*!< MPC base address */
+ const uint32_t base; /*!< MPC base address */
};
/* ARM MPC SIE device data structure */
struct mpc_sie_dev_data_t {
/*!< Array of pointers to memory ranges controlled by the MPC */
- const struct mpc_sie_memory_range_t** range_list;
- uint8_t nbr_of_ranges; /*!< Number of memory ranges in the list */
- bool is_initialized; /*!< Indicates if the MPC driver
- * is initialized and enabled
- */
- uint32_t sie_version; /*!< SIE version */
+ const struct mpc_sie_memory_range_t **range_list;
+ uint8_t nbr_of_ranges; /*!< Number of memory ranges in the list */
+ bool is_initialized; /*!< Indicates if the MPC driver
+ * is initialized and enabled
+ */
+ uint32_t sie_version; /*!< SIE version */
};
/* ARM MPC SIE device structure */
struct mpc_sie_dev_t {
- const struct mpc_sie_dev_cfg_t* const cfg; /*!< MPC configuration */
- struct mpc_sie_dev_data_t* const data; /*!< MPC data */
+ const struct mpc_sie_dev_cfg_t *const cfg; /*!< MPC configuration */
+ struct mpc_sie_dev_data_t *const data; /*!< MPC data */
};
/**
@@ -129,9 +129,8 @@ struct mpc_sie_dev_t {
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_init(struct mpc_sie_dev_t* dev,
- const struct mpc_sie_memory_range_t** range_list,
- uint8_t nbr_of_ranges);
+enum mpc_sie_error_t
+mpc_sie_init(struct mpc_sie_dev_t *dev, const struct mpc_sie_memory_range_t **range_list, uint8_t nbr_of_ranges);
/**
* \brief Gets MPC block size. All regions must be aligned on this block
@@ -144,8 +143,7 @@ enum mpc_sie_error_t mpc_sie_init(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_get_block_size(struct mpc_sie_dev_t* dev,
- uint32_t* blk_size);
+enum mpc_sie_error_t mpc_sie_get_block_size(struct mpc_sie_dev_t *dev, uint32_t *blk_size);
/**
* \brief Configures a memory region (base and limit included).
@@ -171,7 +169,7 @@ enum mpc_sie_error_t mpc_sie_get_block_size(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_config_region(struct mpc_sie_dev_t* dev,
+enum mpc_sie_error_t mpc_sie_config_region(struct mpc_sie_dev_t *dev,
const uint32_t base,
const uint32_t limit,
enum mpc_sie_sec_attr_t attr);
@@ -189,10 +187,8 @@ enum mpc_sie_error_t mpc_sie_config_region(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_get_region_config(struct mpc_sie_dev_t* dev,
- uint32_t base,
- uint32_t limit,
- enum mpc_sie_sec_attr_t* attr);
+enum mpc_sie_error_t
+mpc_sie_get_region_config(struct mpc_sie_dev_t *dev, uint32_t base, uint32_t limit, enum mpc_sie_sec_attr_t *attr);
/**
* \brief Gets the MPC control value.
@@ -204,8 +200,7 @@ enum mpc_sie_error_t mpc_sie_get_region_config(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_get_ctrl(struct mpc_sie_dev_t* dev,
- uint32_t* ctrl_val);
+enum mpc_sie_error_t mpc_sie_get_ctrl(struct mpc_sie_dev_t *dev, uint32_t *ctrl_val);
/**
* \brief Sets the MPC control value.
@@ -217,8 +212,7 @@ enum mpc_sie_error_t mpc_sie_get_ctrl(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_set_ctrl(struct mpc_sie_dev_t* dev,
- uint32_t mpc_ctrl);
+enum mpc_sie_error_t mpc_sie_set_ctrl(struct mpc_sie_dev_t *dev, uint32_t mpc_ctrl);
/**
* \brief Gets the configured secure response.
@@ -230,8 +224,7 @@ enum mpc_sie_error_t mpc_sie_set_ctrl(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_get_sec_resp(struct mpc_sie_dev_t* dev,
- enum mpc_sie_sec_resp_t* sec_rep);
+enum mpc_sie_error_t mpc_sie_get_sec_resp(struct mpc_sie_dev_t *dev, enum mpc_sie_sec_resp_t *sec_rep);
/**
* \brief Sets the response type when SW asks to gate the incoming transfers.
@@ -241,8 +234,7 @@ enum mpc_sie_error_t mpc_sie_get_sec_resp(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_set_sec_resp(struct mpc_sie_dev_t* dev,
- enum mpc_sie_sec_resp_t sec_rep);
+enum mpc_sie_error_t mpc_sie_set_sec_resp(struct mpc_sie_dev_t *dev, enum mpc_sie_sec_resp_t sec_rep);
/**
* \brief Enables MPC interrupt.
@@ -253,7 +245,7 @@ enum mpc_sie_error_t mpc_sie_set_sec_resp(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_irq_enable(struct mpc_sie_dev_t* dev);
+enum mpc_sie_error_t mpc_sie_irq_enable(struct mpc_sie_dev_t *dev);
/**
* \brief Disables MPC interrupt
@@ -262,7 +254,7 @@ enum mpc_sie_error_t mpc_sie_irq_enable(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-void mpc_sie_irq_disable(struct mpc_sie_dev_t* dev);
+void mpc_sie_irq_disable(struct mpc_sie_dev_t *dev);
/**
* \brief Clears MPC interrupt.
@@ -271,7 +263,7 @@ void mpc_sie_irq_disable(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-void mpc_sie_clear_irq(struct mpc_sie_dev_t* dev);
+void mpc_sie_clear_irq(struct mpc_sie_dev_t *dev);
/**
* \brief Returns the MPC interrupt state.
@@ -282,7 +274,7 @@ void mpc_sie_clear_irq(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-uint32_t mpc_sie_irq_state(struct mpc_sie_dev_t* dev);
+uint32_t mpc_sie_irq_state(struct mpc_sie_dev_t *dev);
/**
* \brief Locks down the MPC configuration.
@@ -293,7 +285,7 @@ uint32_t mpc_sie_irq_state(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_lock_down(struct mpc_sie_dev_t* dev);
+enum mpc_sie_error_t mpc_sie_lock_down(struct mpc_sie_dev_t *dev);
/**
* \brief Returns if gating is present in hardware.
@@ -305,8 +297,7 @@ enum mpc_sie_error_t mpc_sie_lock_down(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-enum mpc_sie_error_t mpc_sie_is_gating_present(struct mpc_sie_dev_t* dev,
- bool* gating_present);
+enum mpc_sie_error_t mpc_sie_is_gating_present(struct mpc_sie_dev_t *dev, bool *gating_present);
/**
* \brief Returns the value of Peripheral ID 0 register.
@@ -317,7 +308,7 @@ enum mpc_sie_error_t mpc_sie_is_gating_present(struct mpc_sie_dev_t* dev,
*
* \note This function doesn't check if dev is NULL.
*/
-uint32_t get_sie_version(struct mpc_sie_dev_t* dev);
+uint32_t get_sie_version(struct mpc_sie_dev_t *dev);
/**
* \brief Reads bit indicating acknowledge for gating incoming transfers.
@@ -328,7 +319,7 @@ uint32_t get_sie_version(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-bool mpc_sie_get_gate_ack(struct mpc_sie_dev_t* dev);
+bool mpc_sie_get_gate_ack(struct mpc_sie_dev_t *dev);
/**
* \brief Sets bit to request for gating incoming transfers.
@@ -337,7 +328,7 @@ bool mpc_sie_get_gate_ack(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-void mpc_sie_request_gating(struct mpc_sie_dev_t* dev);
+void mpc_sie_request_gating(struct mpc_sie_dev_t *dev);
/**
* \brief Clears bit to request for gating incoming transfers.
@@ -346,7 +337,7 @@ void mpc_sie_request_gating(struct mpc_sie_dev_t* dev);
*
* \note This function doesn't check if dev is NULL.
*/
-void mpc_sie_release_gating(struct mpc_sie_dev_t* dev);
+void mpc_sie_release_gating(struct mpc_sie_dev_t *dev);
#ifdef __cplusplus
}