From 9514d847feb70c330d310a366b92013960729bdc Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Wed, 19 Oct 2016 00:20:10 +0300
Subject: [PATCH] esp8266: Add MP_FASTCODE modifier to put a function to iRAM.

It can be used in the following manner:

void MP_FASTCODE(foo)(int arg) { ... }
---
 esp8266/esp8266.ld     | 3 ++-
 esp8266/mpconfigport.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/esp8266/esp8266.ld b/esp8266/esp8266.ld
index 010a4cac6..5fb6f1379 100644
--- a/esp8266/esp8266.ld
+++ b/esp8266/esp8266.ld
@@ -202,7 +202,8 @@ SECTIONS
         *(.entry.text)
         *(.init.literal)
         *(.init)
-        *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
+        *(.literal .text .literal.* .text.* .iram0.literal .iram0.text .iram0.text.*.literal .iram0.text.*)
+        *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
         *(.fini.literal)
         *(.fini)
         *(.gnu.version)
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 201057f12..602b3e9c8 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -182,4 +182,6 @@ extern const struct _mp_obj_module_t onewire_module;
 #define MICROPY_HW_MCU_NAME "ESP8266"
 #define MICROPY_PY_SYS_PLATFORM "esp8266"
 
+#define MP_FASTCODE(n) __attribute__((section(".iram0.text." #n))) n
+
 #define _assert(expr) ((expr) ? (void)0 : __assert_func(__FILE__, __LINE__, __func__, #expr))
-- 
GitLab