summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2019-10-23 09:27:43 +0000
committerpatrick <patrick@openbsd.org>2019-10-23 09:27:43 +0000
commitaaf7ae02776d31464bd24e147b52567af03aea9e (patch)
tree3ed751dfe8f349c57bc8c02aee98483903c5190e
parentUse the existing code in format.c to add foramts for word and line at (diff)
downloadwireguard-openbsd-aaf7ae02776d31464bd24e147b52567af03aea9e.tar.xz
wireguard-openbsd-aaf7ae02776d31464bd24e147b52567af03aea9e.zip
Provide hw.serialno using the root node's serial-number property.
ok kettenis@
-rw-r--r--sys/arch/arm/mainbus/mainbus.c18
-rw-r--r--sys/arch/arm64/dev/mainbus.c18
2 files changed, 26 insertions, 10 deletions
diff --git a/sys/arch/arm/mainbus/mainbus.c b/sys/arch/arm/mainbus/mainbus.c
index 0ea71803e60..aa2e4436e7d 100644
--- a/sys/arch/arm/mainbus/mainbus.c
+++ b/sys/arch/arm/mainbus/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.20 2019/09/21 15:57:03 kettenis Exp $ */
+/* $OpenBSD: mainbus.c,v 1.21 2019/10/23 09:27:43 patrick Exp $ */
/*
* Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
@@ -89,6 +89,7 @@ mainbus_match(struct device *parent, void *cfdata, void *aux)
}
extern char *hw_prod;
+extern char *hw_serial;
extern struct bus_space armv7_bs_tag;
void platform_init_mainbus(struct device *);
@@ -96,7 +97,7 @@ void
mainbus_attach(struct device *parent, struct device *self, void *aux)
{
struct mainbus_softc *sc = (struct mainbus_softc *)self;
- char model[128];
+ char prop[128];
int node, len;
arm_intr_init_fdt();
@@ -107,15 +108,22 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_acells = OF_getpropint(OF_peer(0), "#address-cells", 1);
sc->sc_scells = OF_getpropint(OF_peer(0), "#size-cells", 1);
- len = OF_getprop(sc->sc_node, "model", model, sizeof(model));
+ len = OF_getprop(sc->sc_node, "model", prop, sizeof(prop));
if (len > 0) {
- printf(": %s\n", model);
+ printf(": %s\n", prop);
hw_prod = malloc(len, M_DEVBUF, M_NOWAIT);
if (hw_prod)
- strlcpy(hw_prod, model, len);
+ strlcpy(hw_prod, prop, len);
} else
printf(": unknown model\n");
+ len = OF_getprop(sc->sc_node, "serial-number", prop, sizeof(prop));
+ if (len > 0) {
+ hw_serial = malloc(len, M_DEVBUF, M_NOWAIT);
+ if (hw_serial)
+ strlcpy(hw_serial, prop, len);
+ }
+
/* Attach primary CPU first. */
mainbus_attach_cpus(self, mainbus_match_primary);
diff --git a/sys/arch/arm64/dev/mainbus.c b/sys/arch/arm64/dev/mainbus.c
index 9c23789f739..517a51813f0 100644
--- a/sys/arch/arm64/dev/mainbus.c
+++ b/sys/arch/arm64/dev/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.14 2019/07/02 20:12:11 kettenis Exp $ */
+/* $OpenBSD: mainbus.c,v 1.15 2019/10/23 09:27:43 patrick Exp $ */
/*
* Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
@@ -94,13 +94,14 @@ mainbus_match(struct device *parent, void *cfdata, void *aux)
}
extern char *hw_prod;
+extern char *hw_serial;
void agtimer_init(void);
void
mainbus_attach(struct device *parent, struct device *self, void *aux)
{
struct mainbus_softc *sc = (struct mainbus_softc *)self;
- char model[128];
+ char prop[128];
int node, len;
arm_intr_init_fdt();
@@ -112,15 +113,22 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_acells = OF_getpropint(OF_peer(0), "#address-cells", 1);
sc->sc_scells = OF_getpropint(OF_peer(0), "#size-cells", 1);
- len = OF_getprop(sc->sc_node, "model", model, sizeof(model));
+ len = OF_getprop(sc->sc_node, "model", prop, sizeof(prop));
if (len > 0) {
- printf(": %s\n", model);
+ printf(": %s\n", prop);
hw_prod = malloc(len, M_DEVBUF, M_NOWAIT);
if (hw_prod)
- strlcpy(hw_prod, model, len);
+ strlcpy(hw_prod, prop, len);
} else
printf(": unknown model\n");
+ len = OF_getprop(sc->sc_node, "serial-number", prop, sizeof(prop));
+ if (len > 0) {
+ hw_serial = malloc(len, M_DEVBUF, M_NOWAIT);
+ if (hw_serial)
+ strlcpy(hw_serial, prop, len);
+ }
+
/* Attach primary CPU first. */
mainbus_attach_cpus(self, mainbus_match_primary);