aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ports/ARMCM3/chcore.c12
-rw-r--r--ports/ARMCM3/chcore.h16
-rw-r--r--readme.txt4
3 files changed, 31 insertions, 1 deletions
diff --git a/ports/ARMCM3/chcore.c b/ports/ARMCM3/chcore.c
index b075ec27c..0159ee71f 100644
--- a/ports/ARMCM3/chcore.c
+++ b/ports/ARMCM3/chcore.c
@@ -42,6 +42,18 @@ void port_halt(void) {
}
}
+#if !CH_OPTIMIZE_SPEED
+void _port_lock(void) {
+ register uint32_t tmp asm ("r3") = BASEPRI_KERNEL;
+ asm volatile ("msr BASEPRI, %0" : : "r" (tmp));
+}
+
+void _port_unlock(void) {
+ register uint32_t tmp asm ("r3") = BASEPRI_USER;
+ asm volatile ("msr BASEPRI, %0" : : "r" (tmp));
+}
+#endif
+
/**
* System Timer vector.
* This interrupt is used as system tick.
diff --git a/ports/ARMCM3/chcore.h b/ports/ARMCM3/chcore.h
index 477e2fede..5ef44a09f 100644
--- a/ports/ARMCM3/chcore.h
+++ b/ports/ARMCM3/chcore.h
@@ -221,18 +221,30 @@ struct context {
/**
* Raises the base priority to kernel level.
*/
+#if CH_OPTIMIZE_SPEED
#define port_lock() { \
register uint32_t tmp asm ("r3") = BASEPRI_KERNEL; \
asm volatile ("msr BASEPRI, %0" : : "r" (tmp)); \
}
+#else
+#define port_lock() { \
+ asm volatile ("bl _port_lock" : : : "r3", "lr"); \
+}
+#endif
/**
* Lowers the base priority to user level.
*/
+#if CH_OPTIMIZE_SPEED
#define port_unlock() { \
register uint32_t tmp asm ("r3") = BASEPRI_USER; \
asm volatile ("msr BASEPRI, %0" : : "r" (tmp)); \
}
+#else
+#define port_unlock() { \
+ asm volatile ("bl _port_unlock" : : : "r3", "lr"); \
+}
+#endif
/**
* Same as @p port_lock() in this port.
@@ -303,6 +315,10 @@ struct context {
extern "C" {
#endif
void port_halt(void);
+#if !CH_OPTIMIZE_SPEED
+ void _port_lock(void);
+ void _port_unlock(void);
+#endif
#ifdef __cplusplus
}
#endif
diff --git a/readme.txt b/readme.txt
index 73d28de7e..19db5e968 100644
--- a/readme.txt
+++ b/readme.txt
@@ -87,8 +87,10 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
the macro chSysGetTime() in chTimeNow(), the old names are still recognized
but marked as deprecated (fixes the bug 2678953 but goes a bit further by
introducing a new API category "Time").
-- OPT: Small optimization to the Cortex-M3 port code, improved thread
+- OPT: Small optimization to the Cortex-M3 thread startup code, improved thread
related performance scores and smaller code.
+- OPT: Alternative implementations for port_lock() and port_unlock() when
+ CH_OPTIMIZE_SPEED is FALSE, huge space savings.
- OPT: Improved ready list and priority ordered lists code, saved some tens
of bytes here and there in the kernel.
- Modified the test thread function to return the global test result flag.