From ff8a93585f60043d2b12c21301531789957fe169 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Sat, 30 Oct 2021 00:48:19 +0800 Subject: [PATCH] freertos: Add portTRY_ENTRY_CRITICAL() and deprecate legacy spinlock fucntions Add TRY_ENTRY_CRITICAL() API to all for timeouts when entering critical sections. The following port API were added: - portTRY_ENTER_CRITICAL() - portTRY_ENTER_CRITICAL_ISR() - portTRY_ENTER_CRITICAL_SAFE() Deprecated legacy spinlock API in favor of spinlock.h. The following API were deprecated: - vPortCPUInitializeMutex() - vPortCPUAcquireMutex() - vPortCPUAcquireMutexTimeout() - vPortCPUReleaseMutex() Other Changes: - Added portMUX_INITIALIZE() to replace vPortCPUInitializeMutex() - The assembly of the critical section functions ends up being about 50 instructions longer, thus the spinlock test pass threshold had to be increased to account for the extra runtime. Closes https://github.com/espressif/esp-idf/issues/5301 --- .../host_test/mocks/include/freertos/portmacro.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/mqtt/host_test/mocks/include/freertos/portmacro.h b/components/mqtt/host_test/mocks/include/freertos/portmacro.h index 1ff7b7c..a68d3c4 100644 --- a/components/mqtt/host_test/mocks/include/freertos/portmacro.h +++ b/components/mqtt/host_test/mocks/include/freertos/portmacro.h @@ -121,10 +121,6 @@ typedef struct { * If mux is locked, count is non-zero & represents the number of recursive locks on the mux. */ uint32_t count; -#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG - const char *lastLockedFn; - int lastLockedLine; -#endif } portMUX_TYPE; #define portMUX_FREE_VAL SPINLOCK_FREE @@ -134,13 +130,8 @@ typedef struct { #define portMUX_TRY_LOCK SPINLOCK_NO_WAIT /* Try to acquire the spinlock a single time only */ // Keep this in sync with the portMUX_TYPE struct definition please. -#ifndef CONFIG_FREERTOS_PORTMUX_DEBUG #define portMUX_INITIALIZER_UNLOCKED \ { .owner = portMUX_FREE_VAL, .count = 0, } -#else -#define portMUX_INITIALIZER_UNLOCKED \ - { .owner = portMUX_FREE_VAL, .count = 0, .lastLockedFn = "(never locked)", .lastLockedLine = -1 } -#endif /* Scheduler utilities. */ extern void vPortYield(void); @@ -162,11 +153,6 @@ extern void vPortYieldFromISR(void); extern int vPortSetInterruptMask(void); extern void vPortClearInterruptMask(int); -void vPortCPUInitializeMutex(portMUX_TYPE *mux); -void vPortCPUAcquireMutex(portMUX_TYPE *mux); -bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles); -void vPortCPUReleaseMutex(portMUX_TYPE *mux); - extern void vPortEnterCritical(void); extern void vPortExitCritical(void);