git: 969a4b8be5a7 - main - acpidump: add printfield() helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 05 Apr 2024 15:18:05 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=969a4b8be5a7d8edf55bd8945a5a071f57386b0e commit 969a4b8be5a7d8edf55bd8945a5a071f57386b0e Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-04-04 04:49:21 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-04-05 15:17:55 +0000 acpidump: add printfield() helper Reviewed by: markj Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44634 --- 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 e3190fa98ad4..322fcaed2dc0 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) {