Module Name: src
Committed By: mlelstv
Date: Tue Dec 25 16:45:03 UTC 2018
Modified Files:
src/sys/arch/x86/include: smbiosvar.h
src/sys/arch/x86/x86: platform.c
Log Message:
Expose more DMI variables via sysctl.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/include/smbiosvar.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/x86/platform.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/include/smbiosvar.h
diff -u src/sys/arch/x86/include/smbiosvar.h:1.4 src/sys/arch/x86/include/smbiosvar.h:1.5
--- src/sys/arch/x86/include/smbiosvar.h:1.4 Sat Mar 11 07:21:10 2017
+++ src/sys/arch/x86/include/smbiosvar.h Tue Dec 25 16:45:02 2018
@@ -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 <[email protected]>
* Copyright (c) 2005 Jordan Hargrave
@@ -185,7 +185,7 @@ struct smbios_board {
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 @@ struct smbios_board {
} __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 {
Index: src/sys/arch/x86/x86/platform.c
diff -u src/sys/arch/x86/x86/platform.c:1.15 src/sys/arch/x86/x86/platform.c:1.16
--- src/sys/arch/x86/x86/platform.c:1.15 Wed Mar 26 08:04:19 2014
+++ src/sys/arch/x86/x86/platform.c Tue Dec 25 16:45:02 2018
@@ -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 <[email protected]>
@@ -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 @@ static int platform_dminode = CTL_EOL;
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 @@ static void platform_print(void);
/* list of private DMI sysctl nodes */
static const char *platform_private_nodes[] = {
+ "chassis-serial",
"board-serial",
"system-serial",
"system-uuid",
@@ -69,6 +72,8 @@ platform_init(void)
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 @@ platform_init(void)
}
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 @@ platform_add(struct smbtable *tbl, const
}
}
+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)