2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 #include <sys/param.h>
33 #include <sys/kernel.h>
34 #include <sys/sysctl.h>
35 #include <i386/cpuid.h>
38 hw_cpu_sysctl SYSCTL_HANDLER_ARGS
40 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
41 i386_cpu_info_t
*cpu_info
= cpuid_info();
42 void *ptr
= (uint8_t *)cpu_info
+ (uint32_t)arg1
;
50 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
54 if (arg2
== sizeof(uint8_t)) {
55 value
= (uint32_t) *(uint8_t *)ptr
;
57 arg2
= sizeof(uint32_t);
59 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
)+1);
63 hw_cpu_features SYSCTL_HANDLER_ARGS
65 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
66 __unused
void *unused_arg1
= arg1
;
67 __unused
int unused_arg2
= arg2
;
71 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
73 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
76 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
, 0,
79 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
,
80 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
81 hw_cpu_sysctl
, "A", "CPU vendor");
83 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
84 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
85 hw_cpu_sysctl
, "A", "CPU brand string");
87 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
88 (void *)offsetof(i386_cpu_info_t
, cpuid_model_string
), -1,
89 hw_cpu_sysctl
, "A", "CPU model string");
91 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, value
, CTLTYPE_INT
| CTLFLAG_RD
,
92 (void *)offsetof(i386_cpu_info_t
, cpuid_value
), sizeof(uint32_t),
93 hw_cpu_sysctl
, "I", "CPU value");
95 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
,
96 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
97 hw_cpu_sysctl
, "I", "CPU family");
99 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
,
100 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
101 hw_cpu_sysctl
, "I", "CPU model");
103 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
,
104 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
105 hw_cpu_sysctl
, "I", "CPU extended model");
107 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
,
108 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
109 hw_cpu_sysctl
, "I", "CPU extended family");
111 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
,
112 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
113 hw_cpu_sysctl
, "I", "CPU stepping");
115 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_INT
| CTLFLAG_RD
,
116 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint32_t),
117 hw_cpu_sysctl
, "I", "CPU features");
119 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
,
120 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
121 hw_cpu_sysctl
, "I", "CPU signature");
123 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
,
124 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
125 hw_cpu_sysctl
, "I", "CPU brand");
127 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
,
129 hw_cpu_features
, "A", "CPU feature names");
132 struct sysctl_oid
*machdep_sysctl_list
[] =
134 &sysctl__machdep_cpu
,
135 &sysctl__machdep_cpu_vendor
,
136 &sysctl__machdep_cpu_brand_string
,
137 &sysctl__machdep_cpu_model_string
,
138 &sysctl__machdep_cpu_value
,
139 &sysctl__machdep_cpu_family
,
140 &sysctl__machdep_cpu_model
,
141 &sysctl__machdep_cpu_extmodel
,
142 &sysctl__machdep_cpu_extfamily
,
143 &sysctl__machdep_cpu_feature_bits
,
144 &sysctl__machdep_cpu_stepping
,
145 &sysctl__machdep_cpu_signature
,
146 &sysctl__machdep_cpu_brand
,
147 &sysctl__machdep_cpu_features
,
148 (struct sysctl_oid
*) 0