Skip to content

Commit

Permalink
arch/arm:use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Browse files Browse the repository at this point in the history
Signed-off-by: lipengfei28 <[email protected]>
  • Loading branch information
lipengfei28 committed Jan 14, 2025
1 parent 2760cc3 commit 8647529
Show file tree
Hide file tree
Showing 78 changed files with 460 additions and 533 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/armv6-m/barriers.h
* arch/arm/include/armv6-m/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -18,8 +18,8 @@
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_ARMV6_M_BARRIERS_H
#define __ARCH_ARM_SRC_ARMV6_M_BARRIERS_H
#ifndef __ARCH_ARM_INCLUDE_ARMV6_M_BARRIERS_H
#define __ARCH_ARM_INCLUDE_ARMV6_M_BARRIERS_H

/****************************************************************************
* Included Files
Expand All @@ -35,8 +35,8 @@
#define arm_isb() __asm__ __volatile__ ("isb " : : : "memory")
#define arm_dmb() __asm__ __volatile__ ("dmb " : : : "memory")

#define ARM_DSB() arm_dsb()
#define ARM_ISB() arm_isb()
#define ARM_DMB() arm_dmb()
#define UP_DSB() arm_dsb()
#define UP_ISB() arm_isb()
#define UP_DMB() arm_dmb()

#endif /* __ARCH_ARM_SRC_ARMV6_M_BARRIERS_H */
#endif /* __ARCH_ARM_INCLUDE_ARMV6_M_BARRIERS_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/armv7-a/barriers.h
* arch/arm/include/armv7-a/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -18,8 +18,8 @@
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_ARMV7_A_BARRIERS_H
#define __ARCH_ARM_SRC_ARMV7_A_BARRIERS_H
#ifndef __ARCH_ARM_INCLUDE_ARMV7_A_BARRIERS_H
#define __ARCH_ARM_INCLUDE_ARMV7_A_BARRIERS_H

/****************************************************************************
* Included Files
Expand All @@ -37,10 +37,10 @@
#define arm_nop() __asm__ __volatile__ ("nop\n")
#define arm_sev() __asm__ __volatile__ ("sev\n")

#define ARM_DSB() arm_dsb(15)
#define ARM_DMB() arm_dmb(15)
#define ARM_ISB() arm_isb()
#define ARM_NOP() arm_nop()
#define ARM_SEV() arm_sev()
#define UP_DSB() arm_dsb(15)
#define UP_DMB() arm_dmb(15)
#define UP_ISB() arm_isb()
#define UP_NOP() arm_nop()
#define UP_SEV() arm_sev()

#endif /* __ARCH_ARM_SRC_ARMV7_A_BARRIERS_H */
#endif /* __ARCH_ARM_INCLUDE_ARMV7_A_BARRIERS_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/armv7-m/barriers.h
* arch/arm/include/armv7-m/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -18,8 +18,8 @@
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_ARMV7_M_BARRIERS_H
#define __ARCH_ARM_SRC_ARMV7_M_BARRIERS_H
#ifndef __ARCH_ARM_INCLUDE_ARMV7_M_BARRIERS_H
#define __ARCH_ARM_INCLUDE_ARMV7_M_BARRIERS_H

/****************************************************************************
* Included Files
Expand All @@ -35,8 +35,8 @@
#define arm_isb() __asm__ __volatile__ ("isb " : : : "memory")
#define arm_dmb() __asm__ __volatile__ ("dmb " : : : "memory")

#define ARM_DSB() arm_dsb()
#define ARM_ISB() arm_isb()
#define ARM_DMB() arm_dmb()
#define UP_DSB() arm_dsb()
#define UP_ISB() arm_isb()
#define UP_DMB() arm_dmb()

#endif /* __ARCH_ARM_SRC_ARMV7_M_BARRIERS_H */
#endif /* __ARCH_ARM_INCLUDE_ARMV7_M_BARRIERS_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/armv7-r/barriers.h
* arch/arm/include/armv7-r/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -18,8 +18,8 @@
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_ARMV7_R_BARRIERS_H
#define __ARCH_ARM_SRC_ARMV7_R_BARRIERS_H
#ifndef __ARCH_ARM_INCLUDE_ARMV7_R_BARRIERS_H
#define __ARCH_ARM_INCLUDE_ARMV7_R_BARRIERS_H

/****************************************************************************
* Included Files
Expand All @@ -37,10 +37,10 @@
#define arm_nop() __asm__ __volatile__ ("nop\n")
#define arm_sev() __asm__ __volatile__ ("sev\n")

#define ARM_DSB() arm_dsb(15)
#define ARM_DMB() arm_dmb(15)
#define ARM_ISB() arm_isb()
#define ARM_NOP() arm_nop()
#define ARM_SEV() arm_sev()
#define UP_DSB() arm_dsb(15)
#define UP_DMB() arm_dmb(15)
#define UP_ISB() arm_isb()
#define UP_NOP() arm_nop()
#define UP_SEV() arm_sev()

#endif /* __ARCH_ARM_SRC_ARMV7_R_BARRIERS_H */
#endif /* __ARCH_ARM_INCLUDE_ARMV7_R_BARRIERS_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/armv8-m/barriers.h
* arch/arm/include/armv8-m/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -18,8 +18,8 @@
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_ARMV8_M_BARRIERS_H
#define __ARCH_ARM_SRC_ARMV8_M_BARRIERS_H
#ifndef __ARCH_ARM_INCLUDE_ARMV8_M_BARRIERS_H
#define __ARCH_ARM_INCLUDE_ARMV8_M_BARRIERS_H

