Mon Nov 14 02:44:59 2011 UTC ()
add a machdep.dmi sysctl tree with the following read-only keys:
 system-vendor, system-product, system-version, system-serial, system-uuid
 bios-vendor, bios-version
 board-vendor, board-product, board-version, board-serial
the *-serial and *-uuid keys are marked with CTLFLAG_PRIVATE

a few of the pmf platform key names changed so update callers to match


(jmcneill)
diff -r1.11 -r1.12 src/sys/arch/x86/x86/platform.c
diff -r1.251 -r1.252 src/sys/dev/acpi/acpi.c
diff -r1.47 -r1.48 src/sys/dev/acpi/acpi_cpu.c
diff -r1.19 -r1.20 src/sys/dev/acpi/acpi_quirks.c

cvs diff -r1.11 -r1.12 src/sys/arch/x86/x86/Attic/platform.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/Attic/platform.c 2011/01/18 07:47:16 1.11
+++ src/sys/arch/x86/x86/Attic/platform.c 2011/11/14 02:44:59 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: platform.c,v 1.11 2011/01/18 07:47:16 jmmv Exp $ */ 1/* $NetBSD: platform.c,v 1.12 2011/11/14 02:44:59 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,68 +19,96 @@ @@ -19,68 +19,96 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include "isa.h" 29#include "isa.h"
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.11 2011/01/18 07:47:16 jmmv Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.12 2011/11/14 02:44:59 jmcneill Exp $");
33 33
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/kernel.h> 36#include <sys/kernel.h>
 37#include <sys/sysctl.h>
 38#include <sys/uuid.h>
37#include <sys/pmf.h> 39#include <sys/pmf.h>
38 40
39#include <dev/isa/isavar.h> 41#include <dev/isa/isavar.h>
40 42
41#include <arch/x86/include/smbiosvar.h> 43#include <arch/x86/include/smbiosvar.h>
42 44
 45static int platform_dminode = CTL_EOL;
 46
43void platform_init(void); /* XXX */ 47void platform_init(void); /* XXX */
44static void platform_add(struct smbtable *, const char *, int); 48static void platform_add(struct smbtable *, const char *, int);
45static void platform_add_date(struct smbtable *, const char *, int); 49static void platform_add_date(struct smbtable *, const char *, int);
 50static void platform_add_uuid(struct smbtable *, const char *,
 51 const uint8_t *);
 52static int platform_dmi_sysctl(SYSCTLFN_PROTO);
46static void platform_print(void); 53static void platform_print(void);
47 54
 55/* list of private DMI sysctl nodes */
 56static const char *platform_private_nodes[] = {
 57 "board-serial",
 58 "system-serial",
 59 "system-uuid",
 60 NULL
 61};
 62
