aboutsummaryrefslogtreecommitdiffstats
path: root/os/ports/GCC/SIMIA32
diff options
context:
space:
mode:
Diffstat (limited to 'os/ports/GCC/SIMIA32')
-rw-r--r--os/ports/GCC/SIMIA32/chcore.c17
-rw-r--r--os/ports/GCC/SIMIA32/chcore.h11
2 files changed, 13 insertions, 15 deletions
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
}