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