Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ets intr lock nest #6484

Merged
merged 10 commits into from
Sep 11, 2019
Merged
18 changes: 18 additions & 0 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ static os_event_t s_loop_queue[LOOP_QUEUE_SIZE];
/* Used to implement optimistic_yield */
static uint32_t s_micros_at_task_start;

/* For ets_intr_lock_nest / ets_intr_unlock_nest
* Max nesting seen by SDK so far is 2.
*/
#define ETS_INTR_LOCK_NEST_MAX 7
byte ets_intr_lock_stack[ETS_INTR_LOCK_NEST_MAX];
byte ets_intr_lock_stack_ptr=0;


extern "C" {
extern const uint32_t __attribute__((section(".ver_number"))) core_version = ARDUINO_ESP8266_GIT_VER;
Expand Down Expand Up @@ -121,6 +128,17 @@ extern "C" void optimistic_yield(uint32_t interval_us) {
}
}

extern "C" void ets_intr_lock_nest() {
if (ets_intr_lock_stack_ptr < ETS_INTR_LOCK_NEST_MAX)
ets_intr_lock_stack[ets_intr_lock_stack_ptr++] = xt_rsil(3);
}

extern "C" void ets_intr_unlock_nest() {
if (ets_intr_lock_stack_ptr > 0)
xt_wsr_ps(ets_intr_lock_stack[--ets_intr_lock_stack_ptr]);
}


extern "C" void __loop_end (void)
{
run_scheduled_functions();
Expand Down
7 changes: 7 additions & 0 deletions tools/sdk/lib/fix_sdk_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ xtensa-lx106-elf-objcopy --redefine-sym default_hostname=wifi_station_default_ho
xtensa-lx106-elf-objcopy --redefine-sym default_hostname=wifi_station_default_hostname eagle_lwip_if.o
xtensa-lx106-elf-ar r libmain.a eagle_lwip_if.o user_interface.o
rm -f eagle_lwip_if.o user_interface.o

# Replace use of ROM ets_intr_(un)lock with nestable ets_intr_(un)lock_nest
for f in libmain.a libpp.a libnet80211.a; do
xtensa-lx106-elf-objcopy --redefine-sym ets_intr_lock=ets_intr_lock_nest $f;
xtensa-lx106-elf-objcopy --redefine-sym ets_intr_unlock=ets_intr_unlock_nest $f;
done