git: 9ab216e2646a - stable/14 - acpidump: add printfield() helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 12 Apr 2024 01:18:43 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=9ab216e2646a52caeacc56d763877ca866e167c3
commit 9ab216e2646a52caeacc56d763877ca866e167c3
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-04 04:49:21 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-12 01:18:32 +0000
acpidump: add printfield() helper
(cherry picked from commit 969a4b8be5a7d8edf55bd8945a5a071f57386b0e)
---
usr.sbin/acpi/acpidump/acpi.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index 9875a4798085..391310b44c7c 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -156,6 +156,18 @@ printflag(uint64_t var, uint64_t mask, const char *name)
}
}
+static void
+printfield(uint64_t var, int lbit, int hbit, const char *name)
+{
+ uint64_t mask;
+ int len;
+
+ len = hbit - lbit + 1;
+ mask = ((1 << (len + 1)) - 1) << lbit;
+ printf("%c%s=%#jx", pf_sep, name, (uintmax_t)((var & mask) >> lbit));
+ pf_sep = ',';
+}
+
static void
acpi_print_string(char *s, size_t length)
{