up_putc: int up_putc, enter_critical_section may be called

before kernel has been iniitialized,we use spin_lock_irqsave to replace.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2023-12-07 21:31:02 +08:00
committed by Xiang Xiao
parent 90f9ffc2e8
commit 5cee996588
45 changed files with 167 additions and 165 deletions
+4 -4
View File
@@ -1118,11 +1118,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_setusartint(priv, ie); up_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -1133,7 +1133,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -1174,7 +1174,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
up_setusartint(priv, 0); up_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -308,10 +308,10 @@ static void efm32_restoreuartint(struct efm32_leuart_s *priv, uint32_t ien)
* bits in ien. * bits in ien.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
priv->ien = ien; priv->ien = ien;
efm32_setuartint(priv); efm32_setuartint(priv);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -322,14 +322,14 @@ static void efm32_disableuartint(struct efm32_leuart_s *priv, uint32_t *ien)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ien) if (ien)
{ {
*ien = priv->ien; *ien = priv->ien;
} }
efm32_restoreuartint(priv, 0); efm32_restoreuartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -522,10 +522,10 @@ static void efm32_restoreuartint(struct efm32_usart_s *priv, uint32_t ien)
* ien * ien
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
priv->ien = ien; priv->ien = ien;
efm32_setuartint(priv); efm32_setuartint(priv);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -537,14 +537,14 @@ static void efm32_disableuartint(struct efm32_usart_s *priv, uint32_t *ien)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ien) if (ien)
{ {
*ien = priv->ien; *ien = priv->ien;
} }
efm32_restoreuartint(priv, 0); efm32_restoreuartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
+4 -4
View File
@@ -1124,7 +1124,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint32_t *ie)
irqstate_t flags; irqstate_t flags;
uint32_t ctl_ie; uint32_t ctl_ie;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -1158,7 +1158,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint32_t *ie)
ctl_ie = (USART_CFG_CTL_MASK << USART_CFG_SHIFT); ctl_ie = (USART_CFG_CTL_MASK << USART_CFG_SHIFT);
up_setusartint(priv, ctl_ie); up_setusartint(priv, ctl_ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -1169,11 +1169,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint32_t ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_setusartint(priv, ie); up_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -705,10 +705,10 @@ static void kinetis_restoreuartint(struct kinetis_dev_s *priv, uint32_t ie)
* ie * ie
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
priv->ie = ie & LPUART_CTRL_ALL_INTS; priv->ie = ie & LPUART_CTRL_ALL_INTS;
kinetis_setuartint(priv); kinetis_setuartint(priv);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -720,14 +720,14 @@ static void kinetis_disableuartint(struct kinetis_dev_s *priv, uint32_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
*ie = priv->ie; *ie = priv->ie;
} }
kinetis_restoreuartint(priv, 0); kinetis_restoreuartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
+6 -6
View File
@@ -792,12 +792,12 @@ static void up_setuartint(struct up_dev_s *priv)
* ie * ie
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
regval = up_serialin(priv, KINETIS_UART_C2_OFFSET); regval = up_serialin(priv, KINETIS_UART_C2_OFFSET);
regval &= ~UART_C2_ALLINTS; regval &= ~UART_C2_ALLINTS;
regval |= priv->ie; regval |= priv->ie;
up_serialout(priv, KINETIS_UART_C2_OFFSET, regval); up_serialout(priv, KINETIS_UART_C2_OFFSET, regval);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -812,10 +812,10 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t ie)
* ie * ie
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
priv->ie = ie & UART_C2_ALLINTS; priv->ie = ie & UART_C2_ALLINTS;
up_setuartint(priv); up_setuartint(priv);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -827,14 +827,14 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
*ie = priv->ie; *ie = priv->ie;
} }
up_restoreuartint(priv, 0); up_restoreuartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
+6 -6
View File
@@ -328,12 +328,12 @@ static void up_setuartint(struct up_dev_s *priv)
* in ie. * in ie.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
regval = up_serialin(priv, KL_UART_C2_OFFSET); regval = up_serialin(priv, KL_UART_C2_OFFSET);
regval &= ~UART_C2_ALLINTS; regval &= ~UART_C2_ALLINTS;
regval |= priv->ie; regval |= priv->ie;
up_serialout(priv, KL_UART_C2_OFFSET, regval); up_serialout(priv, KL_UART_C2_OFFSET, regval);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -348,10 +348,10 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t ie)
* in ie. * in ie.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
priv->ie = ie & UART_C2_ALLINTS; priv->ie = ie & UART_C2_ALLINTS;
up_setuartint(priv); up_setuartint(priv);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -362,14 +362,14 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
*ie = priv->ie; *ie = priv->ie;
} }
up_restoreuartint(priv, 0); up_restoreuartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+5 -3
View File
@@ -63,6 +63,8 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include <nuttx/arch.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@@ -797,18 +799,18 @@ void arm_lowputc(char ch)
* atomic. * atomic.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if ((getreg32(CONSOLE_BASE + LPC54_USART_FIFOSTAT_OFFSET) & if ((getreg32(CONSOLE_BASE + LPC54_USART_FIFOSTAT_OFFSET) &
USART_FIFOSTAT_TXNOTFULL) != 0) USART_FIFOSTAT_TXNOTFULL) != 0)
{ {
/* Send the character */ /* Send the character */
putreg32((uint32_t)ch, CONSOLE_BASE + LPC54_USART_FIFOWR_OFFSET); putreg32((uint32_t)ch, CONSOLE_BASE + LPC54_USART_FIFOWR_OFFSET);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return; return;
} }
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
} }
+2 -2
View File
@@ -922,14 +922,14 @@ static void lpc54_fifoint_disableall(struct lpc54_dev_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (intset) if (intset)
{ {
*intset = lpc54_serialin(priv, LPC54_USART_FIFOINTENCLR_OFFSET); *intset = lpc54_serialin(priv, LPC54_USART_FIFOINTENCLR_OFFSET);
} }
lpc54_serialout(priv, LPC54_USART_FIFOINTENCLR_OFFSET, USART_FIFOINT_ALL); lpc54_serialout(priv, LPC54_USART_FIFOINTENCLR_OFFSET, USART_FIFOINT_ALL);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -3
View File
@@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/arch.h>
#include "arm_internal.h" #include "arm_internal.h"
#include "sam_gpio.h" #include "sam_gpio.h"
@@ -277,18 +278,18 @@ void arm_lowputc(char ch)
* atomic. * atomic.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) & if ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) &
UART_INT_TXEMPTY) != 0) UART_INT_TXEMPTY) != 0)
{ {
/* Send the character */ /* Send the character */
putreg32((uint32_t)ch, SAM_CONSOLE_BASE + SAM_UART_THR_OFFSET); putreg32((uint32_t)ch, SAM_CONSOLE_BASE + SAM_UART_THR_OFFSET);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return; return;
} }
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
} }
+4 -3
View File
@@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/arch.h>
#include "arm_internal.h" #include "arm_internal.h"
#include "sam_pio.h" #include "sam_pio.h"
@@ -235,18 +236,18 @@ void arm_lowputc(char ch)
* atomic. * atomic.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if ((getreg32(SAM_CONSOLE_VBASE + SAM_UART_SR_OFFSET) & if ((getreg32(SAM_CONSOLE_VBASE + SAM_UART_SR_OFFSET) &
UART_INT_TXEMPTY) != 0) UART_INT_TXEMPTY) != 0)
{ {
/* Send the character */ /* Send the character */
putreg32((uint32_t)ch, SAM_CONSOLE_VBASE + SAM_UART_THR_OFFSET); putreg32((uint32_t)ch, SAM_CONSOLE_VBASE + SAM_UART_THR_OFFSET);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return; return;
} }
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#elif defined(SAMA5_HAVE_FLEXCOM_CONSOLE) #elif defined(SAMA5_HAVE_FLEXCOM_CONSOLE)
+2 -2
View File
@@ -1045,7 +1045,7 @@ int up_putc(int ch)
* interrupts from firing in the serial driver code. * interrupts from firing in the serial driver code.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
/* Check for LF */ /* Check for LF */
@@ -1057,7 +1057,7 @@ int up_putc(int ch)
} }
sam_lowputc(ch); sam_lowputc(ch);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
#endif #endif
return ch; return ch;
} }
+2 -2
View File
@@ -1104,7 +1104,7 @@ int up_putc(int ch)
* interrupts from firing in the serial driver code. * interrupts from firing in the serial driver code.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
/* Check for LF */ /* Check for LF */
@@ -1116,7 +1116,7 @@ int up_putc(int ch)
} }
sam_lowputc(ch); sam_lowputc(ch);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
#endif #endif
return ch; return ch;
} }
+4 -3
View File
@@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "arm_internal.h" #include "arm_internal.h"
@@ -183,18 +184,18 @@ void arm_lowputc(char ch)
* atomic. * atomic.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) & if ((getreg32(SAM_CONSOLE_BASE + SAM_UART_SR_OFFSET) &
UART_INT_TXEMPTY) != 0) UART_INT_TXEMPTY) != 0)
{ {
/* Send the character */ /* Send the character */
putreg32((uint32_t)ch, SAM_CONSOLE_BASE + SAM_UART_THR_OFFSET); putreg32((uint32_t)ch, SAM_CONSOLE_BASE + SAM_UART_THR_OFFSET);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return; return;
} }
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
} }
+4 -4
View File
@@ -1339,11 +1339,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_setusartint(priv, ie); up_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -1354,7 +1354,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -1395,7 +1395,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
up_setusartint(priv, 0); up_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+2 -2
View File
@@ -803,7 +803,7 @@ static void stm32serial_disableusartint(struct stm32_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -847,7 +847,7 @@ static void stm32serial_disableusartint(struct stm32_serial_s *priv,
stm32serial_setusartint(priv, 0); stm32serial_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -531,11 +531,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_setusartint(priv, ie); up_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -546,7 +546,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -590,7 +590,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
up_setusartint(priv, 0); up_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -1405,11 +1405,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_setusartint(priv, ie); up_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -1420,7 +1420,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -1464,7 +1464,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
up_setusartint(priv, 0); up_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -1566,11 +1566,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_setusartint(priv, ie); up_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
@@ -1582,7 +1582,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -1626,7 +1626,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
up_setusartint(priv, 0); up_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -901,11 +901,11 @@ static void stm32l4serial_restoreusartint(struct stm32l4_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
stm32l4serial_setusartint(priv, ie); stm32l4serial_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -917,7 +917,7 @@ static void stm32l4serial_disableusartint(struct stm32l4_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -965,7 +965,7 @@ static void stm32l4serial_disableusartint(struct stm32l4_serial_s *priv,
stm32l4serial_setusartint(priv, 0); stm32l4serial_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -906,11 +906,11 @@ static void stm32l5serial_restoreusartint(struct stm32l5_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
stm32l5serial_setusartint(priv, ie); stm32l5serial_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -922,7 +922,7 @@ static void stm32l5serial_disableusartint(struct stm32l5_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -965,7 +965,7 @@ static void stm32l5serial_disableusartint(struct stm32l5_serial_s *priv,
stm32l5serial_setusartint(priv, 0); stm32l5serial_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+2 -2
View File
@@ -922,7 +922,7 @@ static void stm32serial_disableusartint(struct stm32_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -965,7 +965,7 @@ static void stm32serial_disableusartint(struct stm32_serial_s *priv,
stm32serial_setusartint(priv, 0); stm32serial_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -556,11 +556,11 @@ static void stm32wb_serial_restoreusartint(struct stm32wb_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
stm32wb_serial_setusartint(priv, ie); stm32wb_serial_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -572,7 +572,7 @@ static void stm32wb_serial_disableusartint(struct stm32wb_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -620,7 +620,7 @@ static void stm32wb_serial_disableusartint(struct stm32wb_serial_s *priv,
stm32wb_serial_setusartint(priv, 0); stm32wb_serial_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -661,11 +661,11 @@ static void stm32wl5serial_restoreusartint(struct stm32wl5_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
stm32wl5serial_setusartint(priv, ie); stm32wl5serial_setusartint(priv, ie);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -677,7 +677,7 @@ static void stm32wl5serial_disableusartint(struct stm32wl5_serial_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ie) if (ie)
{ {
@@ -720,7 +720,7 @@ static void stm32wl5serial_disableusartint(struct stm32wl5_serial_s *priv,
stm32wl5serial_setusartint(priv, 0); stm32wl5serial_setusartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -3
View File
@@ -50,6 +50,7 @@
#include <errno.h> #include <errno.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "arm_internal.h" #include "arm_internal.h"
@@ -200,18 +201,18 @@ void arm_lowputc(char ch)
* atomic. * atomic.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if ((getreg32(TMS570_CONSOLE_BASE + TMS570_SCI_FLR_OFFSET) & if ((getreg32(TMS570_CONSOLE_BASE + TMS570_SCI_FLR_OFFSET) &
SCI_FLR_TXRDY) != 0) SCI_FLR_TXRDY) != 0)
{ {
/* Send the character */ /* Send the character */
putreg32((uint32_t)ch, TMS570_CONSOLE_BASE + TMS570_SCI_TD_OFFSET); putreg32((uint32_t)ch, TMS570_CONSOLE_BASE + TMS570_SCI_TD_OFFSET);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return; return;
} }
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
} }
+8 -8
View File
@@ -551,14 +551,14 @@ static inline void xmc4_modifyreg(struct xmc4_dev_s *priv, unsigned
uintptr_t regaddr = priv->uartbase + offset; uintptr_t regaddr = priv->uartbase + offset;
uint32_t regval; uint32_t regval;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
regval = getreg32(regaddr); regval = getreg32(regaddr);
regval &= ~clrbits; regval &= ~clrbits;
regval |= setbits; regval |= setbits;
putreg32(regval, regaddr); putreg32(regval, regaddr);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -573,9 +573,9 @@ static void xmc4_setuartint(struct xmc4_dev_s *priv)
* bits in priv->ccr. * bits in priv->ccr.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
xmc4_modifyreg(priv, XMC4_USIC_CCR_OFFSET, CCR_ALL_EVENTS, priv->ccr); xmc4_modifyreg(priv, XMC4_USIC_CCR_OFFSET, CCR_ALL_EVENTS, priv->ccr);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -590,10 +590,10 @@ static void xmc4_restoreuartint(struct xmc4_dev_s *priv, uint32_t ccr)
* in the ccr argument. * in the ccr argument.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
priv->ccr = ccr; priv->ccr = ccr;
xmc4_setuartint(priv); xmc4_setuartint(priv);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -604,14 +604,14 @@ static void xmc4_disableuartint(struct xmc4_dev_s *priv, uint32_t *ccr)
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (ccr) if (ccr)
{ {
*ccr = priv->ccr; *ccr = priv->ccr;
} }
xmc4_restoreuartint(priv, 0); xmc4_restoreuartint(priv, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+2 -2
View File
@@ -965,7 +965,7 @@ static int a64_uart_init(uint32_t gating, uint32_t rst, pio_pinset_t tx,
irqstate_t flags; irqstate_t flags;
int ret = OK; int ret = OK;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
/* Enable clocking to UART */ /* Enable clocking to UART */
@@ -991,7 +991,7 @@ static int a64_uart_init(uint32_t gating, uint32_t rst, pio_pinset_t tx,
} }
} }
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return ret; return ret;
}; };
+4 -4
View File
@@ -305,10 +305,10 @@ static void up_restoreuartint(struct uart_dev_s *dev, uint8_t im)
* of bits in im. * of bits in im.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_rxint(dev, RX_ENABLED(im)); up_rxint(dev, RX_ENABLED(im));
up_txint(dev, TX_ENABLED(im)); up_txint(dev, TX_ENABLED(im));
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -320,14 +320,14 @@ static void up_disableuartint(struct uart_dev_s *dev, uint8_t *im)
struct up_dev_s *priv = (struct up_dev_s *)dev->priv; struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (im) if (im)
{ {
*im = priv->im; *im = priv->im;
} }
up_restoreuartint(dev, 0); up_restoreuartint(dev, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -622,10 +622,10 @@ static void up_restoreuartint(struct uart_dev_s *dev, uint8_t im)
* in im * in im
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_rxint(dev, RX_ENABLED(im)); up_rxint(dev, RX_ENABLED(im));
up_txint(dev, TX_ENABLED(im)); up_txint(dev, TX_ENABLED(im));
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -637,14 +637,14 @@ static void up_disableuartint(struct uart_dev_s *dev, uint8_t *im)
struct up_dev_s *priv = (struct up_dev_s *)dev->priv; struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (im) if (im)
{ {
*im = priv->im; *im = priv->im;
} }
up_restoreuartint(dev, 0); up_restoreuartint(dev, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+2 -2
View File
@@ -115,7 +115,7 @@ int up_putc(int ch)
* interrupts from firing in the serial driver code. * interrupts from firing in the serial driver code.
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
/* Check for LF */ /* Check for LF */
@@ -128,7 +128,7 @@ int up_putc(int ch)
/* or1k_lowputc(ch); */ /* or1k_lowputc(ch); */
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
#endif #endif
return ch; return ch;
} }
+2 -2
View File
@@ -888,7 +888,7 @@ void riscv_serialinit(void)
int up_putc(int ch) int up_putc(int ch)
{ {
#ifdef HAVE_SERIAL_CONSOLE #ifdef HAVE_SERIAL_CONSOLE
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
/* Check for LF */ /* Check for LF */
@@ -900,7 +900,7 @@ int up_putc(int ch)
} }
riscv_lowputc(ch); riscv_lowputc(ch);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
#endif #endif
return ch; return ch;
} }
+4 -4
View File
@@ -214,12 +214,12 @@ static void up_serialout(struct up_dev_s *priv, int offset, uint32_t value)
static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
priv->im = im; priv->im = im;
up_serialout(priv, UART_IE_OFFSET, im); up_serialout(priv, UART_IE_OFFSET, im);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -228,7 +228,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
/* Return the current interrupt mask value */ /* Return the current interrupt mask value */
@@ -241,7 +241,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
priv->im = 0; priv->im = 0;
up_serialout(priv, UART_IE_OFFSET, 0); up_serialout(priv, UART_IE_OFFSET, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -207,7 +207,7 @@ void esp_lowputc_disable_all_uart_int(const struct esp_uart_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (current_status != NULL) if (current_status != NULL)
{ {
@@ -224,7 +224,7 @@ void esp_lowputc_disable_all_uart_int(const struct esp_uart_s *priv,
uart_hal_clr_intsts_mask(priv->hal, UINT32_MAX); uart_hal_clr_intsts_mask(priv->hal, UINT32_MAX);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -710,7 +710,7 @@ void esp32c3_lowputc_disable_all_uart_int(const struct esp32c3_uart_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (current_status != NULL) if (current_status != NULL)
{ {
@@ -727,7 +727,7 @@ void esp32c3_lowputc_disable_all_uart_int(const struct esp32c3_uart_s *priv,
putreg32(0xffffffff, UART_INT_CLR_REG(priv->id)); putreg32(0xffffffff, UART_INT_CLR_REG(priv->id));
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -214,12 +214,12 @@ static void up_serialout(struct up_dev_s *priv, int offset, uint32_t value)
static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
priv->im = im; priv->im = im;
up_serialout(priv, UART_IE_OFFSET, im); up_serialout(priv, UART_IE_OFFSET, im);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -228,7 +228,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
/* Return the current interrupt mask value */ /* Return the current interrupt mask value */
@@ -241,7 +241,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
priv->im = 0; priv->im = 0;
up_serialout(priv, UART_IE_OFFSET, 0); up_serialout(priv, UART_IE_OFFSET, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -233,12 +233,12 @@ static void up_serialmodfiy(struct up_dev_s *priv, int offset,
static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
priv->im = im; priv->im = im;
up_serialout(priv, UART_IER_OFFSET, im); up_serialout(priv, UART_IER_OFFSET, im);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -247,7 +247,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
/* Return the current interrupt mask value */ /* Return the current interrupt mask value */
@@ -260,7 +260,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
priv->im = 0; priv->im = 0;
up_serialout(priv, UART_IER_OFFSET, 0); up_serialout(priv, UART_IER_OFFSET, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -214,12 +214,12 @@ static void up_serialout(struct up_dev_s *priv, int offset, uint32_t value)
static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
priv->im = im; priv->im = im;
up_serialout(priv, UART_IE_OFFSET, im); up_serialout(priv, UART_IE_OFFSET, im);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -228,7 +228,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
/* Return the current interrupt mask value */ /* Return the current interrupt mask value */
@@ -241,7 +241,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
priv->im = 0; priv->im = 0;
up_serialout(priv, UART_IE_OFFSET, 0); up_serialout(priv, UART_IE_OFFSET, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -237,7 +237,7 @@ static void up_serialout(struct up_dev_s *priv, int offset, uint32_t value)
static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
priv->im = im; priv->im = im;
@@ -245,7 +245,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
LITEX_CONSOLE_BASE + UART_EV_PENDING_OFFSET); LITEX_CONSOLE_BASE + UART_EV_PENDING_OFFSET);
up_serialout(priv, UART_EV_ENABLE_OFFSET, im); up_serialout(priv, UART_EV_ENABLE_OFFSET, im);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -254,7 +254,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im)
static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
/* Return the current interrupt mask value */ /* Return the current interrupt mask value */
@@ -271,7 +271,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *im)
LITEX_CONSOLE_BASE + UART_EV_PENDING_OFFSET); LITEX_CONSOLE_BASE + UART_EV_PENDING_OFFSET);
up_serialout(priv, UART_EV_ENABLE_OFFSET, 0); up_serialout(priv, UART_EV_ENABLE_OFFSET, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -343,11 +343,11 @@ static void up_putreg(struct up_dev_s *priv, int offset, uint32_t value)
static void up_restoreuartint(struct up_dev_s *priv, uint32_t im) static void up_restoreuartint(struct up_dev_s *priv, uint32_t im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
up_putreg(priv, RV32M1_LPUART_CTRL_OFFSET, im); up_putreg(priv, RV32M1_LPUART_CTRL_OFFSET, im);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -356,7 +356,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint32_t im)
static void up_disableuartint(struct up_dev_s *priv, uint32_t *im) static void up_disableuartint(struct up_dev_s *priv, uint32_t *im)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
uint32_t regval = up_getreg(priv, RV32M1_LPUART_CTRL_OFFSET); uint32_t regval = up_getreg(priv, RV32M1_LPUART_CTRL_OFFSET);
/* Return the current interrupt mask value */ /* Return the current interrupt mask value */
@@ -371,7 +371,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint32_t *im)
regval &= ~(LPUART_CTRL_TCIE | LPUART_CTRL_TIE | LPUART_CTRL_RIE); regval &= ~(LPUART_CTRL_TCIE | LPUART_CTRL_TIE | LPUART_CTRL_RIE);
up_putreg(priv, RV32M1_LPUART_CTRL_OFFSET, regval); up_putreg(priv, RV32M1_LPUART_CTRL_OFFSET, regval);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -359,10 +359,10 @@ static void up_restoreuartint(struct uart_dev_s *dev, uint8_t im)
* in im * in im
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_rxint(dev, RX_ENABLED(im)); up_rxint(dev, RX_ENABLED(im));
up_txint(dev, TX_ENABLED(im)); up_txint(dev, TX_ENABLED(im));
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -374,14 +374,14 @@ static void up_disableuartint(struct uart_dev_s *dev, uint8_t *im)
struct up_dev_s *priv = (struct up_dev_s *)dev->priv; struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (im) if (im)
{ {
*im = priv->im; *im = priv->im;
} }
up_restoreuartint(dev, 0); up_restoreuartint(dev, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -361,10 +361,10 @@ static void up_restoreuartint(struct uart_dev_s *dev, uint8_t im)
* im * im
*/ */
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
up_rxint(dev, RX_ENABLED(im)); up_rxint(dev, RX_ENABLED(im));
up_txint(dev, TX_ENABLED(im)); up_txint(dev, TX_ENABLED(im));
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
@@ -376,14 +376,14 @@ static void up_disableuartint(struct uart_dev_s *dev, uint8_t *im)
struct up_dev_s *priv = (struct up_dev_s *)dev->priv; struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (im) if (im)
{ {
*im = priv->im; *im = priv->im;
} }
up_restoreuartint(dev, 0); up_restoreuartint(dev, 0);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+2 -2
View File
@@ -653,7 +653,7 @@ void esp32s2_lowputc_disable_all_uart_int(const struct esp32s2_uart_s *priv,
{ {
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = spin_lock_irqsave(NULL);
if (current_status != NULL) if (current_status != NULL)
{ {
@@ -670,7 +670,7 @@ void esp32s2_lowputc_disable_all_uart_int(const struct esp32s2_uart_s *priv,
putreg32(UINT32_MAX, UART_INT_CLR_REG(priv->id)); putreg32(UINT32_MAX, UART_INT_CLR_REG(priv->id));
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -213,7 +213,7 @@ static uart_dev_t g_uart1port;
static uint8_t z16f_disableuartirq(struct uart_dev_s *dev) static uint8_t z16f_disableuartirq(struct uart_dev_s *dev)
{ {
struct z16f_uart_s *priv = (struct z16f_uart_s *)dev->priv; struct z16f_uart_s *priv = (struct z16f_uart_s *)dev->priv;
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
uint8_t state = priv->rxenabled ? STATE_RXENABLED : uint8_t state = priv->rxenabled ? STATE_RXENABLED :
STATE_DISABLED | STATE_DISABLED |
priv->txenabled ? STATE_TXENABLED : priv->txenabled ? STATE_TXENABLED :
@@ -222,7 +222,7 @@ static uint8_t z16f_disableuartirq(struct uart_dev_s *dev)
z16f_txint(dev, false); z16f_txint(dev, false);
z16f_rxint(dev, false); z16f_rxint(dev, false);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return state; return state;
} }
@@ -232,12 +232,12 @@ static uint8_t z16f_disableuartirq(struct uart_dev_s *dev)
static void z16f_restoreuartirq(struct uart_dev_s *dev, uint8_t state) static void z16f_restoreuartirq(struct uart_dev_s *dev, uint8_t state)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
z16f_txint(dev, (state & STATE_TXENABLED) ? true : false); z16f_txint(dev, (state & STATE_TXENABLED) ? true : false);
z16f_rxint(dev, (state & STATE_RXENABLED) ? true : false); z16f_rxint(dev, (state & STATE_RXENABLED) ? true : false);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -4
View File
@@ -253,7 +253,7 @@ static inline uint8_t z8_getuart(FAR struct z8_uart_s *priv, uint8_t offset)
static uint8_t z8_disableuartirq(FAR struct uart_dev_s *dev) static uint8_t z8_disableuartirq(FAR struct uart_dev_s *dev)
{ {
struct z8_uart_s *priv = (struct z8_uart_s *)dev->priv; struct z8_uart_s *priv = (struct z8_uart_s *)dev->priv;
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
uint8_t state = priv->rxenabled ? uint8_t state = priv->rxenabled ?
STATE_RXENABLED : STATE_DISABLED | \ STATE_RXENABLED : STATE_DISABLED | \
priv->txenabled ? priv->txenabled ?
@@ -262,7 +262,7 @@ static uint8_t z8_disableuartirq(FAR struct uart_dev_s *dev)
z8_txint(dev, false); z8_txint(dev, false);
z8_rxint(dev, false); z8_rxint(dev, false);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
return state; return state;
} }
@@ -272,12 +272,12 @@ static uint8_t z8_disableuartirq(FAR struct uart_dev_s *dev)
static void z8_restoreuartirq(FAR struct uart_dev_s *dev, uint8_t state) static void z8_restoreuartirq(FAR struct uart_dev_s *dev, uint8_t state)
{ {
irqstate_t flags = enter_critical_section(); irqstate_t flags = spin_lock_irqsave(NULL);
z8_txint(dev, (state & STATE_TXENABLED) ? true : false); z8_txint(dev, (state & STATE_TXENABLED) ? true : false);
z8_rxint(dev, (state & STATE_RXENABLED) ? true : false); z8_rxint(dev, (state & STATE_RXENABLED) ? true : false);
leave_critical_section(flags); spin_unlock_irqrestore(NULL, flags);
} }
/**************************************************************************** /****************************************************************************
+4 -8
View File
@@ -1694,8 +1694,12 @@ static bool u16550_txempty(struct uart_dev_s *dev)
#ifdef HAVE_16550_CONSOLE #ifdef HAVE_16550_CONSOLE
static void u16550_putc(FAR struct u16550_s *priv, int ch) static void u16550_putc(FAR struct u16550_s *priv, int ch)
{ {
irqstate_t flags;
flags = spin_lock_irqsave(NULL);
while ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) == 0); while ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) == 0);
u16550_serialout(priv, UART_THR_OFFSET, (uart_datawidth_t)ch); u16550_serialout(priv, UART_THR_OFFSET, (uart_datawidth_t)ch);
spin_unlock_irqrestore(NULL, flags);
} }
#endif #endif
@@ -1768,13 +1772,6 @@ void u16550_serialinit(void)
int up_putc(int ch) int up_putc(int ch)
{ {
FAR struct u16550_s *priv = (FAR struct u16550_s *)CONSOLE_DEV.priv; FAR struct u16550_s *priv = (FAR struct u16550_s *)CONSOLE_DEV.priv;
irqstate_t flags;
/* All interrupts must be disabled to prevent re-entrancy and to prevent
* interrupts from firing in the serial driver code.
*/
flags = enter_critical_section();
/* Check for LF */ /* Check for LF */
@@ -1786,7 +1783,6 @@ int up_putc(int ch)
} }
u16550_putc(priv, ch); u16550_putc(priv, ch);
leave_critical_section(flags);
return ch; return ch;
} }