Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86 Expose more DMI variables via sysctl.
details: https://anonhg.NetBSD.org/src/rev/037eaa587873
branches: trunk
changeset: 995505:037eaa587873
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Tue Dec 25 16:45:02 2018 +0000
description:
Expose more DMI variables via sysctl.
diffstat:
sys/arch/x86/include/smbiosvar.h | 57 ++++++++++++++++++++++++++++++++++++++-
sys/arch/x86/x86/platform.c | 45 ++++++++++++++++++++++++++++++-
2 files changed, 98 insertions(+), 4 deletions(-)
diffs (172 lines):
diff -r 6734f8e42331 -r 037eaa587873 sys/arch/x86/include/smbiosvar.h
--- a/sys/arch/x86/include/smbiosvar.h Tue Dec 25 11:56:13 2018 +0000
+++ b/sys/arch/x86/include/smbiosvar.h Tue Dec 25 16:45:02 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smbiosvar.h,v 1.4 2017/03/11 07:21:10 nonaka Exp $ */
+/* $NetBSD: smbiosvar.h,v 1.5 2018/12/25 16:45:02 mlelstv Exp $ */
/*
* Copyright (c) 2006 Gordon Willem Klok <gklok%cogeco.ca@localhost>
* Copyright (c) 2005 Jordan Hargrave
@@ -185,7 +185,7 @@
uint8_t product; /* string */
uint8_t version; /* string */
uint8_t serial; /* string */
- uint8_t asset; /* stirng */
+ uint8_t asset; /* string */
uint8_t feature; /* feature flags */
uint8_t location; /* location in chassis */
uint16_t handle; /* chassis handle */
@@ -194,6 +194,59 @@
} __packed;
/*
+ * SMBIOS Structure Type 3 "System Enclosure or Chassis"
+ * DMTF Specification DSP0134 Section 3.1.1 p.g. 37
+ */
+struct smbios_chassis {
+ uint8_t vendor; /* string */
+ uint8_t shape;
+ uint8_t version; /* string */
+ uint8_t serial; /* string */
+ uint8_t asset; /* string */
+ uint8_t bustate;
+ uint8_t psstate;
+ uint8_t thstate;
+ uint8_t security;
+ uint32_t oemdata;
+ uint8_t height;
+ uint8_t powercords;
+ uint8_t noc; /* number of contained objects */
+} __packed;
+
+/*
+ * SMBIOS Structure Type 4 "Processor Information"
+ * DMTF Specification DSP0134 Section 3.1.1 p.g. 42
+ */
+struct smbios_processor {
+ uint8_t socket; /* string */
+ uint8_t type;
+ uint8_t family;
+ uint8_t vendor; /* string */
+ uint64_t cpuid;
+ uint8_t version; /* string */
+ uint8_t voltage;
+ uint16_t clkspeed;
+ uint16_t maxspeed;
+ uint16_t curspeed;
+ uint8_t status;
+ uint8_t upgrade;
+ uint8_t l1cache;
+ uint8_t l2cache;
+ uint8_t l3cache;
+ uint8_t serial; /* string */
+ uint8_t asset; /* string */
+ uint8_t part; /* string */
+ uint8_t cores; /* cores per socket */
+ uint8_t enabled; /* enabled cores per socket */
+ uint8_t threads; /* threads per socket */
+ uint16_t characteristics;
+ uint16_t family2; /* for values >= 255 */
+ uint16_t cores2; /* for values >= 255 */
+ uint16_t enabled2; /* for values >= 255 */
+ uint16_t threads2; /* for values >= 255 */
+} __packed;
+
+/*
* SMBIOS Structure Type 9 "Expansion slot"
*/
struct smbios_slot {
diff -r 6734f8e42331 -r 037eaa587873 sys/arch/x86/x86/platform.c
--- a/sys/arch/x86/x86/platform.c Tue Dec 25 11:56:13 2018 +0000
+++ b/sys/arch/x86/x86/platform.c Tue Dec 25 16:45:02 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: platform.c,v 1.15 2014/03/26 08:04:19 christos Exp $ */
+/* $NetBSD: platform.c,v 1.16 2018/12/25 16:45:02 mlelstv Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "isa.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.15 2014/03/26 08:04:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.16 2018/12/25 16:45:02 mlelstv Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -48,6 +48,8 @@
void platform_init(void); /* XXX */
static void platform_add(struct smbtable *, const char *, int);
+static void platform_add_word(struct smbtable *, const char *, uint16_t,
+ const char *);
static void platform_add_date(struct smbtable *, const char *, int);
static void platform_add_uuid(struct smbtable *, const char *,
const uint8_t *);
@@ -56,6 +58,7 @@
/* list of private DMI sysctl nodes */
static const char *platform_private_nodes[] = {
+ "chassis-serial",
"board-serial",
"system-serial",
"system-uuid",
@@ -69,6 +72,8 @@
struct smbios_sys *psys;
struct smbios_struct_bios *pbios;
struct smbios_board *pboard;
+ struct smbios_chassis *pchassis;
+ struct smbios_processor *pproc;
struct smbios_slot *pslot;
int nisa, nother;
@@ -104,6 +109,27 @@
}
smbios.cookie = 0;
+ if (smbios_find_table(SMBIOS_TYPE_ENCLOSURE, &smbios)) {
+ pchassis = smbios.tblhdr;
+
+ platform_add(&smbios, "chassis-vendor", pchassis->vendor);
+ platform_add(&smbios, "chassis-type", pchassis->shape);
+ platform_add(&smbios, "chassis-version", pchassis->version);
+ platform_add(&smbios, "chassis-serial", pchassis->serial);
+ platform_add(&smbios, "chassis-asset-tag", pchassis->asset);
+ }
+
+ smbios.cookie = 0;
+ if (smbios_find_table(SMBIOS_TYPE_PROCESSOR, &smbios)) {
+ pproc = smbios.tblhdr;
+
+ platform_add(&smbios, "processor-vendor", pproc->vendor);
+ platform_add(&smbios, "processor-version", pproc->version);
+ platform_add_word(&smbios, "processor-frequency",
+ pproc->curspeed, " MHz");
+ }
+
+ smbios.cookie = 0;
nisa = 0;
nother = 0;
while (smbios_find_table(SMBIOS_TYPE_SLOTS, &smbios)) {
@@ -201,6 +227,21 @@
}
}
+static void
+platform_add_word(struct smbtable *tbl, const char *key, uint16_t val,
+ const char *suf)
+{
+ char tmpbuf[128]; /* XXX is this long enough? */
+
+ if (snprintf(tmpbuf, sizeof(tmpbuf), "%u%s", val, suf)) {
+ /* add to platform dictionary */
+ pmf_set_platform(key, tmpbuf);
+
+ /* create sysctl node */
+ platform_create_sysctl(key);
+ }
+}
+
static int
platform_scan_date(char *buf, unsigned int *month, unsigned int *day,
unsigned int *year)
Home |
Main Index |
Thread Index |
Old Index