Skip to content

Commit

Permalink
arch: add up_read_cpuid api
Browse files Browse the repository at this point in the history
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
  • Loading branch information
W-M-R committed Jan 20, 2025
1 parent 118f827 commit 0403699
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/arm/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ typedef struct arch_addrenv_s arch_addrenv_t;
* Public Function Prototypes
****************************************************************************/

uintptr_t up_read_cpuid(void);

#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/src/armv6-m/arm_cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,8 @@ ssize_t up_show_cpuinfo(char *buf, size_t buf_size, off_t file_off)
return -file_off;
}
#endif /* CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_CPUINFO */

uintptr_t up_read_cpuid(void)
{
return *((volatile uint32_t *)ARMV6M_SYSCON2_BASE);
}
7 changes: 7 additions & 0 deletions arch/arm/src/armv7-a/arm_cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,10 @@ ssize_t up_show_cpuinfo(char *buf, size_t buf_size, off_t file_off)
return -file_off;
}
#endif /* CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_CPUINFO */

uintptr_t up_read_cpuid(void)
{
uint32_t cpuid;
asm volatile("MRC p15, 0, %0, c0, c0, 0" : "=r"(cpuid));
return cpuid;
}
5 changes: 5 additions & 0 deletions arch/arm/src/armv7-m/arm_cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,8 @@ ssize_t up_show_cpuinfo(char *buf, size_t buf_size, off_t file_off)
return -file_off;
}
#endif /* CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_CPUINFO */

uintptr_t up_read_cpuid(void)
{
return *((volatile uint32_t *)NVIC_CPUID_BASE);
}
5 changes: 5 additions & 0 deletions arch/arm/src/armv8-m/arm_cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,8 @@ ssize_t up_show_cpuinfo(char *buf, size_t buf_size, off_t file_off)
return -file_off;
}
#endif /* CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_CPUINFO */

uintptr_t up_read_cpuid(void)
{
return *((volatile uint32_t *)NVIC_CPUID_BASE);
}

0 comments on commit 0403699

Please sign in to comment.