aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Utzig <utzig@utzig.org>2015-06-04 12:25:39 +0000
committerFabio Utzig <utzig@utzig.org>2015-06-04 12:25:39 +0000
commit0e2b620290bcf45094f086e9d7a744a1c312b42b (patch)
tree7cfe81d0a3f60690a554297942d858e9970fb179
parent6f6da8a73e877306e1fd96bfb5015de9849c575b (diff)
downloadChibiOS-0e2b620290bcf45094f086e9d7a744a1c312b42b.tar.gz
ChibiOS-0e2b620290bcf45094f086e9d7a744a1c312b42b.tar.bz2
ChibiOS-0e2b620290bcf45094f086e9d7a744a1c312b42b.zip
[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
-rw-r--r--os/nil/ports/AVR/nilcore.h18
-rw-r--r--os/rt/ports/AVR/chcore.h20
2 files changed, 37 insertions, 1 deletions
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,7 @@ 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)); \
@@ -183,10 +187,22 @@ struct port_intctx {
(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)); \
+ (tp)->ctxp->r2 = (int)pf; \
+ (tp)->ctxp->r3 = (int)pf >> 8; \
+ (tp)->ctxp->r4 = (int)arg; \
+ (tp)->ctxp->r5 = (int)arg >> 8; \
+ (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.