From e2b6b440e12562804f161d8db677554bbd666bd1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Jan 2009 16:21:27 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@612 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-AT91SAM7X-GCC/Makefile | 2 +- demos/ARM7-AT91SAM7X-GCC/Makefile.thumb | 2 +- demos/ARM7-AT91SAM7X-GCC/board.c | 16 ++++++------ demos/ARM7-AT91SAM7X-GCC/chconf.h | 9 +++++++ demos/ARM7-AT91SAM7X-WEB-GCC/Makefile | 2 +- demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb | 2 +- demos/ARM7-AT91SAM7X-WEB-GCC/board.c | 16 ++++++------ demos/ARM7-AT91SAM7X-WEB-GCC/chconf.h | 9 +++++++ demos/ARM7-LPC214x-G++/Makefile | 2 +- demos/ARM7-LPC214x-G++/Makefile.thumb | 2 +- demos/ARM7-LPC214x-G++/board.c | 14 +++++------ demos/ARM7-LPC214x-G++/chconf.h | 9 +++++++ demos/ARM7-LPC214x-GCC-minimal/Makefile | 2 +- demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb | 2 +- demos/ARM7-LPC214x-GCC-minimal/board.c | 14 +++++------ demos/ARM7-LPC214x-GCC-minimal/chconf.h | 9 +++++++ demos/ARM7-LPC214x-GCC/Makefile.thumb | 2 +- demos/ARM7-LPC214x-GCC/board.c | 14 +++++------ demos/ARM7-LPC214x-GCC/chconf.h | 9 +++++++ demos/AVR-AT90CANx-GCC/board.c | 6 ++--- demos/AVR-ATmega128-GCC/board.c | 6 ++--- demos/AVR-ATmega128-GCC/chconf.h | 9 +++++++ demos/MSP430-MSP430x1611-GCC/board.c | 6 ++--- demos/MSP430-MSP430x1611-GCC/chconf.h | 9 +++++++ demos/Win32-MinGW/chconf.h | 9 +++++++ ports/ARM7-AT91SAM7X/sam7x_emac.c | 6 +++-- ports/ARM7-AT91SAM7X/sam7x_serial.c | 12 ++++++--- ports/ARM7-LPC214x/lpc214x_serial.c | 12 ++++++--- ports/ARMCM3-STM32F103/stm32_serial.c | 24 +++++++++++------- ports/ARMCM3/chcore.c | 8 +++--- ports/AVR/avr_serial.c | 24 +++++++++--------- ports/AVR/chcore.h | 10 +++++++- ports/MSP430/chcore.h | 10 +++++++- ports/MSP430/msp430_serial.c | 25 +++++++++---------- src/chsys.c | 2 ++ src/include/sys.h | 4 +-- 36 files changed, 210 insertions(+), 109 deletions(-) diff --git a/demos/ARM7-AT91SAM7X-GCC/Makefile b/demos/ARM7-AT91SAM7X-GCC/Makefile index dbdca2c31..7d22aa586 100644 --- a/demos/ARM7-AT91SAM7X-GCC/Makefile +++ b/demos/ARM7-AT91SAM7X-GCC/Makefile @@ -83,7 +83,7 @@ ASRC = ../../ports/ARM7-AT91SAM7X/chcore.c \ TSRC = # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-AT91SAM7X/vectors.s # List all user directories here diff --git a/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb b/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb index 3013eeb95..922113f45 100644 --- a/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb +++ b/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb @@ -83,7 +83,7 @@ TSRC = ../../ports/ARM7-AT91SAM7X/chcore.c \ board.c main.c # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-AT91SAM7X/vectors.s # List all user directories here diff --git a/demos/ARM7-AT91SAM7X-GCC/board.c b/demos/ARM7-AT91SAM7X-GCC/board.c index 8a4b7c4ea..2329b0080 100644 --- a/demos/ARM7-AT91SAM7X-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-GCC/board.c @@ -26,31 +26,31 @@ extern void FiqHandler(void); -__attribute__((naked)) -static void SpuriousHandler(void) { +CH_IRQ_HANDLER static void SpuriousHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); AT91C_BASE_AIC->AIC_EOICR = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* * SYS IRQ handling here. */ -__attribute__((naked)) -static void SYSIrqHandler(void) { +CH_IRQ_HANDLER static void SYSIrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); if (AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS) { (void) AT91C_BASE_PITC->PITC_PIVR; + chSysLockI(); chSysTimerHandlerI(); + chSysUnlockI(); } AT91C_BASE_AIC->AIC_EOICR = 0; \ - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/ARM7-AT91SAM7X-GCC/chconf.h b/demos/ARM7-AT91SAM7X-GCC/chconf.h index f8302116d..c1b6d8c5a 100644 --- a/demos/ARM7-AT91SAM7X-GCC/chconf.h +++ b/demos/ARM7-AT91SAM7X-GCC/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile index b7b859220..44bb4469a 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile @@ -95,7 +95,7 @@ ASRC = ../../ports/ARM7-AT91SAM7X/chcore.c \ TSRC = # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-AT91SAM7X/vectors.s # List all user directories here diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb index 2ef54fb5d..f2f9a851c 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb @@ -96,7 +96,7 @@ TSRC = ../../ports/ARM7-AT91SAM7X/chcore.c \ board.c main.c # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-AT91SAM7X/vectors.s # List all user directories here diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c index 0d2fd0996..87bc438ea 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c @@ -27,31 +27,31 @@ extern void FiqHandler(void); -__attribute__((naked)) -static void SpuriousHandler(void) { +CH_IRQ_HANDLER static void SpuriousHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); AT91C_BASE_AIC->AIC_EOICR = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* * SYS IRQ handling here. */ -__attribute__((naked)) -static void SYSIrqHandler(void) { +CH_IRQ_HANDLER static void SYSIrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); if (AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS) { (void) AT91C_BASE_PITC->PITC_PIVR; + chSysLockI(); chSysTimerHandlerI(); + chSysUnlockI(); } AT91C_BASE_AIC->AIC_EOICR = 0; \ - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/chconf.h b/demos/ARM7-AT91SAM7X-WEB-GCC/chconf.h index ed950dd3f..cc2870abd 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/chconf.h +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/ARM7-LPC214x-G++/Makefile b/demos/ARM7-LPC214x-G++/Makefile index 9bd08a8ee..bb2c22929 100644 --- a/demos/ARM7-LPC214x-G++/Makefile +++ b/demos/ARM7-LPC214x-G++/Makefile @@ -93,7 +93,7 @@ TCSRC = TCPPSRC = # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-LPC214x/vectors.s # List all user directories here diff --git a/demos/ARM7-LPC214x-G++/Makefile.thumb b/demos/ARM7-LPC214x-G++/Makefile.thumb index 177e7cda0..8d3ec2c0c 100644 --- a/demos/ARM7-LPC214x-G++/Makefile.thumb +++ b/demos/ARM7-LPC214x-G++/Makefile.thumb @@ -93,7 +93,7 @@ TCSRC = ../../ports/ARM7-LPC214x/chcore.c \ TCPPSRC = ../../src/lib/ch.cpp main.cpp # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-LPC214x/vectors.s # List all user directories here diff --git a/demos/ARM7-LPC214x-G++/board.c b/demos/ARM7-LPC214x-G++/board.c index 8b17399e0..fef4deb36 100644 --- a/demos/ARM7-LPC214x-G++/board.c +++ b/demos/ARM7-LPC214x-G++/board.c @@ -31,30 +31,28 @@ /* * Non-vectored IRQs handling here. */ -__attribute__((naked)) -static void IrqHandler(void) { +CH_IRQ_HANDLER static void IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); /* nothing */ VICVectAddr = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* * Timer 0 IRQ handling here. */ -__attribute__((naked)) -static void T0IrqHandler(void) { +CH_IRQ_HANDLER static void T0IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); T0IR = 1; /* Clear interrupt on match MR0. */ chSysTimerHandlerI(); VICVectAddr = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/ARM7-LPC214x-G++/chconf.h b/demos/ARM7-LPC214x-G++/chconf.h index 2d0a1513f..73323e4cf 100644 --- a/demos/ARM7-LPC214x-G++/chconf.h +++ b/demos/ARM7-LPC214x-G++/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/ARM7-LPC214x-GCC-minimal/Makefile b/demos/ARM7-LPC214x-GCC-minimal/Makefile index 6450cad6b..a3ab18333 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/Makefile +++ b/demos/ARM7-LPC214x-GCC-minimal/Makefile @@ -80,7 +80,7 @@ ASRC = ../../ports/ARM7-LPC214x/chcore.c \ TSRC = # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-LPC214x/vectors.s # List all user directories here diff --git a/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb b/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb index f4fe4c25b..2f4463583 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb +++ b/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb @@ -80,7 +80,7 @@ TSRC = ../../ports/ARM7-LPC214x/chcore.c \ board.c main.c # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-LPC214x/vectors.s # List all user directories here diff --git a/demos/ARM7-LPC214x-GCC-minimal/board.c b/demos/ARM7-LPC214x-GCC-minimal/board.c index 3b3bd848e..e10297562 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/board.c +++ b/demos/ARM7-LPC214x-GCC-minimal/board.c @@ -31,30 +31,28 @@ /* * Non-vectored IRQs handling here. */ -__attribute__((naked)) -static void IrqHandler(void) { +CH_IRQ_HANDLER static void IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); /* nothing */ VICVectAddr = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* * Timer 0 IRQ handling here. */ -__attribute__((naked)) -static void T0IrqHandler(void) { +CH_IRQ_HANDLER static void T0IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); T0IR = 1; /* Clear interrupt on match MR0. */ chSysTimerHandlerI(); VICVectAddr = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/ARM7-LPC214x-GCC-minimal/chconf.h b/demos/ARM7-LPC214x-GCC-minimal/chconf.h index 94ff64676..876afc52a 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/chconf.h +++ b/demos/ARM7-LPC214x-GCC-minimal/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ //#define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/ARM7-LPC214x-GCC/Makefile.thumb b/demos/ARM7-LPC214x-GCC/Makefile.thumb index a676a4af1..211107deb 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile.thumb +++ b/demos/ARM7-LPC214x-GCC/Makefile.thumb @@ -84,7 +84,7 @@ TSRC = ../../ports/ARM7-LPC214x/chcore.c \ board.c buzzer.c mmcsd.c main.c # List ASM source files here -ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsys.s \ +ASMSRC = ../../ports/ARM7/crt0.s ../../ports/ARM7/chsysasm.s \ ../../ports/ARM7-LPC214x/vectors.s # List all user directories here diff --git a/demos/ARM7-LPC214x-GCC/board.c b/demos/ARM7-LPC214x-GCC/board.c index 9f453100c..767fb9123 100644 --- a/demos/ARM7-LPC214x-GCC/board.c +++ b/demos/ARM7-LPC214x-GCC/board.c @@ -31,30 +31,28 @@ /* * Non-vectored IRQs handling here. */ -__attribute__((naked)) -static void IrqHandler(void) { +CH_IRQ_HANDLER static void IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); /* nothing */ VICVectAddr = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* * Timer 0 IRQ handling here. */ -__attribute__((naked)) -static void T0IrqHandler(void) { +CH_IRQ_HANDLER static void T0IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); T0IR = 1; /* Clear interrupt on match MR0. */ chSysTimerHandlerI(); VICVectAddr = 0; - chSysIRQExitI(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/ARM7-LPC214x-GCC/chconf.h b/demos/ARM7-LPC214x-GCC/chconf.h index ed950dd3f..cc2870abd 100644 --- a/demos/ARM7-LPC214x-GCC/chconf.h +++ b/demos/ARM7-LPC214x-GCC/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/AVR-AT90CANx-GCC/board.c b/demos/AVR-AT90CANx-GCC/board.c index bd052b9c9..cf97132cf 100644 --- a/demos/AVR-AT90CANx-GCC/board.c +++ b/demos/AVR-AT90CANx-GCC/board.c @@ -22,15 +22,15 @@ #include "board.h" #include "avr_serial.h" -SYS_IRQ_HANDLER(TIMER0_COMP_vect) { +CH_IRQ_HANDLER(TIMER0_COMP_vect) { - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); chSysTimerHandlerI(); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/AVR-ATmega128-GCC/board.c b/demos/AVR-ATmega128-GCC/board.c index 96c810b17..0e40c20f4 100644 --- a/demos/AVR-ATmega128-GCC/board.c +++ b/demos/AVR-ATmega128-GCC/board.c @@ -22,15 +22,15 @@ #include "board.h" #include "avr_serial.h" -SYS_IRQ_HANDLER(TIMER0_COMP_vect) { +CH_IRQ_HANDLER(TIMER0_COMP_vect) { - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); chSysTimerHandlerI(); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } /* diff --git a/demos/AVR-ATmega128-GCC/chconf.h b/demos/AVR-ATmega128-GCC/chconf.h index ea028aed6..4e9abec89 100644 --- a/demos/AVR-ATmega128-GCC/chconf.h +++ b/demos/AVR-ATmega128-GCC/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/MSP430-MSP430x1611-GCC/board.c b/demos/MSP430-MSP430x1611-GCC/board.c index f5e5e4012..51a50afb0 100644 --- a/demos/MSP430-MSP430x1611-GCC/board.c +++ b/demos/MSP430-MSP430x1611-GCC/board.c @@ -85,13 +85,13 @@ void hwinit(void) { InitSerial(); } -SYS_IRQ_HANDLER(TIMERA0_VECTOR) tmr0irq(void) { +CH_IRQ_HANDLER(TIMERA0_VECTOR) tmr0irq(void) { - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); chSysTimerHandlerI(); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } diff --git a/demos/MSP430-MSP430x1611-GCC/chconf.h b/demos/MSP430-MSP430x1611-GCC/chconf.h index bf7a9afad..10be65000 100644 --- a/demos/MSP430-MSP430x1611-GCC/chconf.h +++ b/demos/MSP430-MSP430x1611-GCC/chconf.h @@ -35,6 +35,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/demos/Win32-MinGW/chconf.h b/demos/Win32-MinGW/chconf.h index c00b4873f..07d741e99 100644 --- a/demos/Win32-MinGW/chconf.h +++ b/demos/Win32-MinGW/chconf.h @@ -30,6 +30,15 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED +/** Configuration option: If enabled then the used of nested @p chSysLock() / + * @p chSysUnlock() operations is allowed.
+ * For performance and code size reasons the recommended setting is leave + * this option disabled.
+ * You can use this option if you need to merge ChibiOS/RT with external + * libraries that require nested lock/unlock operations. + */ +//#define CH_USE_NESTED_LOCKS + /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority. */ #define CH_USE_ROUNDROBIN diff --git a/ports/ARM7-AT91SAM7X/sam7x_emac.c b/ports/ARM7-AT91SAM7X/sam7x_emac.c index 47de8650e..05701b369 100644 --- a/ports/ARM7-AT91SAM7X/sam7x_emac.c +++ b/ports/ARM7-AT91SAM7X/sam7x_emac.c @@ -126,9 +126,11 @@ static void ServeInterrupt(void) { CH_IRQ_HANDLER void EMACIrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); + ServeInterrupt(); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } /* diff --git a/ports/ARM7-AT91SAM7X/sam7x_serial.c b/ports/ARM7-AT91SAM7X/sam7x_serial.c index 58a275439..023b98527 100644 --- a/ports/ARM7-AT91SAM7X/sam7x_serial.c +++ b/ports/ARM7-AT91SAM7X/sam7x_serial.c @@ -76,16 +76,20 @@ static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) { CH_IRQ_HANDLER void USART0IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); + ServeInterrupt(AT91C_BASE_US0, &COM1); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } CH_IRQ_HANDLER void USART1IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); + ServeInterrupt(AT91C_BASE_US1, &COM2); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } /* diff --git a/ports/ARM7-LPC214x/lpc214x_serial.c b/ports/ARM7-LPC214x/lpc214x_serial.c index 38eae3169..ececd30c4 100644 --- a/ports/ARM7-LPC214x/lpc214x_serial.c +++ b/ports/ARM7-LPC214x/lpc214x_serial.c @@ -111,18 +111,22 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) { CH_IRQ_HANDLER void UART0IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); + ServeInterrupt(U0Base, &COM1); VICVectAddr = 0; - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } CH_IRQ_HANDLER void UART1IrqHandler(void) { - chSysIRQEnterI(); + CH_IRQ_PROLOGUE(); + ServeInterrupt(U1Base, &COM2); VICVectAddr = 0; - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } #ifdef FIFO_PRELOAD diff --git a/ports/ARMCM3-STM32F103/stm32_serial.c b/ports/ARMCM3-STM32F103/stm32_serial.c index 015084488..c17d7a56c 100644 --- a/ports/ARMCM3-STM32F103/stm32_serial.c +++ b/ports/ARMCM3-STM32F103/stm32_serial.c @@ -85,11 +85,13 @@ static void ServeInterrupt(USART_TypeDef *u, FullDuplexDriver *com) { /* * USART1 IRQ service routine. */ -SYS_IRQ_HANDLER void VectorD4(void) { +CH_IRQ_HANDLER void VectorD4(void) { + + CH_IRQ_PROLOGUE(); - chSysIRQEnterI(); ServeInterrupt(USART1, &COM1); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } /* @@ -106,11 +108,13 @@ static void OutNotify1(void) { /* * USART2 IRQ service routine. */ -SYS_IRQ_HANDLER void VectorD8(void) { +CH_IRQ_HANDLER void VectorD8(void) { + + CH_IRQ_PROLOGUE(); - chSysIRQEnterI(); ServeInterrupt(USART2, &COM2); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } /* @@ -127,11 +131,13 @@ static void OutNotify2(void) { /* * USART3 IRQ service routine. */ -SYS_IRQ_HANDLER void VectorDC(void) { +CH_IRQ_HANDLER void VectorDC(void) { + + CH_IRQ_PROLOGUE(); - chSysIRQEnterI(); ServeInterrupt(USART3, &COM3); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } /* diff --git a/ports/ARMCM3/chcore.c b/ports/ARMCM3/chcore.c index a6871d701..f3e15238d 100644 --- a/ports/ARMCM3/chcore.c +++ b/ports/ARMCM3/chcore.c @@ -65,13 +65,15 @@ void threadstart(void) { * This interrupt is used as system tick. * @note The timer is initialized in the board setup code. */ -SYS_IRQ_HANDLER void SysTickVector(void) { +CH_IRQ_HANDLER void SysTickVector(void) { + + CH_IRQ_PROLOGUE(); - chSysIRQEnterI(); chSysLockI(); chSysTimerHandlerI(); chSysUnlockI(); - chSysIRQExitI(); + + CH_IRQ_EPILOGUE(); } /** diff --git a/ports/AVR/avr_serial.c b/ports/AVR/avr_serial.c index f60cfb4e6..628067e83 100644 --- a/ports/AVR/avr_serial.c +++ b/ports/AVR/avr_serial.c @@ -40,10 +40,10 @@ FullDuplexDriver SER1; static uint8_t ib1[SERIAL_BUFFERS_SIZE]; static uint8_t ob1[SERIAL_BUFFERS_SIZE]; -SYS_IRQ_HANDLER(USART0_RX_vect) { +CH_IRQ_HANDLER(USART0_RX_vect) { uint8_t sra; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); sra = UCSR0A; if (sra & ((1 << DOR) | (1 << UPE) | (1 << FE))) @@ -52,13 +52,13 @@ SYS_IRQ_HANDLER(USART0_RX_vect) { chFDDIncomingDataI(&SER1, UDR0); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } -SYS_IRQ_HANDLER(USART0_UDRE_vect) { +CH_IRQ_HANDLER(USART0_UDRE_vect) { msg_t b; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); b = chFDDRequestDataI(&SER1); @@ -68,7 +68,7 @@ SYS_IRQ_HANDLER(USART0_UDRE_vect) { else UDR0 = b; - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } /* @@ -99,10 +99,10 @@ FullDuplexDriver SER2; static uint8_t ib2[SERIAL_BUFFERS_SIZE]; static uint8_t ob2[SERIAL_BUFFERS_SIZE]; -SYS_IRQ_HANDLER(USART1_RX_vect) { +CH_IRQ_HANDLER(USART1_RX_vect) { uint8_t sra; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); sra = UCSR1A; if (sra & ((1 << DOR) | (1 << UPE) | (1 << FE))) @@ -111,13 +111,13 @@ SYS_IRQ_HANDLER(USART1_RX_vect) { chFDDIncomingDataI(&SER2, UDR1); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } -SYS_IRQ_HANDLER(USART1_UDRE_vect) { +CH_IRQ_HANDLER(USART1_UDRE_vect) { msg_t b; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); b = chFDDRequestDataI(&SER2); @@ -127,7 +127,7 @@ SYS_IRQ_HANDLER(USART1_UDRE_vect) { else UDR1 = b; - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } /* diff --git a/ports/AVR/chcore.h b/ports/AVR/chcore.h index 6bb420a5d..b967cb9a0 100644 --- a/ports/AVR/chcore.h +++ b/ports/AVR/chcore.h @@ -208,10 +208,18 @@ asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \ */ #define sys_enable_from_isr() -#if ENABLE_WFI_IDLE != 0 +/** + * Disables all the interrupt sources, even those having a priority higher + * to the kernel. + * In this port it is no different than sys_disable() because the simple + * interrupt handling + */ +#define sys_disable_all() sys_disable() + /** * This port function is implemented as inlined code for performance reasons. */ +#if ENABLE_WFI_IDLE != 0 #define sys_wait_for_interrupt() { \ asm volatile ("sleep"); \ } diff --git a/ports/MSP430/chcore.h b/ports/MSP430/chcore.h index 7f27c3f8b..b090cffba 100644 --- a/ports/MSP430/chcore.h +++ b/ports/MSP430/chcore.h @@ -176,10 +176,18 @@ if (chSchRescRequiredI()) \ */ #define sys_enable_from_isr() -#if ENABLE_WFI_IDLE != 0 +/** + * Disables all the interrupt sources, even those having a priority higher + * to the kernel. + * In this port it is no different than sys_disable() because the simple + * interrupt handling + */ +#define sys_disable_all() sys_disable() + /** * This port function is implemented as inlined code for performance reasons. */ +#if ENABLE_WFI_IDLE != 0 #define sys_wait_for_interrupt() { \ asm volatile ("wfi"); \ } diff --git a/ports/MSP430/msp430_serial.c b/ports/MSP430/msp430_serial.c index 27094edeb..58a44a076 100644 --- a/ports/MSP430/msp430_serial.c +++ b/ports/MSP430/msp430_serial.c @@ -44,10 +44,10 @@ FullDuplexDriver COM1; static uint8_t ib1[SERIAL_BUFFERS_SIZE]; static uint8_t ob1[SERIAL_BUFFERS_SIZE]; -SYS_IRQ_HANDLER(USART0TX_VECTOR) u0txirq(void) { +CH_IRQ_HANDLER(USART0TX_VECTOR) u0txirq(void) { msg_t b; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); b = chFDDRequestDataI(&COM1); @@ -57,13 +57,13 @@ SYS_IRQ_HANDLER(USART0TX_VECTOR) u0txirq(void) { else U0TXBUF = b; - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } -SYS_IRQ_HANDLER(USART0RX_VECTOR) u0rxirq(void) { +CH_IRQ_HANDLER(USART0RX_VECTOR) u0rxirq(void) { uint8_t urctl; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); if ((urctl = U0RCTL) & RXERR) SetError(urctl, &COM1); @@ -71,7 +71,7 @@ SYS_IRQ_HANDLER(USART0RX_VECTOR) u0rxirq(void) { chFDDIncomingDataI(&COM1, U0RXBUF); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } /* @@ -116,10 +116,10 @@ FullDuplexDriver COM2; static uint8_t ib2[SERIAL_BUFFERS_SIZE]; static uint8_t ob2[SERIAL_BUFFERS_SIZE]; -SYS_IRQ_HANDLER(USART1TX_VECTOR) u1txirq(void) { +CH_IRQ_HANDLER(USART1TX_VECTOR) u1txirq(void) { msg_t b; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); chSysLockI(); b = chFDDRequestDataI(&COM2); @@ -129,13 +129,13 @@ SYS_IRQ_HANDLER(USART1TX_VECTOR) u1txirq(void) { else U1TXBUF = b; - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } -SYS_IRQ_HANDLER(USART1RX_VECTOR) u1rxirq(void) { +CH_IRQ_HANDLER(USART1RX_VECTOR) u1rxirq(void) { uint8_t urctl; - SYS_IRQ_PROLOGUE(); + CH_IRQ_PROLOGUE(); if ((urctl = U1RCTL) & RXERR) SetError(urctl, &COM2); @@ -143,10 +143,9 @@ SYS_IRQ_HANDLER(USART1RX_VECTOR) u1rxirq(void) { chFDDIncomingDataI(&COM2, U1RXBUF); chSysUnlockI(); - SYS_IRQ_EPILOGUE(); + CH_IRQ_EPILOGUE(); } - /* * Invoked by the high driver when one or more bytes are inserted in the * output queue. diff --git a/src/chsys.c b/src/chsys.c index 347b75da3..c1666095e 100644 --- a/src/chsys.c +++ b/src/chsys.c @@ -120,7 +120,9 @@ void chSysLock(void) { */ void chSysUnlock(void) { +#ifdef CH_USE_NESTED_LOCKS chDbgAssert(currp->p_locks > 0, "chinit.c, chSysUnlock()"); +#endif chSysUnlockInline(); } #endif /* !CH_OPTIMIZE_SPEED */ diff --git a/src/include/sys.h b/src/include/sys.h index 25cdbed6a..ae6a8dd2a 100644 --- a/src/include/sys.h +++ b/src/include/sys.h @@ -148,7 +148,7 @@ * @note Usually IRQ handlers functions are also declared naked. * @note On some architectures this macro can be empty. */ -#define chSysIRQEnterI() SYS_IRQ_PROLOGUE() +#define CH_IRQ_PROLOGUE() SYS_IRQ_PROLOGUE() /** * IRQ handler exit code. @@ -156,7 +156,7 @@ * @note This macro usually performs the final reschedulation by using * \p chSchRescRequiredI() and \p chSchDoRescheduleI(). */ -#define chSysIRQExitI() SYS_IRQ_EPILOGUE() +#define CH_IRQ_EPILOGUE() SYS_IRQ_EPILOGUE() /** * Standard modifier for IRQ handler functions.