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_MAP_ADDRS_H_
14 #define TEST_PAL_MAP_ADDRS_H_
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define VALID_MAPPED_ADDR(addr) ((addr != 0) && (addr != 0xFFFFFFFF))
21 
22 /* Bit Masks - Used by Linux */
23 #define BM_READ     0x01 /* Pages may be read */
24 #define BM_WRITE    0x02 /* Pages may be written */
25 #define BM_EXEC     0x04 /* Pages may be executed */
26 #define BM_NONE     0x08 /* Pages may not be accessed */
27 #define BM_SHARED   0x10 /* Share this mapping */
28 #define BM_PRIVATE  0x20 /* Create a private copy-on-write mapping */
29 #define BM_FIXED    0x40 /* Don't interpret addr as a hint:
30                 place the mapping at exactly that address. */
31 
32 /******************************************************************************/
33 /*
34  * @brief This function maps IO physical address to OS accessible address.
35  * @param[in]
36  * physAddr - a physical address.
37  * size - size in bytes.
38  *
39  * @param[out]
40  *
41  * @return a valid virtual address or null in case of failure.
42  */
43 void *Test_PalIOMap(void *physAddr, size_t size);
44 
45 /******************************************************************************/
46 /*
47  * @brief This function maps a physical address to a virtual address.
48  * @param[in]
49  * physAddr - a physical address.
50  * startingAddr - preferred static address for mapping.
51  * filename - File name.
52  * size - size in bytes.
53  * protAndFlagsBitMask - prot and flags bit mask.
54  *
55  * @param[out]
56  *
57  * @return a valid virtual address or null in case of failure.
58  */
59 void *Test_PalMapAddr(void *physAddr, void *startingAddr, const char *filename,
60                 size_t size, uint8_t protAndFlagsBitMask);
61 
62 /******************************************************************************/
63 /*
64  * @brief This function unmaps a virtual address.
65  * @param[in] virtual address and size in bytes.
66  *
67  * @param[out]
68  *
69  * @return
70  */
71 void Test_PalUnmapAddr(void *virtAddr, size_t size);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif /* TEST_PAL_MAP_ADDRS_H_ */
78