1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _TEST_PROJ_H_
8 #define _TEST_PROJ_H_
9 
10 #include <stdint.h>
11 #include "test_proj_common.h"
12 
13 #define TEST_PROJ_CC_REG_MAP_AREA_LEN     0x20000
14 
15 struct ProcessMappingArea_t {
16     unsigned long       processTeeHwRegBaseAddr;
17     unsigned long       processTeeHwEnvBaseAddr;
18     unsigned long       processTeeUnmanagedBaseAddr;
19 };
20 
21 extern struct ProcessMappingArea_t processMap;
22 
23 #define TEST_READ_TEE_CC_REG(offset) \
24         *(volatile uint32_t *)(processMap.processTeeHwRegBaseAddr + (offset))
25 
26 #define TEST_WRITE_TEE_CC_REG(offset, val)  { \
27     volatile uint32_t ii1; \
28         (*(volatile uint32_t *)(processMap.processTeeHwRegBaseAddr + (offset))) = (uint32_t)(val); \
29         for(ii1=0; ii1<500; ii1++); \
30 }
31 
32 #define TEST_READ_TEE_ENV_REG(offset) \
33         *(volatile uint32_t *)(processMap.processTeeHwEnvBaseAddr + (offset))
34 
35 #define TEST_WRITE_TEE_ENV_REG(offset, val)  { \
36         volatile uint32_t ii1; \
37         (*(volatile uint32_t *)(processMap.processTeeHwEnvBaseAddr + (offset))) = (uint32_t)(val); \
38         for(ii1=0; ii1<500; ii1++); \
39 }
40 
41 
42 /****************************************************************************/
43 /*                              External API                                */
44 /****************************************************************************/
45 /*
46  * @brief This function initializes platform, i.e maps its relevant memory regions.
47  *
48  * @param[in/out] *pProcessMap - mapping regions
49  *
50  * @return rc - 0 for success, 1 for failure.
51  */
52 uint32_t Test_ProjInit(void);
53 
54 /****************************************************************************/
55 /*
56  * @brief This function frees previously allocated resources
57  *
58  * @param[in/out] *pProcessMap - mapping regions
59   *
60  * @return rc - 0 for success, 1 for failure
61  */
62 void Test_ProjFree(void);
63 
64 #endif //_TEST_PROJ_H_
65 
66