1 /* 2 * Copyright (c) 2019-2022 Arm Limited 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __PPC_RSE_DRIVER_H__ 18 #define __PPC_RSE_DRIVER_H__ 19 20 #include "Driver_Common.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /* API version */ 27 #define ARM_PPC_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1,0) 28 29 /* Security attribute used to configure the peripheral */ 30 typedef enum _PPC_RSE_SecAttr { 31 PPC_RSE_SECURE_CONFIG = 0, /*!< Secure access */ 32 PPC_RSE_NONSECURE_CONFIG, /*!< Non-secure access */ 33 } PPC_RSE_SecAttr; 34 35 /* Privilege attribute used to configure the peripheral */ 36 typedef enum _PPC_RSE_PrivAttr { 37 PPC_RSE_PRIV_AND_NONPRIV_CONFIG = 0, /*!< Privilege and non-privilege 38 * access */ 39 PPC_RSE_PRIV_CONFIG, /*!< Privilege only access */ 40 } PPC_RSE_PrivAttr; 41 42 /* Function descriptions */ 43 /** 44 SACFG - Secure Privilege Control Block 45 NSACFG - Non-Secure Privilege Control Block 46 47 \fn ARM_DRIVER_VERSION PPC_RSE_GetVersion(void) 48 \brief Get driver version. 49 \return \ref ARM_DRIVER_VERSION 50 51 \fn int32_t PPC_RSE_Initialize(void) 52 \brief Initializes PPC Interface. 53 \return Returns RSE PPC error code. 54 55 \fn int32_t PPC_RSE_Uninitialize(void) 56 \brief De-initializes PPC Interface. 57 \return Returns RSE PPC error code. 58 59 \fn int32_t PPC_RSE_ConfigPrivilege(uint32_t periph, 60 PPC_RSE_SecAttr sec_attr, 61 PPC_RSE_PrivAttr priv_attr) 62 \brief Configures privilege level with privileged and unprivileged 63 access or privileged access only in the given security domain 64 for a peripheral controlled by the given PPC. 65 \param[in] periph: Peripheral mask for SACFG and NSACFG registers. 66 \param[in] sec_attr: Specifies Secure or Non Secure domain. 67 \param[in] priv_attr: Privilege attribute value to set. 68 \return Returns RSE PPC error code. 69 70 \fn bool PPC_RSE_IsPeriphPrivOnly (uint32_t periph) 71 \brief Checks if the peripheral is configured to be privilege only 72 - with non-secure caller in the non-secure domain 73 - with secure caller in the configured security domain 74 \param[in] periph: Peripheral mask for SACFG and NSACFG registers. 75 \return Returns true if the peripheral is configured as privilege access 76 only, false for privilege and unprivilege access mode. 77 78 Secure only functions: 79 80 \fn int32_t PPC_RSE_ConfigSecurity(uint32_t periph, 81 PPC_RSE_SecAttr sec_attr) 82 \brief Configures security level for a peripheral controlled by the 83 given PPC with secure or non-secure access only. 84 \param[in] periph: Peripheral mask for SACFG and NSACFG registers. 85 \param[in] sec_attr: Secure attribute value to set. 86 \return Returns RSE PPC error code. 87 88 \fn bool PPC_RSE_IsPeriphSecure (uint32_t periph) 89 \brief Checks if the peripheral is configured to be secure. 90 \param[in] periph: Peripheral mask for SACFG and NSACFG registers. 91 \return Returns true if the peripheral is configured as secure, 92 false for non-secure. 93 94 \fn int32_t PPC_RSE_EnableInterrupt (void) 95 \brief Enables PPC interrupt. 96 \return Returns RSE PPC error code. 97 98 \fn void PPC_RSE_DisableInterrupt (void) 99 \brief Disables PPC interrupt. 100 101 \fn void PPC_RSE_ClearInterrupt (void) 102 \brief Clears PPC interrupt. 103 104 \fn bool PPC_RSE_InterruptState (void) 105 \brief Gets PPC interrupt state. 106 \return Returns true if the interrupt is active, false otherwise. 107 */ 108 109 /** 110 * \brief Access structure of the PPC Driver. 111 */ 112 typedef struct _DRIVER_PPC_RSE { 113 ARM_DRIVER_VERSION (*GetVersion) (void); ///< Pointer to \ref ARM_PPC_GetVersion : Get driver version. 114 int32_t (*Initialize) (void); ///< Pointer to \ref ARM_PPC_Initialize : Initialize the PPC Interface. 115 int32_t (*Uninitialize) (void); ///< Pointer to \ref ARM_PPC_Uninitialize : De-initialize the PPC Interface. 116 int32_t (*ConfigPrivilege) (uint32_t periph, PPC_RSE_SecAttr sec_attr, PPC_RSE_PrivAttr priv_attr); ///< Pointer to \ref ARM_PPC_ConfigPeriph : Configure a peripheral controlled by the PPC. 117 bool (*IsPeriphPrivOnly) (uint32_t periph); ///< Pointer to \ref IsPeriphPrivOnly : Check if the peripheral is configured to be privilege only. 118 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)) 119 int32_t (*ConfigSecurity) (uint32_t periph, PPC_RSE_SecAttr sec_attr); ///< Pointer to \ref ARM_PPC_ConfigPeriph : Configure a peripheral controlled by the PPC. 120 bool (*IsPeriphSecure) (uint32_t periph); ///< Pointer to \ref IsPeriphSecure : Check if the peripheral is configured to be secure. 121 int32_t (*EnableInterrupt) (void); ///< Pointer to \ref ARM_PPC_EnableInterrupt : Enable PPC interrupt. 122 void (*DisableInterrupt) (void); ///< Pointer to \ref ARM_PPC_DisableInterrupt : Disable PPC interrupt. 123 void (*ClearInterrupt) (void); ///< Pointer to \ref ARM_PPC_ClearInterrupt : Clear PPC interrupt. 124 bool (*InterruptState) (void); ///< Pointer to \ref ARM_PPC_InterruptState : PPC interrupt State. 125 #endif /* (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)) */ 126 } const DRIVER_PPC_RSE; 127 128 #ifdef __cplusplus 129 } 130 #endif 131 #endif /* __PPC_RSE_DRIVER_H__ */ 132