diff options
author | jhb <jhb@FreeBSD.org> | 2014-08-29 21:25:47 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2014-08-29 21:25:47 +0000 |
commit | 9d531dc3c174768633bbea0d1d24a6ca83e01e73 (patch) | |
tree | 802e6a34a15eb10ca05a520350213b5b665d1007 /sbin/sysctl | |
parent | 74edf8c62affe892f21b1d50669b66578f787d8d (diff) | |
download | FreeBSD-src-9d531dc3c174768633bbea0d1d24a6ca83e01e73.zip FreeBSD-src-9d531dc3c174768633bbea0d1d24a6ca83e01e73.tar.gz |
- Add a new structure type for the ACPI 3.0 SMAP entry that includes the
optional attributes field.
- Add a 'machdep.smap' sysctl that exports the SMAP table of the running
system as an array of the ACPI 3.0 structure. (On older systems, the
attributes are given a value of zero.) Note that the sysctl only
exports the SMAP table if it is available via the metadata passed from
the loader to the kernel. If an SMAP is not available, an empty array
is returned.
- Add a format handler for the ACPI 3.0 SMAP structure to the sysctl(8)
binary to format the SMAP structures in a readable format similar to
the format found in boot messages.
MFC after: 2 weeks
Diffstat (limited to 'sbin/sysctl')
-rw-r--r-- | sbin/sysctl/sysctl.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 1359645..578260d 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -48,6 +48,10 @@ static const char rcsid[] = #include <sys/sysctl.h> #include <sys/vmmeter.h> +#if defined(__amd64__) || defined(__i386__) +#include <machine/pc/bios.h> +#endif + #include <ctype.h> #include <err.h> #include <errno.h> @@ -541,6 +545,27 @@ S_vmtotal(int l2, void *p) return (0); } +#if defined(__amd64__) || defined(__i386__) +static int +S_bios_smap_xattr(int l2, void *p) +{ + struct bios_smap_xattr *smap, *end; + + if (l2 % sizeof(*smap) != 0) { + warnx("S_bios_smap_xattr %d is not a multiple of %zu", l2, + sizeof(*smap)); + return (1); + } + + end = (struct bios_smap_xattr *)((char *)p + l2); + for (smap = p; smap < end; smap++) + printf("\nSMAP type=%02x, xattr=%02x, base=%016jx, len=%016jx", + smap->type, smap->xattr, (uintmax_t)smap->base, + (uintmax_t)smap->length); + return (0); +} +#endif + static int set_IK(const char *str, int *val) { @@ -793,6 +818,10 @@ show_var(int *oid, int nlen) func = S_loadavg; else if (strcmp(fmt, "S,vmtotal") == 0) func = S_vmtotal; +#if defined(__amd64__) || defined(__i386__) + else if (strcmp(fmt, "S,bios_smap_xattr") == 0) + func = S_bios_smap_xattr; +#endif else func = NULL; if (func) { |