48void 63void
49platform_init(void) 64platform_init(void)
50{ 65{
51 struct smbtable smbios; 66 struct smbtable smbios;
52 struct smbios_sys *psys; 67 struct smbios_sys *psys;
53 struct smbios_struct_bios *pbios; 68 struct smbios_struct_bios *pbios;
 69 struct smbios_board *pboard;
54 struct smbios_slot *pslot; 70 struct smbios_slot *pslot;
55 int nisa, nother; 71 int nisa, nother;
56 72
57 smbios.cookie = 0; 73 smbios.cookie = 0;
58 if (smbios_find_table(SMBIOS_TYPE_SYSTEM, &smbios)) { 74 if (smbios_find_table(SMBIOS_TYPE_SYSTEM, &smbios)) {
59 psys = smbios.tblhdr; 75 psys = smbios.tblhdr;
60 76
61 platform_add(&smbios, "system-manufacturer", psys->vendor); 77 platform_add(&smbios, "system-vendor", psys->vendor);
62 platform_add(&smbios, "system-product-name", psys->product); 78 platform_add(&smbios, "system-product", psys->product);
63 platform_add(&smbios, "system-version", psys->version); 79 platform_add(&smbios, "system-version", psys->version);
64 platform_add(&smbios, "system-serial-number", psys->serial); 80 platform_add(&smbios, "system-serial", psys->serial);
 81 platform_add_uuid(&smbios, "system-uuid", psys->uuid);
65 } 82 }
66 83
67 smbios.cookie = 0; 84 smbios.cookie = 0;
68 if (smbios_find_table(SMBIOS_TYPE_BIOS, &smbios)) { 85 if (smbios_find_table(SMBIOS_TYPE_BIOS, &smbios)) {
69 pbios = smbios.tblhdr; 86 pbios = smbios.tblhdr;
70 87
71 platform_add(&smbios, "firmware-vendor", pbios->vendor); 88 platform_add(&smbios, "bios-vendor", pbios->vendor);
72 platform_add(&smbios, "firmware-version", pbios->version); 89 platform_add(&smbios, "bios-version", pbios->version);
73 platform_add_date(&smbios, "firmware-date", pbios->release); 90 platform_add_date(&smbios, "bios-date", pbios->release);
 91 }
 92
 93 smbios.cookie = 0;
 94 if (smbios_find_table(SMBIOS_TYPE_BASEBOARD, &smbios)) {
 95 pboard = smbios.tblhdr;
 96
 97 platform_add(&smbios, "board-vendor", pboard->vendor);
 98 platform_add(&smbios, "board-product", pboard->product);
 99 platform_add(&smbios, "board-version", pboard->version);
 100 platform_add(&smbios, "board-serial", pboard->serial);
 101 platform_add(&smbios, "board-asset-tag", pboard->asset);
74 } 102 }
75 103
76 smbios.cookie = 0; 104 smbios.cookie = 0;
77 nisa = 0; 105 nisa = 0;
78 nother = 0; 106 nother = 0;
79 while (smbios_find_table(SMBIOS_TYPE_SLOTS, &smbios)) { 107 while (smbios_find_table(SMBIOS_TYPE_SLOTS, &smbios)) {
80 pslot = smbios.tblhdr; 108 pslot = smbios.tblhdr;
81 switch (pslot->type) { 109 switch (pslot->type) {
82 case SMBIOS_SLOT_ISA: 110 case SMBIOS_SLOT_ISA:
83 case SMBIOS_SLOT_EISA: 111 case SMBIOS_SLOT_EISA:
84 nisa++; 112 nisa++;
85 break; 113 break;
86 default: 114 default:
@@ -92,52 +120,93 @@ platform_init(void) @@ -92,52 +120,93 @@ platform_init(void)
92#if NISA > 0 120#if NISA > 0
93 if ((nother | nisa) != 0) { 121 if ((nother | nisa) != 0) {
94 /* Only if there seems to be good expansion slot info. */ 122 /* Only if there seems to be good expansion slot info. */
95 isa_set_slotcount(nisa); 123 isa_set_slotcount(nisa);
96 } 124 }
97#endif 125#endif
98 126
99 platform_print(); 127 platform_print();
100} 128}
101 129
102static void 130static void
103platform_print(void) 131platform_print(void)
104{ 132{
105 const char *manuf, *prod, *ver; 133 const char *vend, *prod, *ver;
106 134
107 manuf = pmf_get_platform("system-manufacturer"); 135 vend = pmf_get_platform("system-vendor");
108 prod = pmf_get_platform("system-product-name"); 136 prod = pmf_get_platform("system-product");
109 ver = pmf_get_platform("system-version"); 137 ver = pmf_get_platform("system-version");
110 138
111 if (manuf == NULL) 139 if (vend == NULL)
112 aprint_verbose("Generic"); 140 aprint_verbose("Generic");
113 else 141 else
114 aprint_verbose("%s", manuf); 142 aprint_verbose("%s", vend);
115 if (prod == NULL) 143 if (prod == NULL)
116 aprint_verbose(" PC"); 144 aprint_verbose(" PC");
117 else 145 else
118 aprint_verbose(" %s", prod); 146 aprint_verbose(" %s", prod);
119 if (ver != NULL) 147 if (ver != NULL)
120 aprint_verbose(" (%s)", ver); 148 aprint_verbose(" (%s)", ver);
121 aprint_verbose("\n"); 149 aprint_verbose("\n");
122} 150}
123 151
 152static bool
 153platform_sysctl_is_private(const char *key)
 154{
 155 unsigned int n;
 156
 157 for (n = 0; platform_private_nodes[n] != NULL; n++) {
 158 if (strcmp(key, platform_private_nodes[n]) == 0) {
 159 return true;
 160 }
 161 }
 162
 163 return false;
 164}
 165
 166static void
 167platform_create_sysctl(const char *key)
 168{
 169 int flags = 0, err;
 170
 171 if (pmf_get_platform(key) == NULL)
 172 return;
 173
 174 /* If the key is marked private, set CTLFLAG_PRIVATE flag */
 175 if (platform_sysctl_is_private(key))
 176 flags |= CTLFLAG_PRIVATE;
 177
 178 err = sysctl_createv(NULL, 0, NULL, NULL,
 179 CTLFLAG_READONLY | flags, CTLTYPE_STRING,
 180 key, NULL, platform_dmi_sysctl, 0, NULL, 0,
 181 CTL_MACHDEP, platform_dminode, CTL_CREATE, CTL_EOL);
 182 if (err != 0)
 183 printf("platform: sysctl_createv "
 184 "(machdep.dmi.%s) failed, err = %d\n",
 185 key, err);
 186}
 187
124static void 188static void
125platform_add(struct smbtable *tbl, const char *key, int idx) 189platform_add(struct smbtable *tbl, const char *key, int idx)
126{ 190{
127 char tmpbuf[128]; /* XXX is this long enough? */ 191 char tmpbuf[128]; /* XXX is this long enough? */
128 192
129 if (smbios_get_string(tbl, idx, tmpbuf, 128) != NULL) 193 if (smbios_get_string(tbl, idx, tmpbuf, 128) != NULL) {
 194 /* add to platform dictionary */
130 pmf_set_platform(key, tmpbuf); 195 pmf_set_platform(key, tmpbuf);
 196
 197 /* create sysctl node */
 198 platform_create_sysctl(key);
 199 }
131} 200}
132 201
133static int 202static int
134platform_scan_date(char *buf, unsigned int *month, unsigned int *day, 203platform_scan_date(char *buf, unsigned int *month, unsigned int *day,
135 unsigned int *year) 204 unsigned int *year)
136{ 205{
137 char *p, *s; 206 char *p, *s;
138 207
139 s = buf; 208 s = buf;
140 p = strchr(s, '/'); 209 p = strchr(s, '/');
141 if (p) *p = '\0'; 210 if (p) *p = '\0';
142 *month = strtoul(s, NULL, 10); 211 *month = strtoul(s, NULL, 10);
143 if (!p) return 1; 212 if (!p) return 1;
@@ -164,13 +233,70 @@ platform_add_date(struct smbtable *tbl,  @@ -164,13 +233,70 @@ platform_add_date(struct smbtable *tbl,
164 if (platform_scan_date(tmpbuf, &month, &day, &year) != 3) 233 if (platform_scan_date(tmpbuf, &month, &day, &year) != 3)
165 return; 234 return;
166 if (month == 0 || month > 12 || day == 0 || day > 31) 235 if (month == 0 || month > 12 || day == 0 || day > 31)
167 return; 236 return;
168 if (year > 9999) 237 if (year > 9999)
169 return; 238 return;
170 if (year < 70) 239 if (year < 70)
171 year += 2000; 240 year += 2000;
172 else if (year < 100) 241 else if (year < 100)
173 year += 1900; 242 year += 1900;
174 sprintf(datestr, "%04u%02u%02u", year, month, day); 243 sprintf(datestr, "%04u%02u%02u", year, month, day);
175 pmf_set_platform(key, datestr); 244 pmf_set_platform(key, datestr);
176} 245}
 246
 247static void
 248platform_add_uuid(struct smbtable *tbl, const char *key, const uint8_t *buf)
 249{
 250 struct uuid uuid;
 251 char tmpbuf[UUID_STR_LEN];
 252
 253 uuid_dec_le(buf, &uuid);
 254 uuid_snprintf(tmpbuf, sizeof(tmpbuf), &uuid);
 255
 256 pmf_set_platform(key, tmpbuf);
 257 platform_create_sysctl(key);
 258}
 259
 260static int
 261platform_dmi_sysctl(SYSCTLFN_ARGS)
 262{
 263 struct sysctlnode node;
 264 const char *v;
 265 int err = 0;
 266
 267 node = *rnode;
 268
 269 v = pmf_get_platform(node.sysctl_name);
 270 if (v == NULL)
 271 return ENOENT;
 272
 273 node.sysctl_data = __UNCONST(v);
 274 err = sysctl_lookup(SYSCTLFN_CALL(&node));
 275 if (err || newp == NULL)
 276 return err;
 277
 278 return 0;
 279}
 280
 281SYSCTL_SETUP(sysctl_dmi_setup, "sysctl machdep.dmi subtree setup")
 282{
 283 const struct sysctlnode *rnode;
 284 int err;
 285
 286 err = sysctl_createv(clog, 0, NULL, &rnode,
 287 CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep",
 288 NULL, NULL, 0, NULL, 0,
 289 CTL_MACHDEP, CTL_EOL);
 290 if (err)
 291 return;
 292
 293 err = sysctl_createv(clog, 0, &rnode, &rnode,
 294 CTLFLAG_PERMANENT, CTLTYPE_NODE, "dmi",
 295 SYSCTL_DESCR("DMI table information"),
 296 NULL, 0, NULL, 0,
 297 CTL_CREATE, CTL_EOL);
 298 if (err)
 299 return;
 300
 301 platform_dminode = rnode->sysctl_num;
 302}

cvs diff -r1.251 -r1.252 src/sys/dev/acpi/acpi.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi.c 2011/10/18 23:47:26 1.251
+++ src/sys/dev/acpi/acpi.c 2011/11/14 02:44:59 1.252
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi.c,v 1.251 2011/10/18 23:47:26 jmcneill Exp $ */ 1/* $NetBSD: acpi.c,v 1.252 2011/11/14 02:44:59 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum of By Noon Software, Inc. 8 * by Charles M. Hannum of By Noon Software, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -90,27 +90,27 @@ @@ -90,27 +90,27 @@
90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
91 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 91 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
92 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 92 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
93 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 93 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
94 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 94 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
95 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 95 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
96 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 96 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
97 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 97 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
98 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 98 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
99 * POSSIBILITY OF SUCH DAMAGE. 99 * POSSIBILITY OF SUCH DAMAGE.
100 */ 100 */
101 101
102#include <sys/cdefs.h> 102#include <sys/cdefs.h>
103__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.251 2011/10/18 23:47:26 jmcneill Exp $"); 103__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.252 2011/11/14 02:44:59 jmcneill Exp $");
104 104
105#include "opt_acpi.h" 105#include "opt_acpi.h"
106#include "opt_pcifixup.h" 106#include "opt_pcifixup.h"
107 107
108#include <sys/param.h> 108#include <sys/param.h>
109#include <sys/device.h> 109#include <sys/device.h>
110#include <sys/kernel.h> 110#include <sys/kernel.h>
111#include <sys/kmem.h> 111#include <sys/kmem.h>
112#include <sys/malloc.h> 112#include <sys/malloc.h>
113#include <sys/module.h> 113#include <sys/module.h>
114#include <sys/mutex.h> 114#include <sys/mutex.h>
115#include <sys/sysctl.h> 115#include <sys/sysctl.h>
116#include <sys/systm.h> 116#include <sys/systm.h>
@@ -296,27 +296,27 @@ acpi_probe(void) @@ -296,27 +296,27 @@ acpi_probe(void)
296 "AslId <%4.4s,%08x>\n", rsdt->OemId, rsdt->OemTableId, 296 "AslId <%4.4s,%08x>\n", rsdt->OemId, rsdt->OemTableId,
297 rsdt->OemRevision, rsdt->AslCompilerId, 297 rsdt->OemRevision, rsdt->AslCompilerId,
298 rsdt->AslCompilerRevision); 298 rsdt->AslCompilerRevision);
299 aprint_normal("ACPI: Not used. Set acpi_force_load to use.\n"); 299 aprint_normal("ACPI: Not used. Set acpi_force_load to use.\n");
300 300
301 acpi_unmap_rsdt(rsdt); 301 acpi_unmap_rsdt(rsdt);
302 goto fail; 302 goto fail;
303 } 303 }
304 304
305 if (acpi_force_load == 0 && (quirks & ACPI_QUIRK_OLDBIOS) != 0) { 305 if (acpi_force_load == 0 && (quirks & ACPI_QUIRK_OLDBIOS) != 0) {
306 306
307 aprint_normal("ACPI: BIOS is too old (%s). " 307 aprint_normal("ACPI: BIOS is too old (%s). "
308 "Set acpi_force_load to use.\n", 308 "Set acpi_force_load to use.\n",
309 pmf_get_platform("firmware-date")); 309 pmf_get_platform("bios-date"));
310 310
311 acpi_unmap_rsdt(rsdt); 311 acpi_unmap_rsdt(rsdt);
312 goto fail; 312 goto fail;
313 } 313 }
314 314
315 acpi_unmap_rsdt(rsdt); 315 acpi_unmap_rsdt(rsdt);
316 316
317 rv = AcpiEnableSubsystem(~(ACPI_NO_HARDWARE_INIT|ACPI_NO_ACPI_ENABLE)); 317 rv = AcpiEnableSubsystem(~(ACPI_NO_HARDWARE_INIT|ACPI_NO_ACPI_ENABLE));
318 318
319 if (ACPI_FAILURE(rv)) { 319 if (ACPI_FAILURE(rv)) {
320 aprint_error("%s: failed to enable subsystem\n", __func__); 320 aprint_error("%s: failed to enable subsystem\n", __func__);
321 goto fail; 321 goto fail;
322 } 322 }

cvs diff -r1.47 -r1.48 src/sys/dev/acpi/acpi_cpu.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_cpu.c 2011/10/27 05:25:07 1.47
+++ src/sys/dev/acpi/acpi_cpu.c 2011/11/14 02:44:59 1.48
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_cpu.c,v 1.47 2011/10/27 05:25:07 jruoho Exp $ */ 1/* $NetBSD: acpi_cpu.c,v 1.48 2011/11/14 02:44:59 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi> 4 * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.47 2011/10/27 05:25:07 jruoho Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.48 2011/11/14 02:44:59 jmcneill Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/cpu.h> 33#include <sys/cpu.h>
34#include <sys/evcnt.h> 34#include <sys/evcnt.h>
35#include <sys/kernel.h> 35#include <sys/kernel.h>
36#include <sys/kmem.h> 36#include <sys/kmem.h>
37#include <sys/module.h> 37#include <sys/module.h>
38#include <sys/mutex.h> 38#include <sys/mutex.h>
39#include <sys/sysctl.h> 39#include <sys/sysctl.h>
40#include <sys/cpufreq.h> 40#include <sys/cpufreq.h>
41 41
42#include <dev/acpi/acpireg.h> 42#include <dev/acpi/acpireg.h>
43#include <dev/acpi/acpivar.h> 43#include <dev/acpi/acpivar.h>
@@ -88,28 +88,28 @@ static const struct { @@ -88,28 +88,28 @@ static const struct {
88CFATTACH_DECL_NEW(acpicpu, sizeof(struct acpicpu_softc), 88CFATTACH_DECL_NEW(acpicpu, sizeof(struct acpicpu_softc),
89 acpicpu_match, acpicpu_attach, acpicpu_detach, NULL); 89 acpicpu_match, acpicpu_attach, acpicpu_detach, NULL);
90 90
91static int 91static int
92acpicpu_match(device_t parent, cfdata_t match, void *aux) 92acpicpu_match(device_t parent, cfdata_t match, void *aux)
93{ 93{
94 const char *manu, *prod, *vers; 94 const char *manu, *prod, *vers;
95 struct cpu_info *ci; 95 struct cpu_info *ci;
96 size_t i; 96 size_t i;
97 97
98 if (acpi_softc == NULL) 98 if (acpi_softc == NULL)
99 return 0; 99 return 0;
100 100
101 manu = pmf_get_platform("system-manufacturer"); 101 manu = pmf_get_platform("system-vendor");
102 prod = pmf_get_platform("system-product-name"); 102 prod = pmf_get_platform("system-product");
103 vers = pmf_get_platform("system-version"); 103 vers = pmf_get_platform("system-version");
104 104
105 if (manu != NULL && prod != NULL && vers != NULL) { 105 if (manu != NULL && prod != NULL && vers != NULL) {
106 106
107 for (i = 0; i < __arraycount(acpicpu_quirks); i++) { 107 for (i = 0; i < __arraycount(acpicpu_quirks); i++) {
108 108
109 if (strcasecmp(acpicpu_quirks[i].manu, manu) == 0 && 109 if (strcasecmp(acpicpu_quirks[i].manu, manu) == 0 &&
110 strcasecmp(acpicpu_quirks[i].prod, prod) == 0 && 110 strcasecmp(acpicpu_quirks[i].prod, prod) == 0 &&
111 strcasecmp(acpicpu_quirks[i].vers, vers) == 0) 111 strcasecmp(acpicpu_quirks[i].vers, vers) == 0)
112 return 0; 112 return 0;
113 } 113 }
114 } 114 }
115 115

cvs diff -r1.19 -r1.20 src/sys/dev/acpi/acpi_quirks.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_quirks.c 2011/02/20 06:45:32 1.19
+++ src/sys/dev/acpi/acpi_quirks.c 2011/11/14 02:44:59 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_quirks.c,v 1.19 2011/02/20 06:45:32 jruoho Exp $ */ 1/* $NetBSD: acpi_quirks.c,v 1.20 2011/11/14 02:44:59 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc. 4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -54,27 +54,27 @@ @@ -54,27 +54,27 @@
54 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 54 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 55 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
56 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 56 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
57 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 57 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 * POSSIBILITY OF SUCH DAMAGE. 62 * POSSIBILITY OF SUCH DAMAGE.
63 */ 63 */
64 64
65#include <sys/cdefs.h> 65#include <sys/cdefs.h>
66 66
67__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.19 2011/02/20 06:45:32 jruoho Exp $"); 67__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.20 2011/11/14 02:44:59 jmcneill Exp $");
68 68
69#include "opt_acpi.h" 69#include "opt_acpi.h"
70 70
71#include <sys/param.h> 71#include <sys/param.h>
72 72
73#include <dev/acpi/acpireg.h> 73#include <dev/acpi/acpireg.h>
74#include <dev/acpi/acpivar.h> 74#include <dev/acpi/acpivar.h>
75 75
76#define _COMPONENT ACPI_UTILITIES 76#define _COMPONENT ACPI_UTILITIES
77ACPI_MODULE_NAME ("acpi_quirks") 77ACPI_MODULE_NAME ("acpi_quirks")
78 78
79#define AQ_GT 0 /* > */ 79#define AQ_GT 0 /* > */
80#define AQ_LT 1 /* < */ 80#define AQ_LT 1 /* < */
@@ -119,27 +119,27 @@ acpi_quirks_revcmp(uint32_t tabval, uint @@ -119,27 +119,27 @@ acpi_quirks_revcmp(uint32_t tabval, uint
119 119
120 case AQ_EQ: 120 case AQ_EQ:
121 return (tabval == wanted) ? 0 : 1; 121 return (tabval == wanted) ? 0 : 1;
122 122
123 default: 123 default:
124 return 1; 124 return 1;
125 } 125 }
126} 126}
127 127
128#ifdef ACPI_BLACKLIST_YEAR 128#ifdef ACPI_BLACKLIST_YEAR
129static int 129static int
130acpi_quirks_bios_year(void) 130acpi_quirks_bios_year(void)
131{ 131{
132 const char *datestr = pmf_get_platform("firmware-date"); 132 const char *datestr = pmf_get_platform("bios-date");
133 unsigned long date; 133 unsigned long date;
134 134
135 if (datestr == NULL) 135 if (datestr == NULL)
136 return -1; 136 return -1;
137 137
138 date = strtoul(datestr, NULL, 10); 138 date = strtoul(datestr, NULL, 10);
139 if (date == 0 || date == ULONG_MAX) 139 if (date == 0 || date == ULONG_MAX)
140 return -1; 140 return -1;
141 if (date < 19000000 || date > 99999999) 141 if (date < 19000000 || date > 99999999)
142 return -1; 142 return -1;
143 return date / 10000; 143 return date / 10000;
144} 144}
145#endif 145#endif