Skip to content

Commit

Permalink
arm64: fix compile failed 'tpidr_el1' undeclared
Browse files Browse the repository at this point in the history
time/lib_localtime.c: In function 'tz_lock':
time/lib_localtime.c:396:7: error: 'tpidr_el1' undeclared (first use in this function)
  396 |   if (up_interrupt_context() || (sched_idletask() && OSINIT_IDLELOOP()))
      |       ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: ligd <liguiding1@xiaomi.com>
  • Loading branch information
GUIDINGLI authored and anchao committed Nov 17, 2024
1 parent dfa24a0 commit a88652f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
38 changes: 2 additions & 36 deletions arch/arm64/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <stddef.h>
# include <nuttx/macro.h>
#endif

#include <nuttx/irq.h>

/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
Expand All @@ -53,41 +54,6 @@

#endif /* CONFIG_ARCH_ADDRENV */

/****************************************************************************
* Name:
* read_/write_/zero_/modify_ sysreg
*
* Description:
*
* ARMv8 Architecture Registers access method
* All the macros need a memory clobber
*
****************************************************************************/

#define read_sysreg(reg) \
({ \
uint64_t __val; \
__asm__ volatile ("mrs %0, " STRINGIFY(reg) \
: "=r" (__val) :: "memory"); \
__val; \
})

#define write_sysreg(__val, reg) \
({ \
__asm__ volatile ("msr " STRINGIFY(reg) ", %0" \
: : "r" (__val) : "memory"); \
})

#define zero_sysreg(reg) \
({ \
__asm__ volatile ("msr " STRINGIFY(reg) ", xzr" \
::: "memory"); \
})

#define modify_sysreg(v,m,a) \
write_sysreg((read_sysreg(a) & ~(m)) | \
((uintptr_t)(v) & (m)), a)

/****************************************************************************
* Inline functions
****************************************************************************/
Expand Down
36 changes: 36 additions & 0 deletions arch/arm64/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <arch/syscall.h>
# include <nuttx/macro.h>
#endif

/* Include NuttX-specific IRQ definitions */
Expand Down Expand Up @@ -394,6 +395,41 @@ static inline void up_irq_restore(irqstate_t flags)
# define up_cpu_index() ((int)MPID_TO_CORE(GET_MPIDR()))
#endif /* CONFIG_ARCH_HAVE_MULTICPU */

/****************************************************************************
* Name:
* read_/write_/zero_/modify_ sysreg
*
* Description:
*
* ARMv8 Architecture Registers access method
* All the macros need a memory clobber
*
****************************************************************************/

#define read_sysreg(reg) \
({ \
uint64_t __val; \
__asm__ volatile ("mrs %0, " STRINGIFY(reg) \
: "=r" (__val) :: "memory"); \
__val; \
})

#define write_sysreg(__val, reg) \
({ \
__asm__ volatile ("msr " STRINGIFY(reg) ", %0" \
: : "r" (__val) : "memory"); \
})

#define zero_sysreg(reg) \
({ \
__asm__ volatile ("msr " STRINGIFY(reg) ", xzr" \
::: "memory"); \
})

#define modify_sysreg(v,m,a) \
write_sysreg((read_sysreg(a) & ~(m)) | \
((uintptr_t)(v) & (m)), a)

/****************************************************************************
* Schedule acceleration macros
*
Expand Down

0 comments on commit a88652f

Please sign in to comment.