1 /******************************************************************************* 2 * The confidential and proprietary information contained in this file may * 3 * only be used by a person authorised under and to the extent permitted * 4 * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 * ALL RIGHTS RESERVED * 7 * This entire notice must be reproduced on all copies of this file * 8 * and copies of this file may only be made by a person if such person is * 9 * permitted to do so under the terms of a subsisting license agreement * 10 * from ARM Limited or its affiliates. * 11 *******************************************************************************/ 12 13 #ifndef TEST_PAL_MEM_S_H_ 14 #define TEST_PAL_MEM_S_H_ 15 16 #include <stdint.h> 17 #include <stdio.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /******************************************************************************/ 24 /* Secure API - ONLY WHEN TRUSTZONE-M IS SUPPORTED */ 25 /* Otherwise, please use only test_pal_mem API. */ 26 /******************************************************************************/ 27 28 /******************************************************************************/ 29 /* 30 * @brief This function allocates SECURE "size" bytes. 31 * 32 * @param[in] size in bytes. 33 * 34 * @param[out] 35 * 36 * @return pointer to the allocated memory. 37 */ 38 void *Test_PalMalloc_s(size_t size); 39 40 /******************************************************************************/ 41 /* 42 * @brief This function frees SECURE allocated memory pointed by pvAddress. 43 * 44 * @param[in] pvAddress - pointer to the allocated memory. 45 * 46 * @param[out] 47 * 48 * @return 49 */ 50 void Test_PalFree_s(void *pvAddress); 51 52 /******************************************************************************/ 53 /* 54 * @brief This function changes the size of a SECURE memory block pointed by 55 * pvAddress. 56 * If the function fails to allocate the requested block of memory: 57 * 1. a null pointer is returned. 58 * 2. The memory block pointed by argument pvAddress is NOT deallocated. 59 * 60 * @param[in] 61 * pvAddress - Pointer to the allocated memory. 62 * newSize - New size. 63 * 64 * @param[out] 65 * 66 * @return - a pointer to the new allocated memory or NULL in case of failure. 67 */ 68 void *Test_PalRealloc_s(void *pvAddress, size_t newSize); 69 70 /******************************************************************************/ 71 /* 72 * @brief This function allocates a DMA-contiguous buffer in a SECURE memory 73 * region and returns its address. 74 * 75 * @param[in] size - Buffer size in bytes. 76 * 77 * @param[out] 78 * 79 * @return an address of the secure allocated buffer. 80 */ 81 void *Test_PalDMAContigBufferAlloc_s(size_t size); 82 83 /******************************************************************************/ 84 /* 85 * @brief This function frees resources in a SECURE region previously allocated 86 * by Test_PalDMAContigBufferAlloc_s. 87 * 88 * @param[in] pvAddress - address of the secure allocated buffer. 89 * 90 * @param[out] 91 * 92 * @return 93 */ 94 void Test_PalDMAContigBufferFree_s(void *pvAddress); 95 96 /******************************************************************************/ 97 /* 98 * @brief This function changes the size of the SECURE memory block pointed by 99 * pvAddress. 100 * If the function fails to allocate the requested block of memory: 101 * 1. a null pointer is returned. 102 * 2. The memory block pointed by argument pvAddress is NOT deallocated. 103 * 104 * @param[in] 105 * pvAddress - Pointer to the secure allocated memory. 106 * newSize - New size in bytes. 107 * 108 * @param[out] 109 * 110 * @return - a pointer to the new secure allocated memory. 111 */ 112 void *Test_PalDMAContigBufferRealloc_s(void *pvAddress, size_t newSize); 113 114 /******************************************************************************/ 115 /* 116 * @brief This function returns the SECURE DMA base address, i.e. the start 117 * address of the SECURE DMA region. 118 * 119 * @param[in] 120 * 121 * @param[out] 122 * 123 * @return - Secure DMABaseAddr. 124 */ 125 unsigned long Test_PalGetDMABaseAddr_s(void); 126 127 /******************************************************************************/ 128 /* 129 * @brief This function returns the SECURE unmanaged base address. 130 * 131 * @param[in] 132 * 133 * @param[out] 134 * 135 * @return - DMABaseAddr. 136 */ 137 unsigned long Test_PalGetUnmanagedBaseAddr_s(void); 138 139 /******************************************************************************/ 140 /* 141 * @brief This function initializes the SECURE DMA memory management. 142 * 143 * @param[in] 144 * newDMABaseAddr_s - new secure DMA start address. 145 * newUnmanagedBaseAddr_s - new secure unmanaged start address. 146 * SDMAsize - secure DMA region size. 147 * 148 * @param[out] 149 * 150 * @return rc - 0 for success, 1 for failure. 151 */ 152 uint32_t Test_PalMemInit_s(unsigned long newDMABaseAddr_s, 153 unsigned long newUnmanagedBaseAddr_s, 154 size_t SDMAsize); 155 156 /******************************************************************************/ 157 /* 158 * @brief This function sets the SECURE memory management driver to its initial 159 * state. 160 * 161 * @param[in] 162 * 163 * @param[out] 164 * 165 * @return rc - 0 for success, 1 for failure. 166 */ 167 uint32_t Test_PalMemFin_s(void); 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* TEST_PAL_MEM_S_H_ */ 174