From 9ff8210349259461c4401b80c9b2b6f51acbf59a Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 18 May 2020 16:30:00 +0000 Subject: [PATCH] Fixed regression in simulator port. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13655 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/common/ports/SIMIA32/chcore.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/os/common/ports/SIMIA32/chcore.c b/os/common/ports/SIMIA32/chcore.c index ef1a475e8..800c53f96 100644 --- a/os/common/ports/SIMIA32/chcore.c +++ b/os/common/ports/SIMIA32/chcore.c @@ -37,6 +37,23 @@ /* Module local definitions. */ /*===========================================================================*/ +/* + * RTOS-specific context offset. + */ +#if defined(_CHIBIOS_RT_CONF_) +#if CH_CFG_USE_REGISTRY +#define CONTEXT_OFFSET "20" +#else +#define CONTEXT_OFFSET "12" +#endif + +#elif defined(_CHIBIOS_NIL_CONF_) +#define CONTEXT_OFFSET "0" + +#else +#error "invalid chconf.h" +#endif + /*===========================================================================*/ /* Module exported variables. */ /*===========================================================================*/ @@ -84,8 +101,8 @@ static void __dummy(thread_t *ntp, thread_t *otp) { "push %esi \n\t" "push %edi \n\t" "push %ebx \n\t" - "movl %esp, 12(%edx) \n\t" - "movl 12(%ecx), %esp \n\t" + "movl %esp, "CONTEXT_OFFSET"(%edx) \n\t" + "movl "CONTEXT_OFFSET"(%ecx), %esp \n\t" "pop %ebx \n\t" "pop %edi \n\t" "pop %esi \n\t"