SMP-related changes.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14125 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-04-02 17:45:42 +00:00
parent 70065704fd
commit 3d9b1e9dd9
1 changed files with 21 additions and 1 deletions

View File

@ -195,10 +195,17 @@
* @details Activating this option will make the Kernel use the PendSV * @details Activating this option will make the Kernel use the PendSV
* handler for preemption instead of the NMI handler. * handler for preemption instead of the NMI handler.
*/ */
#ifndef CORTEX_ALTERNATE_SWITCH #if !defined(CORTEX_ALTERNATE_SWITCH)
#define CORTEX_ALTERNATE_SWITCH FALSE #define CORTEX_ALTERNATE_SWITCH FALSE
#endif #endif
/**
* @brief Spinlock to be used by the port layer.
*/
#if !defined(PORT_SPINLOCK_NUMBER)
#define PORT_SPINLOCK_NUMBER 31
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*===========================================================================*/
@ -211,6 +218,10 @@
#error "ChibiOS Cortex-M0 port not licensed" #error "ChibiOS Cortex-M0 port not licensed"
#endif #endif
#if (PORT_SPINLOCK_NUMBER < 0) || (PORT_SPINLOCK_NUMBER > 31)
#error "invalid PORT_SPINLOCK_NUMBER value"
#endif
/* Handling a GCC problem impacting ARMv6-M.*/ /* Handling a GCC problem impacting ARMv6-M.*/
#if defined(__GNUC__) && !defined(PORT_IGNORE_GCC_VERSION_CHECK) #if defined(__GNUC__) && !defined(PORT_IGNORE_GCC_VERSION_CHECK)
#if ( __GNUC__ > 5 ) && ( __GNUC__ < 10 ) #if ( __GNUC__ > 5 ) && ( __GNUC__ < 10 )
@ -534,6 +545,11 @@ __STATIC_INLINE bool port_is_isr_context(void) {
__STATIC_INLINE void port_lock(void) { __STATIC_INLINE void port_lock(void) {
__disable_irq(); __disable_irq();
#if CH_CFG_SMP_MODE == TRUE
while (SIO->SPINLOCK[PORT_SPINLOCK_NUMBER] == 0U) {
}
__DMB();
#endif
} }
/** /**
@ -542,6 +558,10 @@ __STATIC_INLINE void port_lock(void) {
*/ */
__STATIC_INLINE void port_unlock(void) { __STATIC_INLINE void port_unlock(void) {
#if CH_CFG_SMP_MODE == TRUE
__DMB();
SIO->SPINLOCK[PORT_SPINLOCK_NUMBER] = (uint32_t)SIO;
#endif
__enable_irq(); __enable_irq();
} }