1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_MISC_H
9 #define HPM_MISC_H
10 
11 #define ILM_LOCAL_BASE (0x0U)
12 #define ILM_SIZE_IN_BYTE (0x20000U)
13 #define DLM_LOCAL_BASE (0x80000U)
14 #define DLM_SIZE_IN_BYTE (0x20000U)
15 #define CORE0_ILM_SYSTEM_BASE (0x1040000U)
16 #define CORE0_DLM_SYSTEM_BASE (0x1060000U)
17 
18 #define ADDRESS_IN_ILM(address) \
19     ((ILM_LOCAL_BASE) <= (address)) && \
20     ((ILM_LOCAL_BASE + ILM_SIZE_IN_BYTE) > (address))
21 #define ADDRESS_IN_DLM(address) \
22     ((DLM_LOCAL_BASE) <= (address)) && \
23     ((DLM_LOCAL_BASE + DLM_SIZE_IN_BYTE) > (address))
24 #define ADDRESS_IN_CORE0_DLM_SYSTEM(address) \
25     ((CORE0_DLM_SYSTEM_BASE) <= (address)) && \
26     ((CORE0_DLM_SYSTEM_BASE + DLM_SIZE_IN_BYTE) > (address))
27 
28 #define DLM_TO_SYSTEM(address) \
29     (CORE0_DLM_SYSTEM_BASE + (address) - (DLM_LOCAL_BASE))
30 #define ILM_TO_SYSTEM(address) \
31     (CORE0_ILM_SYSTEM_BASE + (address) - (ILM_LOCAL_BASE))
32 #define SYSTEM_TO_DLM(address) \
33     ((address) - CORE0_DLM_SYSTEM_BASE + (DLM_LOCAL_BASE))
34 
35 #define HPM_CORE0 (0U)
36 
37 /* map core local memory(DLM/ILM) to system address */
core_local_mem_to_sys_address(uint8_t core_id,uint32_t addr)38 static inline uint32_t core_local_mem_to_sys_address(uint8_t core_id, uint32_t addr)
39 {
40     (void) core_id;
41     return addr;
42 }
43 
44 /* map system address to core local memory(DLM/ILM) */
sys_address_to_core_local_mem(uint8_t core_id,uint32_t addr)45 static inline uint32_t sys_address_to_core_local_mem(uint8_t core_id, uint32_t addr)
46 {
47     (void) core_id;
48     return addr;
49 }
50 #endif /* HPM_MISC_H */
51