diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-05-17 11:05:16 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-05-17 11:05:16 +0000 |
commit | 8224b1d6a72ae58b50446d65104649670cb0f4ce (patch) | |
tree | b34414900ac4c366504a6a5b9b75679e0e9a56e0 | |
parent | 808f67e34191db07bdd18aeec6dbfd3b75f3d665 (diff) |
Add machdep.compatible.
ok jsg@
-rw-r--r-- | sys/arch/arm64/arm64/machdep.c | 18 | ||||
-rw-r--r-- | sys/arch/arm64/include/cpu.h | 12 |
2 files changed, 24 insertions, 6 deletions
diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index e7da1f2a546..e4817bfc391 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.48 2020/05/16 14:44:44 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.49 2020/05/17 11:05:15 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> * @@ -30,6 +30,7 @@ #include <sys/buf.h> #include <sys/termios.h> #include <sys/sensors.h> +#include <sys/malloc.h> #include <net/if.h> #include <uvm/uvm.h> @@ -291,12 +292,25 @@ int cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen, struct proc *p) { + char *compatible; + int node, len, error; + /* all sysctl names at this level are terminal */ if (namelen != 1) return (ENOTDIR); /* overloaded */ switch (name[0]) { - // none supported currently + case CPU_COMPATIBLE: + node = OF_finddevice("/"); + len = OF_getproplen(node, "compatible"); + if (len <= 0) + return (EOPNOTSUPP); + compatible = malloc(len, M_TEMP, M_WAITOK | M_ZERO); + OF_getprop(node, "compatible", compatible, len); + compatible[len - 1] = 0; + error = sysctl_rdstring(oldp, oldlenp, newp, compatible); + free(compatible, M_TEMP, len); + return error; default: return (EOPNOTSUPP); } diff --git a/sys/arch/arm64/include/cpu.h b/sys/arch/arm64/include/cpu.h index 30133dc32e1..24f4f53f0b1 100644 --- a/sys/arch/arm64/include/cpu.h +++ b/sys/arch/arm64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.14 2019/07/02 20:13:50 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.15 2020/05/17 11:05:15 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com> * @@ -22,11 +22,15 @@ * User-visible definitions */ -/* CTL_MACHDEP definitions. */ -/* None for now */ -#define CPU_MAXID 0 /* number of valid machdep ids */ +/* + * CTL_MACHDEP definitions. + */ +#define CPU_COMPATIBLE 1 /* compatible proprty */ +#define CPU_MAXID 2 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ + { 0, 0 }, \ + { "compatible", CTLTYPE_STRING }, \ } #ifdef _KERNEL |