Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/cpu.h
| Show All 36 Lines | |||||
| enum { | enum { | ||||
| CPU_IVAR_PCPU = BUS_IVARS_PRIVATE, | CPU_IVAR_PCPU = BUS_IVARS_PRIVATE, | ||||
| CPU_IVAR_NOMINAL_MHZ, | CPU_IVAR_NOMINAL_MHZ, | ||||
| CPU_IVAR_CPUID_SIZE, | CPU_IVAR_CPUID_SIZE, | ||||
| CPU_IVAR_CPUID | CPU_IVAR_CPUID | ||||
| }; | }; | ||||
| static __inline struct pcpu * | static __inline struct pcpu * | ||||
jhb: This can now use __BUS_ACCESSOR_DEFAULT() to return NULL by default, which will also mean you… | |||||
| cpu_get_pcpu(device_t dev) | cpu_get_pcpu(device_t dev) | ||||
| { | { | ||||
| uintptr_t v = 0; | uintptr_t v = 0; | ||||
| BUS_READ_IVAR(device_get_parent(dev), dev, CPU_IVAR_PCPU, &v); | BUS_READ_IVAR(device_get_parent(dev), dev, CPU_IVAR_PCPU, &v); | ||||
| return ((struct pcpu *)v); | return ((struct pcpu *)v); | ||||
| } | } | ||||
| /* | |||||
| * Assumes the parent bus sets the CPU_IVAR_PCPU instance variable, which most | |||||
| * CPU buses do. A panic will ensure if not the case. Calling devices should | |||||
| * check for that condition (most probably in their attach function). | |||||
| */ | |||||
| static __inline u_int | |||||
| cpu_get_pcpuid(device_t dev) | |||||
| { | |||||
| return (cpu_get_pcpu(dev)->pc_cpuid); | |||||
| } | |||||
| static __inline int32_t | static __inline int32_t | ||||
Not Done Inline ActionsThis can also now use __BUS_ACCESSOR_DEFAULT() with a default value of -1. jhb: This can also now use __BUS_ACCESSOR_DEFAULT() with a default value of -1. | |||||
| cpu_get_nominal_mhz(device_t dev) | cpu_get_nominal_mhz(device_t dev) | ||||
| { | { | ||||
| uintptr_t v = 0; | uintptr_t v = 0; | ||||
| if (BUS_READ_IVAR(device_get_parent(dev), dev, | if (BUS_READ_IVAR(device_get_parent(dev), dev, | ||||
| CPU_IVAR_NOMINAL_MHZ, &v) != 0) | CPU_IVAR_NOMINAL_MHZ, &v) != 0) | ||||
| return (-1); | return (-1); | ||||
| return ((int32_t)v); | return ((int32_t)v); | ||||
| ▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines | |||||
This can now use __BUS_ACCESSOR_DEFAULT() to return NULL by default, which will also mean you can start using cpu_has_pcpu in the pstate drivers to check for the ivar being valid vs manually calling BUS_READ_IVAR. It wouldn't be a functional change, just a cosmetic change that spells things more typically. (Unrelated to this commit, just a nice cleanup you can do as a separate commit)