From 58f1fe92ee9c68ffd08bccd19f67eafbbc968a71 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 11 Jan 2012 18:02:20 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3788 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/ports/GCC/SIMIA32/chcore.c | 17 ++++++++--------- os/ports/GCC/SIMIA32/chcore.h | 11 +++++------ 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'os/ports') diff --git a/os/ports/GCC/SIMIA32/chcore.c b/os/ports/GCC/SIMIA32/chcore.c index 58f079ef5..fff2b22c4 100644 --- a/os/ports/GCC/SIMIA32/chcore.c +++ b/os/ports/GCC/SIMIA32/chcore.c @@ -69,17 +69,16 @@ void port_halt(void) { } /** - * Threads return point, it just invokes @p chThdExit(). + * @brief Start a thread by invoking its work function. + * @details If the work function returns @p chThdExit() is automatically + * invoked. */ -void threadexit(void) { +__attribute__((cdecl, noreturn)) +void _port_thread_start(msg_t (*pf)(void *), void *p) { -#if defined(WIN32) || defined (__APPLE__) - asm volatile ("push %eax \n\t" \ - "call _chThdExit"); -#else - asm volatile ("push %eax \n\t" \ - "call chThdExit"); -#endif + chSysUnlock(); + chThdExit(pf(p)); + while(1); } /** @} */ diff --git a/os/ports/GCC/SIMIA32/chcore.h b/os/ports/GCC/SIMIA32/chcore.h index 8bfa719f8..636ae3886 100644 --- a/os/ports/GCC/SIMIA32/chcore.h +++ b/os/ports/GCC/SIMIA32/chcore.h @@ -105,13 +105,11 @@ struct context { */ #define SETUP_CONTEXT(workspace, wsize, pf, arg) { \ uint8_t *esp = (uint8_t *)workspace + wsize; \ - APUSH(esp, 0); \ - APUSH(esp, 0); \ - APUSH(esp, 0); \ APUSH(esp, arg); \ - APUSH(esp, threadexit); \ + APUSH(esp, pf); \ + APUSH(esp, 0); \ esp -= sizeof(struct intctx); \ - ((struct intctx *)esp)->eip = pf; \ + ((struct intctx *)esp)->eip = _port_thread_start; \ ((struct intctx *)esp)->ebx = 0; \ ((struct intctx *)esp)->edi = 0; \ ((struct intctx *)esp)->esi = 0; \ @@ -224,7 +222,8 @@ extern "C" { #endif __attribute__((fastcall)) void port_switch(Thread *ntp, Thread *otp); __attribute__((fastcall)) void port_halt(void); - void threadexit(void); + __attribute__((cdecl, noreturn)) void _port_thread_start(msg_t (*pf)(void *), + void *p); void ChkIntSources(void); #ifdef __cplusplus } -- cgit v1.2.3