diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-11-29 12:56:26 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-11-29 12:56:26 +0000 |
commit | 49c92fbbb028a3fd0518473d39519572ff10141b (patch) | |
tree | 7c0c7976b14ede7af1f7b437d5d19e3b04800ccf /ports | |
parent | 62d821990abb79f9c7bb27f32d249bc934fa0990 (diff) | |
download | ChibiOS-49c92fbbb028a3fd0518473d39519572ff10141b.tar.gz ChibiOS-49c92fbbb028a3fd0518473d39519572ff10141b.tar.bz2 ChibiOS-49c92fbbb028a3fd0518473d39519572ff10141b.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@525 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports')
-rw-r--r-- | ports/ARM7/chcore.h | 2 | ||||
-rw-r--r-- | ports/ARMCM3/chcore.h | 2 | ||||
-rw-r--r-- | ports/AVR/chcore.c | 2 | ||||
-rw-r--r-- | ports/AVR/chcore.h | 43 |
4 files changed, 35 insertions, 14 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_ */
|