From 66be67ced260766f7480cecd1b7f2d450f818fef Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 19 Jun 2015 17:25:25 +0300 Subject: [PATCH] Fix alignment of continuations stack --- cores/esp8266/cont.S | 2 +- cores/esp8266/cont.h | 2 ++ cores/esp8266/cont_util.c | 2 +- cores/esp8266/core_esp8266_main.cpp | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cores/esp8266/cont.S b/cores/esp8266/cont.S index 0ec47a0a7..4c8514246 100644 --- a/cores/esp8266/cont.S +++ b/cores/esp8266/cont.S @@ -106,7 +106,7 @@ cont_resume: cont_norm: /* calculate pointer to cont_ctx.struct_start from sp */ - l32i a2, a1, 8 + l32i a2, a1, 4 /* sp <- cont_ctx.sp_ret */ l32i a1, a2, 4 diff --git a/cores/esp8266/cont.h b/cores/esp8266/cont.h index 529237742..5da60f497 100644 --- a/cores/esp8266/cont.h +++ b/cores/esp8266/cont.h @@ -33,6 +33,8 @@ typedef struct cont_ { unsigned* sp_yield; unsigned* stack_end; + unsigned unused1; + unsigned unused2; unsigned stack_guard1; unsigned stack[CONT_STACKSIZE / 4]; diff --git a/cores/esp8266/cont_util.c b/cores/esp8266/cont_util.c index fcb6f024c..590cd36ad 100644 --- a/cores/esp8266/cont_util.c +++ b/cores/esp8266/cont_util.c @@ -25,7 +25,7 @@ void cont_init(cont_t* cont) { cont->stack_guard1 = CONT_STACKGUARD; cont->stack_guard2 = CONT_STACKGUARD; - cont->stack_end = cont->stack + (sizeof(cont->stack) / 4 - 1); + cont->stack_end = cont->stack + (sizeof(cont->stack) / 4); cont->struct_start = (unsigned*) cont; } diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index b67543f8b..9f91f299f 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -59,7 +59,7 @@ void preloop_update_frequency() { extern void (*__init_array_start)(void); extern void (*__init_array_end)(void); -static cont_t g_cont; +cont_t g_cont __attribute__ ((aligned (16))); static os_event_t g_loop_queue[LOOP_QUEUE_SIZE]; static uint32_t g_micros_at_task_start;