diff --git a/os/nil/ports/AVR/nilcore.h b/os/nil/ports/AVR/nilcore.h index 9c915f303..c8636ebb0 100644 --- a/os/nil/ports/AVR/nilcore.h +++ b/os/nil/ports/AVR/nilcore.h @@ -161,6 +161,9 @@ struct port_intctx { uint8_t r4; uint8_t r3; uint8_t r2; +#ifdef __AVR_3_BYTE_PC__ + uint8_t pcx; +#endif uint8_t pcl; uint8_t pch; }; @@ -176,6 +179,19 @@ struct port_intctx { * @details This code usually setup the context switching frame represented * by an @p port_intctx structure. */ +#ifdef __AVR_3_BYTE_PC__ +#define PORT_SETUP_CONTEXT(tp, wend, pf, arg) { \ + (tp)->ctxp = (struct port_intctx*)(((uint8_t *)(wend)) - \ + sizeof(struct port_intctx)); \ + (tp)->ctxp->r2 = (int)pf; \ + (tp)->ctxp->r3 = (int)pf >> 8; \ + (tp)->ctxp->r4 = (int)arg; \ + (tp)->ctxp->r5 = (int)arg >> 8; \ + (tp)->ctxp->pcx = 0; \ + (tp)->ctxp->pcl = (int)_port_thread_start >> 8; \ + (tp)->ctxp->pch = (int)_port_thread_start; \ +} +#else /* __AVR_3_BYTE_PC__ */ #define PORT_SETUP_CONTEXT(tp, wend, pf, arg) { \ (tp)->ctxp = (struct port_intctx*)(((uint8_t *)(wend)) - \ sizeof(struct port_intctx)); \ @@ -186,7 +202,7 @@ struct port_intctx { (tp)->ctxp->pcl = (int)_port_thread_start >> 8; \ (tp)->ctxp->pch = (int)_port_thread_start; \ } - +#endif /* __AVR_3_BYTE_PC__ */ /** * @brief Computes the thread working area global size. * @note There is no need to perform alignments in this macro. diff --git a/os/rt/ports/AVR/chcore.h b/os/rt/ports/AVR/chcore.h index a8785161b..b119f0635 100644 --- a/os/rt/ports/AVR/chcore.h +++ b/os/rt/ports/AVR/chcore.h @@ -101,6 +101,9 @@ struct port_extctx { uint8_t sr; uint8_t r1; uint8_t r0; +#ifdef __AVR_3_BYTE_PC__ + uint8_t pcx; +#endif uint16_t pc; }; @@ -131,6 +134,9 @@ struct port_intctx { uint8_t r4; uint8_t r3; uint8_t r2; +#ifdef __AVR_3_BYTE_PC__ + uint8_t pcx; +#endif uint8_t pcl; uint8_t pch; }; @@ -150,6 +156,19 @@ struct context { * @details This code usually setup the context switching frame represented * by an @p port_intctx structure. */ +#ifdef __AVR_3_BYTE_PC__ +#define PORT_SETUP_CONTEXT(tp, workspace, wsize, pf, arg) { \ + tp->p_ctx.sp = (struct port_intctx*)((uint8_t *)workspace + wsize - \ + sizeof(struct port_intctx)); \ + tp->p_ctx.sp->r2 = (int)pf; \ + tp->p_ctx.sp->r3 = (int)pf >> 8; \ + tp->p_ctx.sp->r4 = (int)arg; \ + tp->p_ctx.sp->r5 = (int)arg >> 8; \ + tp->p_ctx.sp->pcx = 0; \ + tp->p_ctx.sp->pcl = (int)_port_thread_start >> 8; \ + tp->p_ctx.sp->pch = (int)_port_thread_start; \ +} +#else /* __AVR_3_BYTE_PC__ */ #define PORT_SETUP_CONTEXT(tp, workspace, wsize, pf, arg) { \ tp->p_ctx.sp = (struct port_intctx*)((uint8_t *)workspace + wsize - \ sizeof(struct port_intctx)); \ @@ -160,6 +179,7 @@ struct context { tp->p_ctx.sp->pcl = (int)_port_thread_start >> 8; \ tp->p_ctx.sp->pch = (int)_port_thread_start; \ } +#endif /* __AVR_3_BYTE_PC__ */ /** * @brief Stack size for the system idle thread.