diff options
author | andrew <andrew@FreeBSD.org> | 2015-02-19 12:47:48 +0000 |
---|---|---|
committer | andrew <andrew@FreeBSD.org> | 2015-02-19 12:47:48 +0000 |
commit | abd24e635c165fead8b3094c3636e28a715dce33 (patch) | |
tree | bf1fdd99c1f66e3a87ae4c215a9df09b4aacff99 /sys/sys/cpu.h | |
parent | c560f15fa85ae389cef41cccd341e86818691111 (diff) | |
download | FreeBSD-src-abd24e635c165fead8b3094c3636e28a715dce33.zip FreeBSD-src-abd24e635c165fead8b3094c3636e28a715dce33.tar.gz |
Add support to get the cpu ID from its device driver in a generic way.
This will be needed by arm64 to find the value to pass to the psci (Power
State Coordination Interface) driver, among other things, used to enable
cores.
Differential Revision: https://reviews.freebsd.org/D1824
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/sys/cpu.h')
-rw-r--r-- | sys/sys/cpu.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/sys/cpu.h b/sys/sys/cpu.h index c16091e..f159e37 100644 --- a/sys/sys/cpu.h +++ b/sys/sys/cpu.h @@ -37,6 +37,8 @@ #define CPU_IVAR_PCPU 1 #define CPU_IVAR_NOMINAL_MHZ 2 +#define CPU_IVAR_CPUID_SIZE 3 +#define CPU_IVAR_CPUID 4 static __inline struct pcpu *cpu_get_pcpu(device_t dev) { @@ -54,6 +56,20 @@ static __inline int32_t cpu_get_nominal_mhz(device_t dev) return ((int32_t)v); } +static __inline const uint32_t *cpu_get_cpuid(device_t dev, size_t *count) +{ + uintptr_t v = 0; + if (BUS_READ_IVAR(device_get_parent(dev), dev, + CPU_IVAR_CPUID_SIZE, &v) != 0) + return (NULL); + *count = (size_t)v; + + if (BUS_READ_IVAR(device_get_parent(dev), dev, + CPU_IVAR_CPUID, &v) != 0) + return (NULL); + return ((const uint32_t *)v); +} + /* * CPU frequency control interface. */ |