diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2007-11-27 11:43:28 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2007-11-27 11:43:28 +0000 |
commit | a134cd919ea3e6fee591bc29d360f3da74f46a8b (patch) | |
tree | 621c6bd96434a06ce6fd517934f1db6255187c60 | |
parent | a62cb84475bb6212554b847751a409a6183f05a0 (diff) | |
download | ChibiOS-a134cd919ea3e6fee591bc29d360f3da74f46a8b.tar.gz ChibiOS-a134cd919ea3e6fee591bc29d360f3da74f46a8b.tar.bz2 ChibiOS-a134cd919ea3e6fee591bc29d360f3da74f46a8b.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@115 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | demos/ARM7-LPC214x-GCC-minimal/chconf.h | 4 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC/chconf.h | 6 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC/chcore.c | 6 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC/chcore.h | 28 | ||||
-rw-r--r-- | demos/AVR-AT90CANx-GCC/chconf.h | 4 | ||||
-rw-r--r-- | demos/AVR-AT90CANx-GCC/chcore.h | 31 | ||||
-rw-r--r-- | demos/Win32-MSVS/chconf.h | 4 | ||||
-rw-r--r-- | demos/Win32-MinGW/chconf.h | 4 | ||||
-rw-r--r-- | docs/Doxyfile | 2 | ||||
-rw-r--r-- | src/chdebug.c | 46 | ||||
-rw-r--r-- | src/chschd.c | 4 | ||||
-rw-r--r-- | src/include/debug.h | 13 | ||||
-rw-r--r-- | src/templates/chconf.h | 6 | ||||
-rw-r--r-- | src/templates/chcore.c | 6 | ||||
-rw-r--r-- | src/templates/chcore.h | 41 |
15 files changed, 133 insertions, 72 deletions
diff --git a/demos/ARM7-LPC214x-GCC-minimal/chconf.h b/demos/ARM7-LPC214x-GCC-minimal/chconf.h index 70908e292..fc81d571f 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/chconf.h +++ b/demos/ARM7-LPC214x-GCC-minimal/chconf.h @@ -162,6 +162,10 @@ */
//#define CH_USE_DEBUG
+/** Debug option: Includes the threads context switch tracing feature.
+ */
+//#define CH_USE_TRACE
+
#endif /* _CHCONF_H_ */
/** @} */
diff --git a/demos/ARM7-LPC214x-GCC/chconf.h b/demos/ARM7-LPC214x-GCC/chconf.h index 51aac3a64..311d6efbc 100644 --- a/demos/ARM7-LPC214x-GCC/chconf.h +++ b/demos/ARM7-LPC214x-GCC/chconf.h @@ -160,7 +160,11 @@ * @note the debug support is port-dependent, it may be not present on some
* targets. In that case stub functions will be included.
*/
-//#define CH_USE_DEBUG
+#define CH_USE_DEBUG
+
+/** Debug option: Includes the threads context switch tracing feature.
+ */
+#define CH_USE_TRACE
#endif /* _CHCONF_H_ */
diff --git a/demos/ARM7-LPC214x-GCC/chcore.c b/demos/ARM7-LPC214x-GCC/chcore.c index 49d1d314f..ad6f3a82c 100644 --- a/demos/ARM7-LPC214x-GCC/chcore.c +++ b/demos/ARM7-LPC214x-GCC/chcore.c @@ -166,6 +166,12 @@ void chSysHalt(void) { }
/*
+ * System console message (implemented via JTAG).
+ */
+void chSysPuts(char *msg) {
+}
+
+/*
* Non-vectored IRQs handling here.
*/
void NonVectoredIrq(void) {
diff --git a/demos/ARM7-LPC214x-GCC/chcore.h b/demos/ARM7-LPC214x-GCC/chcore.h index d5ad07040..5c595ae4f 100644 --- a/demos/ARM7-LPC214x-GCC/chcore.h +++ b/demos/ARM7-LPC214x-GCC/chcore.h @@ -71,13 +71,13 @@ typedef struct { /*
* Platform dependent part of the \p chThdCreate() API.
*/
-#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
- tp->p_ctx.r13 = (struct intctx *)((BYTE8 *)workspace + \
- wsize - \
- sizeof(struct intctx)); \
- tp->p_ctx.r13->r4 = pf; \
- tp->p_ctx.r13->r5 = arg; \
- tp->p_ctx.r13->lr = threadstart; \
+#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
+ tp->p_ctx.r13 = (struct intctx *)((BYTE8 *)workspace + \
+ wsize - \
+ sizeof(struct intctx)); \
+ tp->p_ctx.r13->r4 = pf; \
+ tp->p_ctx.r13->r5 = arg; \
+ tp->p_ctx.r13->lr = threadstart; \
}
#ifdef THUMB
@@ -88,19 +88,16 @@ extern void chSysUnlock(void); #define chSysUnlock() asm("msr CPSR_c, #0x1F")
#endif /* THUMB */
-#define chSysPuts(msg) {}
-
#ifdef THUMB
#define INT_REQUIRED_STACK 0x10
#else /* !THUMB */
#define INT_REQUIRED_STACK 0
#endif /* THUMB */
-#define UserStackSize(n) (((sizeof(Thread) + \
- sizeof(struct intctx) + \
- sizeof(struct extctx) + \
- (INT_REQUIRED_STACK) + \
- (n) - 1) | 3) + 1)
-
+#define StackAlign(n) ((((n) - 1) | 3) + 1)
+#define UserStackSize(n) StackAlign(sizeof(Thread) + \
+ sizeof(struct intctx) + \
+ sizeof(struct extctx) + \
+ (n) + (INT_REQUIRED_STACK))
#define WorkingArea(s, n) ULONG32 s[UserStackSize(n) >> 2];
/* It requires zero bytes, but better be safe.*/
@@ -109,6 +106,7 @@ void _IdleThread(void *p) __attribute__((noreturn)); void chSysHalt(void) __attribute__((noreturn));
void chSysSwitchI(Context *oldp, Context *newp);
+void chSysPuts(char *msg);
void threadstart(void);
void DefFiqHandler(void);
void DefIrqHandler(void);
diff --git a/demos/AVR-AT90CANx-GCC/chconf.h b/demos/AVR-AT90CANx-GCC/chconf.h index c6146f5e7..2bc89dc2f 100644 --- a/demos/AVR-AT90CANx-GCC/chconf.h +++ b/demos/AVR-AT90CANx-GCC/chconf.h @@ -163,6 +163,10 @@ */
//#define CH_USE_DEBUG
+/** Debug option: Includes the threads context switch tracing feature.
+ */
+//#define CH_USE_TRACE
+
#endif /* _CHCONF_H_ */
/** @} */
diff --git a/demos/AVR-AT90CANx-GCC/chcore.h b/demos/AVR-AT90CANx-GCC/chcore.h index 07cb45f64..9e1b95db8 100644 --- a/demos/AVR-AT90CANx-GCC/chcore.h +++ b/demos/AVR-AT90CANx-GCC/chcore.h @@ -83,26 +83,21 @@ typedef struct { /**
* Platform dependent part of the \p chThdCreate() API.
*/
-#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
- tp->p_ctx.sp--; \
- 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->pc = (UWORD16)threadstart; \
+#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
+ tp->p_ctx.sp--; \
+ 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->pc = (UWORD16)threadstart; \
}
-/*
- * Interrupt stack usage except for saved registers.
- */
-#define EXTRA_INT_STACK 0x10
-
-#define UserStackSize(n) (sizeof(Thread) + \
- sizeof(struct intctx) + \
- sizeof(struct extctx) + \
- EXTRA_INT_STACK + \
- (n))
-
+#define INT_REQUIRED_STACK 0x10
+#define StackAlign(n) (n)
+#define UserStackSize(n) StackAlign(sizeof(Thread) + \
+ sizeof(struct intctx) + \
+ sizeof(struct extctx) + \
+ (n) + (INT_REQUIRED_STACK))
#define WorkingArea(s, n) BYTE8 s[UserStackSize(n)];
#define chSysLock() asm("cli")
diff --git a/demos/Win32-MSVS/chconf.h b/demos/Win32-MSVS/chconf.h index be1896046..5941cc856 100644 --- a/demos/Win32-MSVS/chconf.h +++ b/demos/Win32-MSVS/chconf.h @@ -167,6 +167,10 @@ */
//#define CH_USE_DEBUG
+/** Debug option: Includes the threads context switch tracing feature.
+ */
+//#define CH_USE_TRACE
+
#endif /* _CHCONF_H_ */
/** @} */
diff --git a/demos/Win32-MinGW/chconf.h b/demos/Win32-MinGW/chconf.h index 8ce32defa..af19dd995 100644 --- a/demos/Win32-MinGW/chconf.h +++ b/demos/Win32-MinGW/chconf.h @@ -167,6 +167,10 @@ */
//#define CH_USE_DEBUG
+/** Debug option: Includes the threads context switch tracing feature.
+ */
+//#define CH_USE_TRACE
+
#endif /* _CHCONF_H_ */
/** @} */
diff --git a/docs/Doxyfile b/docs/Doxyfile index 2c9999f94..87ee6c879 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -4,7 +4,7 @@ # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = ChibiOS/RT -PROJECT_NUMBER = "0.4.2 beta" +PROJECT_NUMBER = "0.4.3 beta" OUTPUT_DIRECTORY = . CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English diff --git a/src/chdebug.c b/src/chdebug.c index d08f91fd1..29e855e9c 100644 --- a/src/chdebug.c +++ b/src/chdebug.c @@ -21,7 +21,6 @@ #ifdef CH_USE_DEBUG
-TraceBuffer dbgtb;
char *dbglastmsg;
/**
@@ -29,27 +28,10 @@ char *dbglastmsg; */
void chDbgInit(void) {
+#ifdef CH_USE_TRACE
dbgtb.tb_size = TRACE_BUFFER_SIZE;
dbgtb.tb_ptr = &dbgtb.tb_buffer[0];
-}
-
-/**
- * Inserts in the circular debug trace buffer a context switch record.
- * @param otp the thread being switched out
- * @param ntp the thread to be resumed
- */
-void chDbgTrace(Thread *otp, Thread *ntp) {
-
- dbgtb.tb_ptr->cse_slpdata = otp->p_common;
-#ifdef CH_USE_SYSTEMTIME
- dbgtb.tb_ptr->cse_time = chSysGetTime();
-#else
- dbgtb.tb_ptr->cse_time = 0;
#endif
- dbgtb.tb_ptr->cse_state = otp->p_state;
- dbgtb.tb_ptr->cse_tid = ntp->p_tid;
- if (++dbgtb.tb_ptr >= &dbgtb.tb_buffer[TRACE_BUFFER_SIZE])
- dbgtb.tb_ptr = &dbgtb.tb_buffer[0];
}
/**
@@ -72,4 +54,30 @@ void chDbgPanic(char *msg) { chSysHalt();
}
+#ifdef CH_USE_TRACE
+/**
+ * Public trace buffer.
+ */
+TraceBuffer dbgtb;
+
+/**
+ * Inserts in the circular debug trace buffer a context switch record.
+ * @param otp the thread being switched out
+ * @param ntp the thread to be resumed
+ */
+void chDbgTrace(Thread *otp, Thread *ntp) {
+
+ dbgtb.tb_ptr->cse_slpdata = otp->p_common;
+#ifdef CH_USE_SYSTEMTIME
+ dbgtb.tb_ptr->cse_time = chSysGetTime();
+#else
+ dbgtb.tb_ptr->cse_time = 0;
+#endif
+ dbgtb.tb_ptr->cse_state = otp->p_state;
+ dbgtb.tb_ptr->cse_tid = ntp->p_tid;
+ if (++dbgtb.tb_ptr >= &dbgtb.tb_buffer[TRACE_BUFFER_SIZE])
+ dbgtb.tb_ptr = &dbgtb.tb_buffer[0];
+}
+#endif /* CH_USE_TRACE */
+
#endif /* CH_USE_DEBUG */
diff --git a/src/chschd.c b/src/chschd.c index fe42f7ccc..c4b5df5a9 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -88,7 +88,7 @@ void chSchGoSleepS(t_tstate newstate) { (otp = currp)->p_state = newstate;
(currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR;
rlist.r_preempt = CH_TIME_QUANTUM;
-#ifdef CH_USE_DEBUG
+#ifdef CH_USE_TRACE
chDbgTrace(otp, currp);
#endif
chSysSwitchI(&otp->p_ctx, &currp->p_ctx);
@@ -115,7 +115,7 @@ void chSchWakeupS(Thread *ntp, t_msg msg) { (currp = ntp)->p_state = PRCURR;
ntp->p_rdymsg = msg;
rlist.r_preempt = CH_TIME_QUANTUM;
-#ifdef CH_USE_DEBUG
+#ifdef CH_USE_TRACE
chDbgTrace(otp, ntp);
#endif
chSysSwitchI(&otp->p_ctx, &ntp->p_ctx);
diff --git a/src/include/debug.h b/src/include/debug.h index 38d9c2ff1..bf5b3ee7d 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -27,7 +27,7 @@ #ifdef CH_USE_DEBUG
-#ifndef TRACE_BUFFER_SIZE
+#ifndef TRACE_BUFFER_SIZE
#define TRACE_BUFFER_SIZE 64
#endif
@@ -52,7 +52,6 @@ extern char *dbglastmsg; extern "C" {
#endif
void chDbgInit(void);
- void chDbgTrace(Thread *otp, Thread *ntp);
void chDbgPuts(char *msg);
void chDbgPanic(char *msg);
#ifdef __cplusplus
@@ -67,6 +66,16 @@ extern "C" { #endif /* CH_USE_DEBUG */
+#ifdef CH_USE_TRACE
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chDbgTrace(Thread *otp, Thread *ntp);
+#ifdef __cplusplus
+}
+#endif
+#endif /* CH_USE_TRACE */
+
#endif /* _DEBUG_H_ */
/** @} */
diff --git a/src/templates/chconf.h b/src/templates/chconf.h index c8214c623..d8f0f9ae4 100644 --- a/src/templates/chconf.h +++ b/src/templates/chconf.h @@ -157,12 +157,16 @@ */
//#define CH_CURRP_REGISTER_CACHE "reg"
-/** Configuration option: Includes basic debug support to the kernel.
+/** Debug option: Includes basic debug support to the kernel.
* @note the debug support is port-dependent, it may be not present on some
* targets. In that case stub functions will be included.
*/
#define CH_USE_DEBUG
+/** Debug option: Includes the threads context switch tracing feature.
+ */
+#define CH_USE_TRACE
+
#endif /* _CHCONF_H_ */
/** @} */
diff --git a/src/templates/chcore.c b/src/templates/chcore.c index ec2b39592..195113abf 100644 --- a/src/templates/chcore.c +++ b/src/templates/chcore.c @@ -59,4 +59,10 @@ void chSysHalt(void) { */
void chSysSwitchI(Context *oldp, Context *newp) {}
+/**
+ * Prints a message on the system console (if any).
+ */
+void chSysPuts(char *msg) {
+}
+
/** @} */
diff --git a/src/templates/chcore.h b/src/templates/chcore.h index 7f2c5fb0b..c88748f8b 100644 --- a/src/templates/chcore.h +++ b/src/templates/chcore.h @@ -25,21 +25,27 @@ #ifndef _CHCORE_H_
#define _CHCORE_H_
-/*
- * Stack saved context.
+/**
+ * Interrupt saved context.
+ */
+struct extctx {
+};
+
+/**
+ * System saved context.
*/
-struct stackregs {
+struct intctx {
};
typedef struct {
- struct stackregs *sp;
+ struct intctx *sp;
} Context;
/**
* Platform dependent part of the \p chThdCreate() API.
*/
-#define SETUP_CONTEXT(workspace, wsize, pf, arg) \
-{ \
+#define SETUP_CONTEXT(workspace, wsize, pf, arg) \
+{ \
}
/**
@@ -53,11 +59,24 @@ typedef struct { #define INT_REQUIRED_STACK 0
/**
+ * Enforces a stack size alignment.
+ */
+#define StackAlign(n) (n)
+
+/**
* Macro to be used when allocating stack spaces, it adds the system-specific
* overhead.
*/
-#define UserStackSize(n) (sizeof(Thread) + \
- sizeof(struct stackregs) + (n) + (INT_REQUIRED_STACK))
+#define UserStackSize(n) StackAlign(sizeof(Thread) + \
+ sizeof(struct intctx) + \
+ sizeof(struct extctx) + \
+ (n) + (INT_REQUIRED_STACK))
+
+/**
+ * Macro used to allocate a thread working area aligned as both position and
+ * size.
+ */
+#define WorkingArea(s, n) BYTE8 s[UserStackSize(n)];
/**
* Enters the ChibiOS/RT system mutual exclusion zone, the implementation is
@@ -81,14 +100,10 @@ typedef struct { */
#define chSysUnlock()
-/**
- * Prints a message on the system console (if any).
- */
-#define chSysPuts(msg) {}
-
void _IdleThread(void *p);
void chSysHalt(void);
void chSysSwitchI(Context *oldp, Context *newp);
+void chSysPuts(char *msg);
#endif /* _CHCORE_H_ */
|