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
This commit is contained in:
Konstantin Belousov 2024-04-04 07:49:21 +03:00
parent 29a6b72775
commit 969a4b8be5

View file

@ -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)
{