git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@89 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
95618293b7
commit
e776216d02
|
@ -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
|
||||
|
|
|
@ -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_ */
|
||||
|
||||
|
|
|
@ -214,6 +214,6 @@ void NonVectoredIrq(void) {
|
|||
void Timer0Irq(void) {
|
||||
|
||||
T0IR = 1; /* Clear interrupt on match MR0. */
|
||||
VICVectAddr = 0;
|
||||
chSchTimerHandlerI();
|
||||
VICVectAddr = 0;
|
||||
}
|
||||
|
|
|
@ -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 + \
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
14
readme.txt
14
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.
|
||||
|
|
|
@ -34,7 +34,7 @@ Thread *currp;
|
|||
#endif
|
||||
|
||||
#ifdef CH_USE_SYSTEMTIME
|
||||
t_time stime;
|
||||
volatile t_time stime;
|
||||
#endif
|
||||
|
||||
/** @endcond */
|
||||
|
|
|
@ -41,19 +41,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.
|
||||
|
|
|
@ -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_ */
|
||||
|
||||
|
|
|
@ -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_ */
|
||||
|
||||
/** @} */
|
||||
|
|
51
test/test.c
51
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue