aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2020-02-19 06:28:55 +0000
committerHiroki Sato <hrs@FreeBSD.org>2020-02-19 06:28:55 +0000
commit294de6bbd6dfa5eeb918bb1175905e5a88302095 (patch)
tree3e9c9f05132c6585d64a3f23cda62e814bbd523c /usr.sbin
parent9fab908a79e98408664cdcfbe2d01a3338a84a56 (diff)
downloadsrc-294de6bbd6dfa5eeb918bb1175905e5a88302095.tar.gz
src-294de6bbd6dfa5eeb918bb1175905e5a88302095.zip
Add _BIX (Battery Information Extended) object support.
ACPI Control Method Batteries have a _BIF and/or _BIX object which provide static properties of the battery. FreeBSD acpi_cmbat module supported _BIF object only, which was deprecated as of ACPI 4.0. _BIX is an extended version of _BIF defined in ACPI 4.0 or later. As of writing, _BIX has two revisions. One is in ACPI 4.0 (rev.0) and another is in ACPI 6.0 (rev.1). It seems that hardware vendors still stick to _BIF only or _BIX rev.0 + _BIF for the maximum compatibility. Microsoft requires _BIX rev.0 for Windows machines, so there are some laptop machines with _BIX rev.0 only. In this case, FreeBSD does not recognize the battery information. After this change, the acpi_cmbat module gets battery information from _BIX or _BIF object and internally uses _BIX rev.1 data structure as the primary information store in the kernel. ACPIIO_BATT_GET_BI[FX] returns an acpi_bi[fx] structure built by using information obtained from a _BIF or a _BIX object found on the system. The revision number field can be used to check which field is available. The acpiconf(8) utility will show additional information if _BIX is available. Although ABIs of ACPIIO_BATT_* were changed, the existing APIs for userland utilities are not changed and the backward-compatible ABIs are provided. This means that older versions of acpiconf(8) can also work with the new kernel. The (union acpi_battery_ioctl_arg) was padded to 256 byte long to avoid another ABI change in the future. A _BIX object with its revision number >1 will be treated as compatible with the rev.1 _BIX format. Reviewed by: takawata MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23728
Notes
Notes: svn path=/head/; revision=358095
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.c61
1 files changed, 44 insertions, 17 deletions
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c
index 4af4c73d4e15..8a31657fb980 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.c
+++ b/usr.sbin/acpi/acpiconf/acpiconf.c
@@ -96,34 +96,61 @@ acpi_battinfo(int num)
/* Print battery design information. */
battio.unit = num;
- if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1)
+ if (ioctl(acpifd, ACPIIO_BATT_GET_BIX, &battio) == -1)
err(EX_IOERR, "get battery info (%d) failed", num);
- amp = battio.bif.units;
+ amp = battio.bix.units;
pwr_units = amp ? "mA" : "mW";
- if (battio.bif.dcap == UNKNOWN_CAP)
+ if (battio.bix.dcap == UNKNOWN_CAP)
printf("Design capacity:\tunknown\n");
else
- printf("Design capacity:\t%d %sh\n", battio.bif.dcap,
+ printf("Design capacity:\t%d %sh\n", battio.bix.dcap,
pwr_units);
- if (battio.bif.lfcap == UNKNOWN_CAP)
+ if (battio.bix.lfcap == UNKNOWN_CAP)
printf("Last full capacity:\tunknown\n");
else
- printf("Last full capacity:\t%d %sh\n", battio.bif.lfcap,
+ printf("Last full capacity:\t%d %sh\n", battio.bix.lfcap,
pwr_units);
- printf("Technology:\t\t%s\n", battio.bif.btech == 0 ?
+ printf("Technology:\t\t%s\n", battio.bix.btech == 0 ?
"primary (non-rechargeable)" : "secondary (rechargeable)");
- if (battio.bif.dvol == UNKNOWN_CAP)
+ if (ACPI_BIX_REV_MIN_CHECK(battio.bix.rev, ACPI_BIX_REV_1)) {
+ printf("Battery Swappable Capability:\t");
+ if (battio.bix.scap == ACPI_BIX_SCAP_NO)
+ printf("Non-swappable\n");
+ else if (battio.bix.scap == ACPI_BIX_SCAP_COLD)
+ printf("cold swap\n");
+ else if (battio.bix.scap == ACPI_BIX_SCAP_HOT)
+ printf("hot swap\n");
+ else
+ printf("unknown\n");
+ }
+ if (battio.bix.dvol == UNKNOWN_CAP)
printf("Design voltage:\t\tunknown\n");
else
- printf("Design voltage:\t\t%d mV\n", battio.bif.dvol);
- printf("Capacity (warn):\t%d %sh\n", battio.bif.wcap, pwr_units);
- printf("Capacity (low):\t\t%d %sh\n", battio.bif.lcap, pwr_units);
- printf("Low/warn granularity:\t%d %sh\n", battio.bif.gra1, pwr_units);
- printf("Warn/full granularity:\t%d %sh\n", battio.bif.gra2, pwr_units);
- printf("Model number:\t\t%s\n", battio.bif.model);
- printf("Serial number:\t\t%s\n", battio.bif.serial);
- printf("Type:\t\t\t%s\n", battio.bif.type);
- printf("OEM info:\t\t%s\n", battio.bif.oeminfo);
+ printf("Design voltage:\t\t%d mV\n", battio.bix.dvol);
+ printf("Capacity (warn):\t%d %sh\n", battio.bix.wcap, pwr_units);
+ printf("Capacity (low):\t\t%d %sh\n", battio.bix.lcap, pwr_units);
+ if (ACPI_BIX_REV_MIN_CHECK(battio.bix.rev, ACPI_BIX_REV_0)) {
+ if (battio.bix.cycles != ACPI_BATT_UNKNOWN)
+ printf("Cycle Count:\t\t%d\n", battio.bix.cycles);
+ printf("Mesurement Accuracy:\t%d %%\n",
+ battio.bix.accuracy / 1000);
+ if (battio.bix.stmax != ACPI_BATT_UNKNOWN)
+ printf("Max Sampling Time:\t%d ms\n",
+ battio.bix.stmax);
+ if (battio.bix.stmin != ACPI_BATT_UNKNOWN)
+ printf("Min Sampling Time:\t%d ms\n",
+ battio.bix.stmin);
+ printf("Max Average Interval:\t%d ms\n",
+ battio.bix.aimax);
+ printf("Min Average Interval:\t%d ms\n",
+ battio.bix.aimin);
+ }
+ printf("Low/warn granularity:\t%d %sh\n", battio.bix.gra1, pwr_units);
+ printf("Warn/full granularity:\t%d %sh\n", battio.bix.gra2, pwr_units);
+ printf("Model number:\t\t%s\n", battio.bix.model);
+ printf("Serial number:\t\t%s\n", battio.bix.serial);
+ printf("Type:\t\t\t%s\n", battio.bix.type);
+ printf("OEM info:\t\t%s\n", battio.bix.oeminfo);
/* Fetch battery voltage information. */
volt = UNKNOWN_VOLTAGE;