* @APPLE_LICENSE_HEADER_END@
*/
+#include <string.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
static int
hw_cpu_sysctl SYSCTL_HANDLER_ARGS
{
- i386_cpu_info_t cpu_info;
- void *ptr = (uint8_t *)&cpu_info + (uint32_t)arg1;
+ __unused struct sysctl_oid *unused_oidp = oidp;
+ i386_cpu_info_t *cpu_info = cpuid_info();
+ void *ptr = (uint8_t *)cpu_info + (uint32_t)arg1;
int value;
- cpuid_get_info(&cpu_info);
+ if (arg2 == -1) {
+ ptr = *(char **)ptr;
+ arg2 = 0;
+ }
+
+ if (arg2 == 0 && ((char *)ptr)[0] == '\0') {
+ return ENOENT;
+ }
if (arg2 == sizeof(uint8_t)) {
value = (uint32_t) *(uint8_t *)ptr;
ptr = &value;
arg2 = sizeof(uint32_t);
}
- return SYSCTL_OUT(req, ptr, arg2 ? arg2 : strlen((char *)ptr)+1);
- return 0;
+ return SYSCTL_OUT(req, ptr, arg2 ? (size_t) arg2 : strlen((char *)ptr)+1);
}
static int
hw_cpu_features SYSCTL_HANDLER_ARGS
{
- i386_cpu_info_t cpu_info;
+ __unused struct sysctl_oid *unused_oidp = oidp;
+ __unused void *unused_arg1 = arg1;
+ __unused int unused_arg2 = arg2;
char buf[256];
- vm_size_t size;
- cpuid_get_info(&cpu_info);
buf[0] = '\0';
- cpuid_get_feature_names(cpu_info.cpuid_features, buf, sizeof(buf));
+ cpuid_get_feature_names(cpuid_features(), buf, sizeof(buf));
return SYSCTL_OUT(req, buf, strlen(buf) + 1);
}
(void *)offsetof(i386_cpu_info_t, cpuid_brand_string), 0,
hw_cpu_sysctl, "A", "CPU brand string");
+SYSCTL_PROC(_machdep_cpu, OID_AUTO, model_string, CTLTYPE_STRING | CTLFLAG_RD,
+ (void *)offsetof(i386_cpu_info_t, cpuid_model_string), -1,
+ hw_cpu_sysctl, "A", "CPU model string");
+
SYSCTL_PROC(_machdep_cpu, OID_AUTO, value, CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, cpuid_value), sizeof(uint32_t),
hw_cpu_sysctl, "I", "CPU value");
(void *)offsetof(i386_cpu_info_t, cpuid_brand), sizeof(uint8_t),
hw_cpu_sysctl, "I", "CPU brand");
-#if 0
-SYSCTL_PROC(_machdep_cpu, OID_AUTO, model_string, CTLTYPE_STRING | CTLFLAG_RD,
- (void *)offsetof(i386_cpu_info_t, model_string), 0,
- hw_cpu_sysctl, "A", "CPU model string");
-#endif
-
SYSCTL_PROC(_machdep_cpu, OID_AUTO, features, CTLTYPE_STRING | CTLFLAG_RD,
0, 0,
hw_cpu_features, "A", "CPU feature names");
&sysctl__machdep_cpu,
&sysctl__machdep_cpu_vendor,
&sysctl__machdep_cpu_brand_string,
+ &sysctl__machdep_cpu_model_string,
&sysctl__machdep_cpu_value,
&sysctl__machdep_cpu_family,
&sysctl__machdep_cpu_model,