Skip to content

Commit 7bdd78f

Browse files
committed
[DNM] hal: renesas: ra: Use irq_lock for FSP_CRITICAL_SECTION
Use `irq_lock` for FSP_CRITICAL_SECTION Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent fbac993 commit 7bdd78f

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

zephyr/ra/portable/bsp_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
/* BSP MCU Specific Includes. */
5353
#include "bsp_register_protection.h"
5454
#include "bsp_irq.h"
55-
#include "bsp_io.h"
55+
#ifdef irq_lock
56+
#include "bsp_io.h"
57+
#endif
5658
#include "bsp_group_irq.h"
5759
#include "bsp_clocks.h"
5860
#include "bsp_module_stop.h"

zephyr/ra/portable/bsp_common.h

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
#include "bsp_cfg.h"
3131

32+
#include <zephyr/irq.h>
33+
34+
3235
/** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
3336
FSP_HEADER
3437

@@ -143,35 +146,9 @@ FSP_HEADER
143146
#define BSP_CFG_IRQ_MASK_LEVEL_FOR_CRITICAL_SECTION (0U)
144147
#endif
145148

146-
/* This macro defines a variable for saving previous mask value */
147-
#ifndef FSP_CRITICAL_SECTION_DEFINE
148-
149-
#define FSP_CRITICAL_SECTION_DEFINE uint32_t old_mask_level = 0U
150-
#endif
151-
152-
/* These macros abstract methods to save and restore the interrupt state for different architectures. */
153-
#if (0 == BSP_CFG_IRQ_MASK_LEVEL_FOR_CRITICAL_SECTION)
154-
#define FSP_CRITICAL_SECTION_GET_CURRENT_STATE __get_PRIMASK
155-
#define FSP_CRITICAL_SECTION_SET_STATE __set_PRIMASK
156-
#define FSP_CRITICAL_SECTION_IRQ_MASK_SET (1U)
157-
#else
158-
#define FSP_CRITICAL_SECTION_GET_CURRENT_STATE __get_BASEPRI
159-
#define FSP_CRITICAL_SECTION_SET_STATE __set_BASEPRI
160-
#define FSP_CRITICAL_SECTION_IRQ_MASK_SET ((uint8_t) (BSP_CFG_IRQ_MASK_LEVEL_FOR_CRITICAL_SECTION << \
161-
(8U - __NVIC_PRIO_BITS)))
162-
#endif
163-
164-
/** This macro temporarily saves the current interrupt state and disables interrupts. */
165-
#ifndef FSP_CRITICAL_SECTION_ENTER
166-
#define FSP_CRITICAL_SECTION_ENTER \
167-
old_mask_level = FSP_CRITICAL_SECTION_GET_CURRENT_STATE(); \
168-
FSP_CRITICAL_SECTION_SET_STATE(FSP_CRITICAL_SECTION_IRQ_MASK_SET)
169-
#endif
170-
171-
/** This macro restores the previously saved interrupt state, reenabling interrupts. */
172-
#ifndef FSP_CRITICAL_SECTION_EXIT
173-
#define FSP_CRITICAL_SECTION_EXIT FSP_CRITICAL_SECTION_SET_STATE(old_mask_level)
174-
#endif
149+
#define FSP_CRITICAL_SECTION_DEFINE unsigned int irq_lock_key
150+
#define FSP_CRITICAL_SECTION_ENTER irq_lock_key = irq_lock();
151+
#define FSP_CRITICAL_SECTION_EXIT irq_unlock(irq_lock_key);
175152

176153
/* Number of Cortex processor exceptions, used as an offset from XPSR value for the IRQn_Type macro. */
177154
#define FSP_PRIV_CORTEX_PROCESSOR_EXCEPTIONS (16U)

0 commit comments

Comments
 (0)