[AVR] Add support for models with 3-byte sized PC

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8009 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
Fabio Utzig 2015-06-04 12:25:39 +00:00
parent 6f6da8a73e
commit 0e2b620290
2 changed files with 37 additions and 1 deletions

View File

@ -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.

View File

@ -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.