1 /*
2  * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3  */
4 #ifndef __HAL_LOCATION_H__
5 #define __HAL_LOCATION_H__
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #define HAL_SEC_DEF_A(s, d, n)          __attribute__((section(#s #d #n))) n
12 #define HAL_SEC_DEF(section, name)      HAL_SEC_DEF_A(section, ., name)
13 #define HAL_SEC_LOC(section)            HAL_SEC_DEF_A(section, , )
14 
15 #if defined(__GNUC__) && !(defined(ROM_BUILD) || defined(PROGRAMMER))
16 
17 #define BOOT_TEXT_SRAM_LOC              HAL_SEC_LOC(.boot_text_sram)
18 #define BOOT_TEXT_SRAM_DEF(n)           HAL_SEC_DEF(.boot_text_sram, n)
19 #define BOOT_TEXT_FLASH_LOC             HAL_SEC_LOC(.boot_text_flash)
20 #define BOOT_TEXT_FLASH_DEF(n)          HAL_SEC_DEF(.boot_text_flash, n)
21 #define BOOT_RODATA_LOC                 HAL_SEC_LOC(.boot_rodata)
22 #define BOOT_RODATA_DEF(n)              HAL_SEC_DEF(.boot_rodata, n)
23 #define BOOT_DATA_LOC                   HAL_SEC_LOC(.boot_data)
24 #define BOOT_DATA_DEF(n)                HAL_SEC_DEF(.boot_data, n)
25 #ifdef __ARMCC_VERSION
26 #define BOOT_BSS_LOC                    HAL_SEC_LOC(.bss.boot_bss)
27 #define BOOT_BSS_DEF(n)                 HAL_SEC_DEF(.bss.boot_bss, n)
28 #else
29 #define BOOT_BSS_LOC                    HAL_SEC_LOC(.boot_bss)
30 #define BOOT_BSS_DEF(n)                 HAL_SEC_DEF(.boot_bss, n)
31 #endif
32 
33 #define SRAM_TEXT_LOC                   HAL_SEC_LOC(.sram_text)
34 #define SRAM_TEXT_DEF(n)                HAL_SEC_DEF(.sram_text, n)
35 #define SRAM_DATA_LOC                   HAL_SEC_LOC(.sram_data)
36 #define SRAM_DATA_DEF(n)                HAL_SEC_DEF(.sram_data, n)
37 #define SRAM_STACK_LOC                  ALIGNED(8) HAL_SEC_LOC(.sram_data)
38 #define SRAM_STACK_DEF(n)               ALIGNED(8) HAL_SEC_LOC(.sram_data, n)
39 #ifdef __ARMCC_VERSION
40 #define SRAM_BSS_LOC                    HAL_SEC_LOC(.bss.sram_bss)
41 #define SRAM_BSS_DEF(n)                 HAL_SEC_DEF(.bss.sram_bss, n)
42 #else
43 #define SRAM_BSS_LOC                    HAL_SEC_LOC(.sram_bss)
44 #define SRAM_BSS_DEF(n)                 HAL_SEC_DEF(.sram_bss, n)
45 #endif
46 
47 #define FRAM_TEXT_LOC                   HAL_SEC_LOC(.fast_text_sram)
48 #define FRAM_TEXT_DEF(n)                HAL_SEC_DEF(.fast_text_sram, n)
49 
50 #define CP_TEXT_SRAM_LOC                HAL_SEC_LOC(.cp_text_sram)
51 #define CP_TEXT_SRAM_DEF(n)             HAL_SEC_DEF(.cp_text_sram, n)
52 #define CP_DATA_LOC                     HAL_SEC_LOC(.cp_data)
53 #define CP_DATA_DEF(n)                  HAL_SEC_DEF(.cp_data, n)
54 #ifdef __ARMCC_VERSION
55 #define CP_BSS_LOC                      HAL_SEC_LOC(.bss.cp_bss)
56 #define CP_BSS_DEF(n)                   HAL_SEC_DEF(.bss.cp_bss, n)
57 #else
58 #define CP_BSS_LOC                      HAL_SEC_LOC(.cp_bss)
59 #define CP_BSS_DEF(n)                   HAL_SEC_DEF(.cp_bss, n)
60 #endif
61 
62 #define FLASH_TEXT_LOC                  HAL_SEC_LOC(.flash_text)
63 #define FLASH_TEXT_DEF(n)               HAL_SEC_DEF(.flash_text, n)
64 #define FLASH_RODATA_LOC                HAL_SEC_LOC(.flash_rodata)
65 #define FLASH_RODATA_DEF(n)             HAL_SEC_DEF(.flash_rodata, n)
66 
67 #define REBOOT_CUSTOM_PARAM_LOC         HAL_SEC_LOC(.reboot_custom_param)
68 #define REBOOT_CUSTOM_PARAM_DEF         HAL_SEC_DEF(.reboot_custom_param)
69 
70 #else
71 
72 #define BOOT_TEXT_SRAM_LOC
73 #define BOOT_TEXT_SRAM_DEF(n)           n
74 #if defined(__GNUC__) && defined(PROGRAMMER_INFLASH)
75 #define BOOT_TEXT_FLASH_LOC             HAL_SEC_LOC(.boot_text_flash)
76 #define BOOT_TEXT_FLASH_DEF(n)          HAL_SEC_DEF(.boot_text_flash, n)
77 #else
78 #define BOOT_TEXT_FLASH_LOC
79 #define BOOT_TEXT_FLASH_DEF(n)          n
80 #endif
81 #define BOOT_RODATA_LOC
82 #define BOOT_RODATA_DEF(n)              n
83 #define BOOT_DATA_LOC
84 #define BOOT_DATA_DEF(n)                n
85 #define BOOT_BSS_LOC
86 #define BOOT_BSS_DEF(n)                 n
87 
88 #define SRAM_TEXT_LOC
89 #define SRAM_TEXT_DEF(n)                n
90 #define SRAM_DATA_LOC
91 #define SRAM_DATA_DEF(n)                n
92 #define SRAM_STACK_LOC
93 #define SRAM_STACK_DEF(n)               n
94 #define SRAM_BSS_LOC
95 #define SRAM_BSS_DEF(n)                 n
96 
97 #define FRAM_TEXT_LOC
98 #define FRAM_TEXT_DEF(n)                n
99 
100 #define CP_TEXT_SRAM_LOC
101 #define CP_TEXT_SRAM_DEF(n)             n
102 #define CP_DATA_LOC
103 #define CP_DATA_DEF(n)                  n
104 #define CP_BSS_LOC
105 #define CP_BSS_DEF(n)                   n
106 
107 #define FLASH_TEXT_LOC
108 #define FLASH_TEXT_DEF(n)               n
109 #define FLASH_RODATA_LOC
110 #define FLASH_RODATA_DEF(n)             n
111 
112 #define REBOOT_CUSTOM_PARAM_LOC
113 #define REBOOT_CUSTOM_PARAM_DEF(n)      n
114 
115 #endif // !__GNUC__ || ROM_BUILD || PROGRAMMER
116 
117 #if defined(__GNUC__) && defined(__ARM_ARCH_ISA_ARM)
118 #define SYNC_FLAGS_LOC                  HAL_SEC_LOC(.sync_flags)
119 #define SYNC_FLAGS_DEF(n)               HAL_SEC_DEF(.sync_flags, n)
120 #else
121 #define SYNC_FLAGS_LOC			HAL_SEC_LOC(.sram_bss)
122 #define SYNC_FLAGS_DEF(n)		HAL_SEC_DEF(.sram_bss, n)
123 #endif
124 
125 #if defined(__ARM_ARCH_ISA_ARM)
126 #define PSRAMUHS_TEXT_LOC               HAL_SEC_LOC(.psramuhs_text)
127 #define PSRAMUHS_TEXT_DEF(n)            HAL_SEC_DEF(.psramuhs_text, n)
128 #else
129 #define PSRAMUHS_TEXT_LOC
130 #define PSRAMUHS_TEXT_DEF(n)            n
131 #endif
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif
138