2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/param.h>
27 #include <sys/kernel.h>
28 #include <sys/sysctl.h>
29 #include <i386/cpuid.h>
32 hw_cpu_sysctl SYSCTL_HANDLER_ARGS
34 i386_cpu_info_t cpu_info
;
35 void *ptr
= (uint8_t *)&cpu_info
+ (uint32_t)arg1
;
38 cpuid_get_info(&cpu_info
);
40 if (arg2
== sizeof(uint8_t)) {
41 value
= (uint32_t) *(uint8_t *)ptr
;
43 arg2
= sizeof(uint32_t);
45 return SYSCTL_OUT(req
, ptr
, arg2
? arg2
: strlen((char *)ptr
)+1);
50 hw_cpu_features SYSCTL_HANDLER_ARGS
52 i386_cpu_info_t cpu_info
;
56 cpuid_get_info(&cpu_info
);
58 cpuid_get_feature_names(cpu_info
.cpuid_features
, buf
, sizeof(buf
));
60 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
63 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
, 0,
66 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
,
67 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
68 hw_cpu_sysctl
, "A", "CPU vendor");
70 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
71 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
72 hw_cpu_sysctl
, "A", "CPU brand string");
74 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, value
, CTLTYPE_INT
| CTLFLAG_RD
,
75 (void *)offsetof(i386_cpu_info_t
, cpuid_value
), sizeof(uint32_t),
76 hw_cpu_sysctl
, "I", "CPU value");
78 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
,
79 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
80 hw_cpu_sysctl
, "I", "CPU family");
82 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
,
83 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
84 hw_cpu_sysctl
, "I", "CPU model");
86 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
,
87 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
88 hw_cpu_sysctl
, "I", "CPU extended model");
90 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
,
91 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
92 hw_cpu_sysctl
, "I", "CPU extended family");
94 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
,
95 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
96 hw_cpu_sysctl
, "I", "CPU stepping");
98 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_INT
| CTLFLAG_RD
,
99 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint32_t),
100 hw_cpu_sysctl
, "I", "CPU features");
102 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
,
103 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
104 hw_cpu_sysctl
, "I", "CPU signature");
106 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
,
107 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
108 hw_cpu_sysctl
, "I", "CPU brand");
111 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
112 (void *)offsetof(i386_cpu_info_t
, model_string
), 0,
113 hw_cpu_sysctl
, "A", "CPU model string");
116 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
,
118 hw_cpu_features
, "A", "CPU feature names");
121 struct sysctl_oid
*machdep_sysctl_list
[] =
123 &sysctl__machdep_cpu
,
124 &sysctl__machdep_cpu_vendor
,
125 &sysctl__machdep_cpu_brand_string
,
126 &sysctl__machdep_cpu_value
,
127 &sysctl__machdep_cpu_family
,
128 &sysctl__machdep_cpu_model
,
129 &sysctl__machdep_cpu_extmodel
,
130 &sysctl__machdep_cpu_extfamily
,
131 &sysctl__machdep_cpu_feature_bits
,
132 &sysctl__machdep_cpu_stepping
,
133 &sysctl__machdep_cpu_signature
,
134 &sysctl__machdep_cpu_brand
,
135 &sysctl__machdep_cpu_features
,
136 (struct sysctl_oid
*) 0