aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ports/ARM7/chcore.h2
-rw-r--r--ports/ARMCM3/chcore.h2
-rw-r--r--ports/AVR/chcore.c2
-rw-r--r--ports/AVR/chcore.h43
-rw-r--r--readme.txt4
-rw-r--r--src/templates/chcore.h2
6 files changed, 38 insertions, 17 deletions
diff --git a/ports/ARM7/chcore.h b/ports/ARM7/chcore.h
index 74d3d4890..ee18aab25 100644
--- a/ports/ARM7/chcore.h
+++ b/ports/ARM7/chcore.h
@@ -135,7 +135,7 @@ extern "C" {
INT_REQUIRED_STACK)
#define UserStackSize(n) THD_WA_SIZE(n)
-#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n)];
+#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
#define WorkingArea(s, n) WORKING_AREA(s, n)
#ifdef THUMB
diff --git a/ports/ARMCM3/chcore.h b/ports/ARMCM3/chcore.h
index d4b3dd3bc..6474d91d0 100644
--- a/ports/ARMCM3/chcore.h
+++ b/ports/ARMCM3/chcore.h
@@ -133,7 +133,7 @@ typedef struct {
INT_REQUIRED_STACK)
#define UserStackSize(n) THD_WA_SIZE(n)
-#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n)];
+#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
#define WorkingArea(s, n) WORKING_AREA(s, n)
/* called on each interrupt entry, currently nothing is done */
diff --git a/ports/AVR/chcore.c b/ports/AVR/chcore.c
index 022e80e64..340843d45 100644
--- a/ports/AVR/chcore.c
+++ b/ports/AVR/chcore.c
@@ -21,7 +21,7 @@
#include <avr/io.h>
-void _IdleThread(void *p) {
+void _idle(void *p) {
while (TRUE) {
asm("sleep");
diff --git a/ports/AVR/chcore.h b/ports/AVR/chcore.h
index fe0f13e1f..534575874 100644
--- a/ports/AVR/chcore.h
+++ b/ports/AVR/chcore.h
@@ -20,9 +20,17 @@
#ifndef _CHCORE_H_
#define _CHCORE_H_
+/**
+ * Macro defining the AVR architecture.
+ */
#define CH_ARCHITECTURE_AVR
/*
+ * 8 bit stack alignment.
+ */
+typedef uint8_t stkalign_t;
+
+/*
* Interrupt saved context.
*/
struct extctx {
@@ -97,12 +105,19 @@ typedef struct {
}
#define INT_REQUIRED_STACK 8
-#define StackAlign(n) (n)
-#define UserStackSize(n) StackAlign(sizeof(Thread) + \
- (sizeof(struct intctx) - 1) + \
- (sizeof(struct extctx) - 1) + \
- (n) + (INT_REQUIRED_STACK))
-#define WorkingArea(s, n) uint8_t s[UserStackSize(n)];
+
+#define STACK_ALIGN(n) ((((n) - 1) | sizeof(stkalign_t)) + 1)
+#define StackAlign(n) STACK_ALIGN(n)
+
+#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
+ (sizeof(struct intctx) - 1) + \
+ (sizeof(struct extctx) - 1) + \
+ (n) + \
+ INT_REQUIRED_STACK)
+#define UserStackSize(n) THD_WA_SIZE(n)
+
+#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
+#define WorkingArea(s, n) WORKING_AREA(s, n)
#define chSysLock() asm volatile ("cli")
@@ -121,11 +136,17 @@ typedef struct {
}
#define IDLE_THREAD_STACK_SIZE 8
-void _IdleThread(void *p) __attribute__((noreturn));
-void chSysHalt(void) __attribute__((noreturn)) ;
-void chSysSwitchI(Thread *otp, Thread *ntp);
-void chSysPuts(char *msg);
-void threadstart(void) __attribute__((naked));
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void _idle(void *p) __attribute__((noreturn));
+ void chSysHalt(void) __attribute__((noreturn)) ;
+ void chSysSwitchI(Thread *otp, Thread *ntp);
+ void chSysPuts(char *msg);
+ void threadstart(void) __attribute__((naked));
+#ifdef __cplusplus
+}
+#endif
#endif /* _CHCORE_H_ */
diff --git a/readme.txt b/readme.txt
index d1452860f..17615ffc2 100644
--- a/readme.txt
+++ b/readme.txt
@@ -75,8 +75,8 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
*** 0.8.2 ***
- FIX: Duplicated sections in the documentation removed.
-- FIX: Minor problem in Cortex-M3 port affecting chSysHalt() and chSysPuts()
- functions when the kernel is compiled with G++.
+- FIX: Minor problem in Cortex-M3 and AVR ports when the kernel is compiled
+ using G++.
- NEW: Added chPoolAllocI() and chPoolFreeI() APIs in order to allow the use
of memory pools from interrupt handlers and timer callbacks.
- CHANGE: The macros WorkingArea(), UserStackSize() and StackAlign() are now
diff --git a/src/templates/chcore.h b/src/templates/chcore.h
index 663033fb5..40a468b64 100644
--- a/src/templates/chcore.h
+++ b/src/templates/chcore.h
@@ -108,7 +108,7 @@ typedef struct {
* Macro used to allocate a thread working area aligned as both position and
* size.
*/
-#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n)];
+#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
/**
* IRQ handler enter code.