1 /*
2  * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __MMIO_DEFS_H__
9 #define __MMIO_DEFS_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 #include "tfm_peripherals_def.h"
17 
18 /* Boundary handle binding macros. */
19 #define HANDLE_ATTR_PRIV_POS            1U
20 #define HANDLE_ATTR_PRIV_MASK           (0x1UL << HANDLE_ATTR_PRIV_POS)
21 #define HANDLE_ATTR_NS_POS              0U
22 #define HANDLE_ATTR_NS_MASK             (0x1UL << HANDLE_ATTR_NS_POS)
23 #if TFM_ISOLATION_LEVEL == 3
24 #define HANDLE_ATTR_SPM_POS             2U
25 #define HANDLE_ATTR_SPM_MASK            (0x1UL << HANDLE_ATTR_SPM_POS)
26 #define HANDLE_PER_ATTR_BITS            (0x4)
27 #define HANDLE_ATTR_RW_POS              (1 << (HANDLE_PER_ATTR_BITS - 1))
28 #define HANDLE_ATTR_INDEX_MASK          (HANDLE_ATTR_RW_POS - 1)
29 #define HANDLE_INDEX_BITS               (0x8)
30 #define HANDLE_INDEX_MASK               (((1 << HANDLE_INDEX_BITS) -1) << 24)
31 #define HANDLE_ENCODE_INDEX(attr, idx)                              \
32     do {                                                            \
33         (attr) |= (((idx) << 24) & HANDLE_INDEX_MASK);              \
34         (idx)++;                                                    \
35     } while (0)
36 #endif
37 
38 /* Allowed named MMIO of this platform */
39 const uintptr_t partition_named_mmio_list[] = {
40     (uintptr_t)TFM_PERIPHERAL_TIMER0,
41     (uintptr_t)TFM_PERIPHERAL_STD_UART,
42 #ifdef PSA_API_TEST_IPC
43     (uintptr_t)FF_TEST_UART_REGION,
44     (uintptr_t)FF_TEST_WATCHDOG_REGION,
45     (uintptr_t)FF_TEST_NVMEM_REGION,
46     (uintptr_t)FF_TEST_SERVER_PARTITION_MMIO,
47     (uintptr_t)FF_TEST_DRIVER_PARTITION_MMIO,
48 #endif
49 };
50 
51 /*
52  * Platform AN521 only has named MMIO.
53  * If the platform has numbered MMIO, define them in another list.
54  */
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif /* __MMIO_DEFS_H__ */
61