aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/ARM7-LPC214x-GCC/Makefile4
-rw-r--r--demos/ARM7-LPC214x-GCC/chconf.h2
-rw-r--r--demos/ARM7-LPC214x-GCC/chcore.c2
-rw-r--r--demos/ARM7-LPC214x-GCC/chcore.h4
-rw-r--r--demos/ARM7-LPC214x-GCC/chcore2.s30
-rw-r--r--readme.txt14
-rw-r--r--src/chschd.c2
-rw-r--r--src/chsleep.c13
-rw-r--r--src/include/scheduler.h2
-rw-r--r--src/include/sleep.h10
-rw-r--r--test/test.c51
11 files changed, 92 insertions, 42 deletions
diff --git a/demos/ARM7-LPC214x-GCC/Makefile b/demos/ARM7-LPC214x-GCC/Makefile
index 755c134e5..0c0ad93e9 100644
--- a/demos/ARM7-LPC214x-GCC/Makefile
+++ b/demos/ARM7-LPC214x-GCC/Makefile
@@ -93,9 +93,9 @@ AOPT =
TOPT = -mthumb -D THUMB
# Common options here
-# NOTE: -ffixed-f7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in chconf.h.
+# NOTE: -ffixed-r7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in chconf.h.
OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing
-#OPT += -ffixed-f7
+#OPT += -ffixed-r7
# Define warning options here
WARN = -Wall -Wstrict-prototypes
diff --git a/demos/ARM7-LPC214x-GCC/chconf.h b/demos/ARM7-LPC214x-GCC/chconf.h
index ba9957e49..51aac3a64 100644
--- a/demos/ARM7-LPC214x-GCC/chconf.h
+++ b/demos/ARM7-LPC214x-GCC/chconf.h
@@ -160,7 +160,7 @@
* @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
#endif /* _CHCONF_H_ */
diff --git a/demos/ARM7-LPC214x-GCC/chcore.c b/demos/ARM7-LPC214x-GCC/chcore.c
index 128fb97aa..2f60c9d53 100644
--- a/demos/ARM7-LPC214x-GCC/chcore.c
+++ b/demos/ARM7-LPC214x-GCC/chcore.c
@@ -214,6 +214,6 @@ void NonVectoredIrq(void) {
void Timer0Irq(void) {
T0IR = 1; /* Clear interrupt on match MR0. */
- VICVectAddr = 0;
chSchTimerHandlerI();
+ VICVectAddr = 0;
}
diff --git a/demos/ARM7-LPC214x-GCC/chcore.h b/demos/ARM7-LPC214x-GCC/chcore.h
index 5a42cdf89..9a1401f1c 100644
--- a/demos/ARM7-LPC214x-GCC/chcore.h
+++ b/demos/ARM7-LPC214x-GCC/chcore.h
@@ -37,7 +37,7 @@ struct stackregs {
regarm r4;
regarm r5;
regarm r6;
-#ifndef MK_CURRP_REGISTER_CACHE
+#ifndef CH_CURRP_REGISTER_CACHE
regarm r7;
#endif
regarm r8;
@@ -51,7 +51,7 @@ typedef struct {
struct stackregs *r13;
} Context;
-#ifdef MK_CURRP_REGISTER_CACHE
+#ifdef CH_CURRP_REGISTER_CACHE
#define SETUP_CONTEXT(workspace, wsize, pf, arg) \
{ \
tp->p_ctx.r13 = (struct stackregs *)((BYTE8 *)workspace + \
diff --git a/demos/ARM7-LPC214x-GCC/chcore2.s b/demos/ARM7-LPC214x-GCC/chcore2.s
index f734eebba..1eb301fbe 100644
--- a/demos/ARM7-LPC214x-GCC/chcore2.s
+++ b/demos/ARM7-LPC214x-GCC/chcore2.s
@@ -47,10 +47,6 @@ threadstart:
SwiHandler:
b SwiHandler
-.globl DefIrqHandler
-DefIrqHandler:
- b DefIrqHandler
-
.globl FiqHandler
FiqHandler:
b FiqHandler
@@ -109,7 +105,7 @@ chSysSwitchI:
* | R10 | |
* | R9 | |
* | R8 | | Internal context: mk_SwitchI() frame
- * | (R7) | | (optional, see MK_CURRP_REGISTER_CACHE)
+ * | (R7) | | (optional, see CH_CURRP_REGISTER_CACHE)
* | R6 | |
* | R5 | |
* SP-> | R4 | -+
@@ -119,9 +115,9 @@ chSysSwitchI:
IrqHandler:
sub lr, lr, #4
stmfd sp!, {r0-r3, r12, lr}
- mrs r0, SPSR // Workaround for ARM7TDMI+VIC
- tst r0, #I_BIT // spurious interrupts.
- ldmnefd sp!, {r0-r3, r12, pc}
+// mrs r0, SPSR // Workaround for ARM7TDMI+VIC
+// tst r0, #I_BIT // spurious interrupts.
+// ldmnefd sp!, {r0-r3, r12, pc}
bl NonVectoredIrq
b IrqCommon
@@ -129,9 +125,9 @@ IrqHandler:
T0IrqHandler:
sub lr, lr, #4
stmfd sp!, {r0-r3, r12, lr}
- mrs r0, SPSR // Workaround for ARM7TDMI+VIC
- tst r0, #I_BIT // spurious interrupts.
- ldmnefd sp!, {r0-r3, r12, pc}^
+// mrs r0, SPSR // Workaround for ARM7TDMI+VIC
+// tst r0, #I_BIT // spurious interrupts.
+// ldmnefd sp!, {r0-r3, r12, pc}^
bl Timer0Irq
b IrqCommon
@@ -139,9 +135,9 @@ T0IrqHandler:
UART0IrqHandler:
sub lr, lr, #4
stmfd sp!, {r0-r3, r12, lr}
- mrs r0, SPSR // Workaround for ARM7TDMI+VIC
- tst r0, #I_BIT // spurious interrupts.
- ldmnefd sp!, {r0-r3, r12, pc}^
+// mrs r0, SPSR // Workaround for ARM7TDMI+VIC
+// tst r0, #I_BIT // spurious interrupts.
+// ldmnefd sp!, {r0-r3, r12, pc}^
bl UART0Irq
b IrqCommon
@@ -149,9 +145,9 @@ UART0IrqHandler:
UART1IrqHandler:
sub lr, lr, #4
stmfd sp!, {r0-r3, r12, lr}
- mrs r0, SPSR // Workaround for ARM7TDMI+VIC
- tst r0, #I_BIT // spurious interrupts.
- ldmnefd sp!, {r0-r3, r12, pc}^
+// mrs r0, SPSR // Workaround for ARM7TDMI+VIC
+// tst r0, #I_BIT // spurious interrupts.
+// ldmnefd sp!, {r0-r3, r12, pc}^
bl UART1Irq
b IrqCommon
diff --git a/readme.txt b/readme.txt
index 38792a82e..79b03287d 100644
--- a/readme.txt
+++ b/readme.txt
@@ -39,7 +39,11 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet.
*****************************************************************************
*** 0.4.0 ***
-- Implemented a debug subsystem, it supports debug messages and a context
+- NEW, added a benchmark functionality to the test suite. The benchmark
+ measures the kernel throughput as messages per second and context switches
+ per second. The benchmark will be useful for fine tuning the compiler
+ options and the kernel itself.
+- NEW, implemented a debug subsystem, it supports debug messages and a context
switch circular trace buffer. The debug code can be enabled/disabled by
using the CH_USE_DEBUG in chconf.h.
The trace buffer is meant to be fetched and decoded by an external tool
@@ -47,6 +51,12 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet.
- Implemented panic messages when CH_USE_DEBUG is enabled.
- Added a thread identifier field to the Thread structure, it is used only
for debug.
+- Global variable stime modified as volatile.
+- API chSysGetTime() reimplemented as a macro.
+- Fixed a regression with the CH_CURRP_REGISTER_CACHE option.
+- Fixed a problem in the LPC2148 interrupt handling code, a spurious
+ interrupts fix recommended on the NXP data sheet proved to be a very bad
+ idea and not about real spurious interrupts also...
- Fixed an harmless warning message in buzzer.c.
*** 0.3.6 ***
@@ -66,7 +76,7 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet.
- Fixed a minor problem in the interrupt initialization code for the LPC214x
demo, regrouped the VIC-specific code into vic.c/vic.h.
- Fixed a bug into the LPC2148 serial driver (limited to the serial port 2).
-- Implemented HW transmit FIFO preloading in the LPC2142 serial driver in
+- Implemented HW transmit FIFO preloading in the LPC2148 serial driver in
order to minimize the number of interrupts generated, it is possible to
disable the feature and return to the old code which is a bit smaller, see
the configuration parameters in ./ARM7-LPC214x/GCC/lpc214x_serial.h.
diff --git a/src/chschd.c b/src/chschd.c
index c30040520..c88a63ead 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -34,7 +34,7 @@ Thread *currp;
#endif
#ifdef CH_USE_SYSTEMTIME
-t_time stime;
+volatile t_time stime;
#endif
/** @endcond */
diff --git a/src/chsleep.c b/src/chsleep.c
index 6c8cfc3c3..e8703ab1a 100644
--- a/src/chsleep.c
+++ b/src/chsleep.c
@@ -42,19 +42,6 @@ void chThdSleep(t_time time) {
#ifdef CH_USE_SYSTEMTIME
/**
- * Returns the number of system ticks since the \p chSysInit() invocation.
- * @return the system ticks number
- * @note The counter can reach its maximum and return to zero.
- * @note This function is designed to work with the \p chThdSleepUntil().
- * @note The function is available only if the \p CH_USE_SYSTEMTIME
- * option is enabled in \p chconf.h.
- */
-t_time chSysGetTime(void) {
-
- return stime;
-}
-
-/**
* Suspends the invoking thread until the system time arrives to the specified
* value.
* @param time the system time
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index fccbfb446..12393e0db 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -78,7 +78,7 @@ extern Thread *currp;
* instead. Direct use of system global variables is discouraged because
* portability reasons.
*/
-extern t_time stime;
+extern volatile t_time stime;
#endif /* _SCHEDULER_H_ */
diff --git a/src/include/sleep.h b/src/include/sleep.h
index e3fa2ffda..e102a03a5 100644
--- a/src/include/sleep.h
+++ b/src/include/sleep.h
@@ -39,6 +39,16 @@ extern "C" {
}
#endif
+/**
+ * Returns the number of system ticks since the \p chSysInit() invocation.
+ * @return the system ticks number
+ * @note The counter can reach its maximum and then returns to zero.
+ * @note This function is designed to work with the \p chThdSleepUntil().
+ * @note The function is available only if the \p CH_USE_SYSTEMTIME
+ * option is enabled in \p chconf.h.
+ */
+#define chSysGetTime() stime
+
#endif /* _SLEEP_H_ */
/** @} */
diff --git a/test/test.c b/test/test.c
index fbaedd280..8fe61794c 100644
--- a/test/test.c
+++ b/test/test.c
@@ -46,10 +46,29 @@ static void wait(void) {
chThdWait(t5);
}
-static void println(char *msgp) {
+static void printn(unsigned int n) {
+ char buf[16], *p;
+
+ if (!n)
+ chFDDPut(comp, '0');
+ else {
+ p = buf;
+ while (n)
+ *p++ = (n % 10) + '0', n /= 10;
+ while (p > buf)
+ chFDDPut(comp, *--p);
+ }
+}
+
+static void print(char *msgp) {
while (*msgp)
chFDDPut(comp, *msgp++);
+}
+
+static void println(char *msgp) {
+
+ print(msgp);
chFDDPut(comp, '\r');
chFDDPut(comp, '\n');
}
@@ -94,12 +113,19 @@ t_msg Thread5(void *p) {
return 0;
}
+t_msg Thread6(void *p) {
+
+ while (!chThdShouldTerminate())
+ chMsgRelease(chMsgWait() + 1);
+ return 0;
+}
+
/**
* Tester thread, this thread must be created with priority \p NORMALPRIO.
*/
t_msg TestThread(void *p) {
t_msg msg;
- int i;
+ unsigned int i;
comp = p;
println("*****************************");
@@ -202,6 +228,27 @@ t_msg TestThread(void *p) {
chThdWait(t1);
println("");
+ /*
+ * Kernel benchmarks.
+ */
+ println("*** Kernel Benchmark, context switch stress test:");
+ t_time time = chSysGetTime() + 1;
+ while (chSysGetTime() < time)
+ ;
+ time += 1000;
+ i = 0;
+ t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread6, chThdSelf());
+ while (chSysGetTime() < time)
+ i = chMsgSend(t1, i);
+ chThdTerminate(t1);
+ chMsgSend(t1, 0); /* Lets the thread check the termination flag.*/
+ chThdWait(t1);
+ print("Messages throughput = ");
+ printn(i);
+ print(" msg/S, ");
+ printn(i << 1);
+ println(" ctxsw/S");
+
println("\r\nTest complete");
return 0;
}