David Vincze | f0dc21c | 2019-11-28 16:01:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #ifndef __CC_HAL_H__ |
| 9 | #define __CC_HAL_H__ |
| 10 | |
| 11 | /*! |
| 12 | @file |
| 13 | @brief This file contains HAL definitions and APIs. |
| 14 | */ |
| 15 | |
| 16 | #include <stdint.h> |
| 17 | #include "cc_hal_plat.h" |
| 18 | #include "cc_pal_types_plat.h" |
| 19 | |
| 20 | /*! HAL return code definitions. */ |
| 21 | typedef enum { |
| 22 | CC_HAL_OK = 0, |
| 23 | CC_HAL_ENODEV, /* Device not opened or does not exist */ |
| 24 | CC_HAL_EINTERNAL, /* Internal driver error (check system log) */ |
| 25 | CC_HAL_MAPFAILED, |
| 26 | CC_HAL_ENOTSUP, /* Unsupported function/option */ |
| 27 | CC_HAL_ENOPERM, /* Not enough permissions for request */ |
| 28 | CC_HAL_EINVAL, /* Invalid parameters */ |
| 29 | CC_HAL_ENORSC, /* No resources available (e.g., memory) */ |
| 30 | CC_HAL_RESERVE32B = 0x7FFFFFFFL |
| 31 | } CCHalRetCode_t; |
| 32 | |
| 33 | /*! |
| 34 | * @brief This function is used to map ARM TrustZone CryptoCell TEE registers to Host virtual address space. |
| 35 | It is called by ::CC_LibInit, and returns a non-zero value in case of failure. |
| 36 | The existing implementation supports Linux environment. In case virtual addressing is not used, the function can be minimized to contain only the |
| 37 | following line, and return OK: |
| 38 | gCcRegBase = (uint32_t)DX_BASE_CC; |
| 39 | @return CC_HAL_OK on success. |
| 40 | @return A non-zero value in case of failure. |
| 41 | */ |
| 42 | int CC_HalInit(void); |
| 43 | |
| 44 | |
| 45 | /*! |
| 46 | * @brief This function is used to wait for the IRR interrupt signal. |
| 47 | * |
| 48 | * @return CCError_t - return CC_OK upon success |
| 49 | */ |
| 50 | CCError_t CC_HalWaitInterrupt(uint32_t data /*!< [in] The interrupt bits to wait upon. */ ); |
| 51 | |
| 52 | /*! |
| 53 | * @brief This function is used to wait for the IRR interrupt signal. |
| 54 | * The existing implementation performs a "busy wait" on the IRR. |
| 55 | * |
| 56 | * @return CCError_t - return CC_OK upon success |
| 57 | */ |
| 58 | CCError_t CC_HalWaitInterruptRND(uint32_t data); |
| 59 | |
| 60 | /*! |
| 61 | * @brief This function clears the DSCRPTR_COMPLETION bit in the ICR signal. |
| 62 | */ |
| 63 | void CC_HalClearInterrupt(uint32_t data); |
| 64 | |
| 65 | /*! |
| 66 | * @brief This function is called by CC_LibInit and is used for initializing the ARM TrustZone CryptoCell TEE cache settings registers. |
| 67 | The existing implementation sets the registers to their default values in HCCC cache coherency mode |
| 68 | (ARCACHE = 0x2, AWCACHE = 0x7, AWCACHE_LAST = 0x7). |
| 69 | These values should be changed by the customer in case the customer's platform requires different HCCC values, or in case SCCC is needed |
| 70 | (the values for SCCC are ARCACHE = 0x3, AWCACHE = 0x3, AWCACHE_LAST = 0x3). |
| 71 | |
| 72 | * @return void |
| 73 | */ |
| 74 | void CC_HalInitHWCacheParams(void); |
| 75 | |
| 76 | /*! |
| 77 | * @brief This function is used to unmap ARM TrustZone CryptoCell TEE registers' virtual address. |
| 78 | It is called by CC_LibFini, and returns a non-zero value in case of failure. |
| 79 | In case virtual addressing is not used, the function can be minimized to be an empty function returning OK. |
| 80 | @return CC_HAL_OK on success. |
| 81 | @return A non-zero value in case of failure. |
| 82 | */ |
| 83 | int CC_HalTerminate(void); |
| 84 | |
| 85 | /*! |
| 86 | * @brief This function is used to clear the interrupt vector. |
| 87 | |
| 88 | * @return void. |
| 89 | */ |
| 90 | void CC_HalClearInterruptBit(uint32_t data /*!< [in] The interrupt bits to clear. */); |
| 91 | |
| 92 | /*! |
| 93 | * @brief This function is used to mask IRR interrupts. |
| 94 | |
| 95 | * @return void. |
| 96 | */ |
| 97 | void CC_HalMaskInterrupt(uint32_t data /*!< [in] The interrupt bits to mask. */); |
| 98 | |
| 99 | |
| 100 | #endif |
| 101 | |