1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef __ESP_ATTR_H__
15 #define __ESP_ATTR_H__
16 
17 #define ROMFN_ATTR
18 
19 //Normally, the linker script will put all code and rodata in flash,
20 //and all variables in shared RAM. These macros can be used to redirect
21 //particular functions/variables to other memory regions.
22 
23 // Forces code into IRAM instead of flash.
24 #define IRAM_ATTR __attribute__((section(".iram1")))
25 
26 // Forces data into DRAM instead of flash
27 #define DRAM_ATTR __attribute__((section(".dram1")))
28 
29 // Forces data to be 4 bytes aligned
30 #define WORD_ALIGNED_ATTR __attribute__((aligned(4)))
31 
32 // Forces data to be placed to DMA-capable places
33 #define DMA_ATTR WORD_ALIGNED_ATTR DRAM_ATTR
34 
35 // Forces a string into DRAM instead of flash
36 // Use as ets_printf(DRAM_STR("Hello world!\n"));
37 #define DRAM_STR(str) (__extension__({static const DRAM_ATTR char __c[] = (str); (const char *)&__c;}))
38 
39 // Forces code into RTC fast memory. See "docs/deep-sleep-stub.rst"
40 #define RTC_IRAM_ATTR __attribute__((section(".rtc.text")))
41 
42 // Forces data into RTC slow memory. See "docs/deep-sleep-stub.rst"
43 // Any variable marked with this attribute will keep its value
44 // during a deep sleep / wake cycle.
45 #define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
46 
47 // Forces read-only data into RTC slow memory. See "docs/deep-sleep-stub.rst"
48 #define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
49 
50 // Forces data into noinit section to avoid initialization after restart.
51 #define __NOINIT_ATTR __attribute__((section(".noinit")))
52 
53 // Forces data into RTC slow memory of .noinit section.
54 // Any variable marked with this attribute will keep its value
55 // after restart or during a deep sleep / wake cycle.
56 #define RTC_NOINIT_ATTR  __attribute__((section(".rtc_noinit")))
57 
58 #endif /* __ESP_ATTR_H__ */
59