/****************************************************************************
* Included Files
Expand All @@ -35,8 +35,8 @@
#define arm_dmb() __asm__ __volatile__ ("dmb " : : : "memory")
#define arm_dsb(n) __asm__ __volatile__ ("dsb " #n : : : "memory")

#define ARM_ISB() arm_isb()
#define ARM_DMB() arm_dmb()
#define ARM_DSB() arm_dsb(15)
#define UP_ISB() arm_isb()
#define UP_DMB() arm_dmb()
#define UP_DSB() arm_dsb(15)

#endif /* __ARCH_ARM_SRC_ARMV8_M_BARRIERS_H */
#endif /* __ARCH_ARM_INCLUDE_ARMV8_M_BARRIERS_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/armv8-r/barriers.h
* arch/arm/include/armv8-r/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -18,8 +18,8 @@
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_ARMV8_R_BARRIERS_H
#define __ARCH_ARM_SRC_ARMV8_R_BARRIERS_H
#ifndef __ARCH_ARM_INCLUDE_ARMV8_R_BARRIERS_H
#define __ARCH_ARM_INCLUDE_ARMV8_R_BARRIERS_H

/****************************************************************************
* Included Files
Expand All @@ -37,10 +37,10 @@
#define arm_nop() __asm__ __volatile__ ("nop\n")
#define arm_sev() __asm__ __volatile__ ("sev\n")

#define ARM_DSB() arm_dsb(15)
#define ARM_DMB() arm_dmb(15)
#define ARM_ISB() arm_isb()
#define ARM_NOP() arm_nop()
#define ARM_SEV() arm_sev()
#define UP_DSB() arm_dsb(15)
#define UP_DMB() arm_dmb(15)
#define UP_ISB() arm_isb()
#define UP_NOP() arm_nop()
#define UP_SEV() arm_sev()

#endif /* __ARCH_ARM_SRC_ARMV8_R_BARRIERS_H */
#endif /* __ARCH_ARM_INCLUDE_ARMV8_R_BARRIERS_H */
52 changes: 52 additions & 0 deletions arch/arm/include/barriers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/****************************************************************************
* arch/arm/include/barriers.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __ARCH_ARM_INCLUDE_BARRIERS_H
#define __ARCH_ARM_INCLUDE_BARRIERS_H

/****************************************************************************
* Included Files
****************************************************************************/

#if defined(CONFIG_ARCH_ARMV7A)
# include <arch/armv7-a/barriers.h>
#elif defined(CONFIG_ARCH_ARMV7R)
# include <arch/armv7-r/barriers.h>
#elif defined(CONFIG_ARCH_ARMV8R)
# include <arch/armv8-r/barriers.h>
#elif defined(CONFIG_ARCH_ARMV7M)
# include <arch/armv7-m/barriers.h>
#elif defined(CONFIG_ARCH_ARMV8M)
# include <arch/armv8-m/barriers.h>
#elif defined(CONFIG_ARCH_ARMV6M)
# include <arch/armv6-m/barriers.h>
#else
# include <arch/arm/barriers.h>
#endif

#define UP_MB() \
do \
{ \
UP_DSB(); \
UP_ISB(); \
} \
while (0)

#endif /* __ARCH_ARM_INCLUDE_BARRIERS_H */
2 changes: 2 additions & 0 deletions arch/arm/include/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
# include <stdint.h>
#endif /* __ASSEMBLY__ */

#include <arch/barriers.h>

/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-a/arm_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <nuttx/cache.h>
#include <nuttx/irq.h>
#include <sys/param.h>
#include <arch/barriers.h>

#include "cp15_cacheops.h"
#include "barriers.h"
#include "l2cc.h"

/****************************************************************************
Expand Down
11 changes: 4 additions & 7 deletions arch/arm/src/armv7-a/arm_l2cc_pl310.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
#include <debug.h>

#include <nuttx/irq.h>
#include <arch/barriers.h>

#include "arm_internal.h"
#include "barriers.h"
#include "l2cc.h"
#include "l2cc_pl310.h"

Expand Down Expand Up @@ -388,8 +388,7 @@ void arm_l2ccinitialize(void)

l2cc_invalidate_all();
putreg32(L2CC_CR_L2CEN, L2CC_CR);
ARM_DSB();
ARM_ISB();
UP_MB();
}

sinfo("(%d ways) * (%d bytes/way) = %d bytes\n",
Expand Down Expand Up @@ -464,8 +463,7 @@ void l2cc_enable(void)

l2cc_invalidate_all();
putreg32(L2CC_CR_L2CEN, L2CC_CR);
ARM_DSB();
ARM_ISB();
UP_MB();
leave_critical_section(flags);
}

Expand Down Expand Up @@ -495,8 +493,7 @@ void l2cc_disable(void)
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */

putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
UP_MB();
leave_critical_section(flags);
}

Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/armv7-a/arm_scu.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

#include <stdint.h>

#include <arch/barriers.h>
#include <arch/irq.h>

#include "arm_internal.h"
#include "cp15_cacheops.h"
#include "barriers.h"
#include "sctlr.h"
#include "scu.h"

Expand Down Expand Up @@ -72,7 +72,7 @@ void arm_enable_smp(int cpu)
*/

cp15_invalidate_dcache_all();
ARM_DSB();
UP_DSB();

/* Invalidate the L2C-310 -- Missing logic. */

Expand All @@ -84,7 +84,7 @@ void arm_enable_smp(int cpu)

/* Initialize done, kick other cpus which waiting on __start */

ARM_SEV();
UP_SEV();
}

/* Actions for other CPUs */
Expand All @@ -96,7 +96,7 @@ void arm_enable_smp(int cpu)
*/

cp15_dcache_op_level(0, CP15_CACHE_INVALIDATE);
ARM_DSB();
UP_DSB();

/* Wait for the SCU to be enabled by the primary processor -- should
* not be necessary.
Expand Down
Loading

0 comments on commit 8647529

Please sign in to comment.