2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/sysctl.h>
33 #include <i386/cpuid.h>
36 hw_cpu_sysctl SYSCTL_HANDLER_ARGS
38 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
39 i386_cpu_info_t
*cpu_info
= cpuid_info();
40 void *ptr
= (uint8_t *)cpu_info
+ (uint32_t)arg1
;
48 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
52 if (arg2
== sizeof(uint8_t)) {
53 value
= (uint32_t) *(uint8_t *)ptr
;
55 arg2
= sizeof(uint32_t);
57 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
)+1);
61 hw_cpu_features SYSCTL_HANDLER_ARGS
63 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
64 __unused
void *unused_arg1
= arg1
;
65 __unused
int unused_arg2
= arg2
;
69 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
71 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
74 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
, 0,
77 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
,
78 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
79 hw_cpu_sysctl
, "A", "CPU vendor");
81 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
82 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
83 hw_cpu_sysctl
, "A", "CPU brand string");
85 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
86 (void *)offsetof(i386_cpu_info_t
, cpuid_model_string
), -1,
87 hw_cpu_sysctl
, "A", "CPU model string");
89 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, value
, CTLTYPE_INT
| CTLFLAG_RD
,
90 (void *)offsetof(i386_cpu_info_t
, cpuid_value
), sizeof(uint32_t),
91 hw_cpu_sysctl
, "I", "CPU value");
93 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
,
94 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
95 hw_cpu_sysctl
, "I", "CPU family");
97 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
,
98 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
99 hw_cpu_sysctl
, "I", "CPU model");
101 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
,
102 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
103 hw_cpu_sysctl
, "I", "CPU extended model");
105 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
,
106 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
107 hw_cpu_sysctl
, "I", "CPU extended family");
109 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
,
110 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
111 hw_cpu_sysctl
, "I", "CPU stepping");
113 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_INT
| CTLFLAG_RD
,
114 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint32_t),
115 hw_cpu_sysctl
, "I", "CPU features");
117 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
,
118 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
119 hw_cpu_sysctl
, "I", "CPU signature");
121 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
,
122 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
123 hw_cpu_sysctl
, "I", "CPU brand");
125 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
,
127 hw_cpu_features
, "A", "CPU feature names");
130 struct sysctl_oid
*machdep_sysctl_list
[] =
132 &sysctl__machdep_cpu
,
133 &sysctl__machdep_cpu_vendor
,
134 &sysctl__machdep_cpu_brand_string
,
135 &sysctl__machdep_cpu_model_string
,
136 &sysctl__machdep_cpu_value
,
137 &sysctl__machdep_cpu_family
,
138 &sysctl__machdep_cpu_model
,
139 &sysctl__machdep_cpu_extmodel
,
140 &sysctl__machdep_cpu_extfamily
,
141 &sysctl__machdep_cpu_feature_bits
,
142 &sysctl__machdep_cpu_stepping
,
143 &sysctl__machdep_cpu_signature
,
144 &sysctl__machdep_cpu_brand
,
145 &sysctl__machdep_cpu_features
,
146 (struct sysctl_oid
*) 0