mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
@@ -966,7 +966,7 @@ static int ez80emac_transmit(struct ez80emac_driver_s *priv)
|
||||
|
||||
/* Increment statistics */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
EMAC_STAT(priv, tx_packets);
|
||||
|
||||
/* The current packet to be sent is txnext; Calculate the new txnext and
|
||||
@@ -1037,7 +1037,7 @@ static int ez80emac_transmit(struct ez80emac_driver_s *priv)
|
||||
*/
|
||||
|
||||
outp(EZ80_EMAC_PTMR, EMAC_PTMR);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
nllvdbg("txdesc=%p {%06x, %u, %04x}\n",
|
||||
txdesc, txdesc->np, txdesc->pktsize, txdesc->stat);
|
||||
@@ -1664,10 +1664,10 @@ static void ez80emac_txtimeout(int argc, uint32_t arg, ...)
|
||||
|
||||
/* Then reset the hardware */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
ez80emac_ifdown(&priv->dev);
|
||||
ez80emac_ifup(&priv->dev);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Then poll uIP for new XMIT data */
|
||||
|
||||
@@ -1824,7 +1824,7 @@ static int ez80emac_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
up_disable_irq(EZ80_EMACRX_IRQ);
|
||||
up_disable_irq(EZ80_EMACTX_IRQ);
|
||||
up_disable_irq(EZ80_EMACSYS_IRQ);
|
||||
@@ -1845,7 +1845,7 @@ static int ez80emac_ifdown(struct net_driver_s *dev)
|
||||
outp(EZ80_EMAC_PTMR, 0);
|
||||
|
||||
priv->bifup = false;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1873,7 +1873,7 @@ static int ez80emac_txavail(struct net_driver_s *dev)
|
||||
struct ez80emac_driver_s *priv = (struct ez80emac_driver_s *)dev->d_private;
|
||||
irqstate_t flags;
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Ignore the notification if the interface is not yet up */
|
||||
|
||||
@@ -1887,7 +1887,7 @@ static int ez80emac_txavail(struct net_driver_s *dev)
|
||||
(void)devif_poll(&priv->dev, ez80emac_txpoll);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,6 @@
|
||||
#include "chip/switch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -59,14 +55,6 @@
|
||||
|
||||
volatile chipreg_t *current_regs;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "chip/switch.h"
|
||||
#include "sched/sched.h"
|
||||
@@ -129,7 +129,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Refuse to handle nested signal actions */
|
||||
|
||||
@@ -185,7 +185,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DISABLE_SIGNALS */
|
||||
|
||||
@@ -50,10 +50,6 @@
|
||||
#include "z180_iomap.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -78,10 +74,6 @@ uint8_t current_cbr;
|
||||
|
||||
extern uintptr_t up_vectors[16];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#include <nuttx/mm/gran.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/io.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
@@ -269,7 +269,7 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize,
|
||||
* address of environment might be longer than the life of the task.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
cbr = z180_mmu_alloccbr();
|
||||
if (!cbr)
|
||||
{
|
||||
@@ -302,14 +302,14 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize,
|
||||
cbr->pages = (uint8_t)npages;
|
||||
*addrenv = (group_addrenv_t)cbr;
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
|
||||
errout_with_cbr:
|
||||
z180_mmu_freecbr(cbr);
|
||||
|
||||
errout_with_irq:
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -463,13 +463,13 @@ int up_addrenv_select(FAR const group_addrenv_t *addrenv,
|
||||
|
||||
/* Return the current CBR value from the CBR register */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
*oldenv = (save_addrenv_t)inp(Z180_MMU_CBR);
|
||||
|
||||
/* Write the new CBR value into CBR register */
|
||||
|
||||
outp(Z180_MMU_CBR, cbr->cbr);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/io.h>
|
||||
|
||||
/****************************************************************************
|
||||
@@ -73,10 +73,10 @@ void modifyreg8(uint16_t addr, uint8_t clearbits, uint8_t setbits)
|
||||
irqstate_t flags;
|
||||
uint8_t regval;
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
regval = inp(addr);
|
||||
regval &= ~clearbits;
|
||||
regval |= setbits;
|
||||
outp(regval, addr);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "chip/switch.h"
|
||||
#include "sched/sched.h"
|
||||
@@ -129,7 +129,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Refuse to handle nested signal actions */
|
||||
|
||||
@@ -185,7 +185,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DISABLE_SIGNALS */
|
||||
|
||||
@@ -47,10 +47,6 @@
|
||||
#include "chip/switch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -59,14 +55,6 @@
|
||||
|
||||
struct z8_irqstate_s g_z8irqstate;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "chip/switch.h"
|
||||
#include "sched/sched.h"
|
||||
@@ -129,7 +129,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Refuse to handle nested signal actions */
|
||||
|
||||
@@ -185,7 +185,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DISABLE_SIGNALS */
|
||||
|
||||
@@ -269,14 +269,14 @@ 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)
|
||||
{
|
||||
struct z8_uart_s *priv = (struct z8_uart_s*)dev->priv;
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
uint8_t state = priv->rxenabled ? STATE_RXENABLED : STATE_DISABLED | \
|
||||
priv->txenabled ? STATE_TXENABLED : STATE_DISABLED;
|
||||
|
||||
z8_txint(dev, false);
|
||||
z8_rxint(dev, false);
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -286,12 +286,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)
|
||||
{
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
z8_txint(dev, (state & STATE_TXENABLED) ? true : false);
|
||||
z8_rxint(dev, (state & STATE_RXENABLED) ? true : false);
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -616,7 +616,7 @@ static int z8_receive(FAR struct uart_dev_s *dev, FAR uint32_t *status)
|
||||
static void z8_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||
{
|
||||
struct z8_uart_s *priv = (struct z8_uart_s*)dev->priv;
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
if (enable)
|
||||
{
|
||||
@@ -630,7 +630,7 @@ static void z8_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||
}
|
||||
|
||||
priv->rxenabled = enable;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -672,7 +672,7 @@ static void z8_send(FAR struct uart_dev_s *dev, int ch)
|
||||
static void z8_txint(FAR struct uart_dev_s *dev, bool enable)
|
||||
{
|
||||
struct z8_uart_s *priv = (struct z8_uart_s*)dev->priv;
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
if (enable)
|
||||
{
|
||||
@@ -686,7 +686,7 @@ static void z8_txint(FAR struct uart_dev_s *dev, bool enable)
|
||||
}
|
||||
|
||||
priv->txenabled = enable;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -44,10 +44,6 @@
|
||||
#include "chip/switch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -58,14 +54,6 @@
|
||||
|
||||
volatile chipreg_t *current_regs;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "chip/switch.h"
|
||||
#include "sched/sched.h"
|
||||
@@ -129,7 +129,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Refuse to handle nested signal actions */
|
||||
|
||||
@@ -185,7 +185,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DISABLE_SIGNALS */
|
||||
|
||||
Reference in New Issue
Block a user