History log of /freebsd-current/sys/dev/acpica/acpi_cmbat.c
Revision Date Author Comments
# d0cc25f7 19-Apr-2024 Ahmad Khalifa <ahmadkhalifa570@gmail.com>

acpi_cmbat: Use nitems instead of sizeof

Reviewed by: imp, markj, Elliott Mitchell
Pull Request: https://github.com/freebsd/freebsd-src/pull/1125


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# f63aaffe 23-Mar-2023 Gordon Bergling <gbe@FreeBSD.org>

acpi(4): Fix a typo in a kernel message

- s/enitialization/initialization/

MFC afer: 5 days


# 916a5d8a 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

acpi: Remove unused devclass arguments to DRIVER_MODULE.


# ff29a952 27-Feb-2020 Hiroki Sato <hrs@FreeBSD.org>

Add workaround for models which do not follow the ACPI specification strictly.
Extra objects are now simply ignored instead of rejecting everything.


# 294de6bb 18-Feb-2020 Hiroki Sato <hrs@FreeBSD.org>

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


# 5efca36f 25-Oct-2018 Takanori Watanabe <takawata@FreeBSD.org>

Distinguish _CID match and _HID match and make lower priority probe
when _CID match.

Reviewed by: jhb, imp
Differential Revision:https://reviews.freebsd.org/D16468


# 6040822c 30-Jul-2018 Alan Somers <asomers@FreeBSD.org>

Make timespecadd(3) and friends public

The timespecadd(3) family of macros were imported from NetBSD back in
r35029. However, they were initially guarded by #ifdef _KERNEL. In the
meantime, we have grown at least 28 syscalls that use timespecs in some
way, leading many programs both inside and outside of the base system to
redefine those macros. It's better just to make the definitions public.

Our kernel currently defines two-argument versions of timespecadd and
timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define
three-argument versions. Solaris also defines a three-argument version, but
only in its kernel. This revision changes our definition to match the
common three-argument version.

Bump _FreeBSD_version due to the breaking KPI change.

Discussed with: cem, jilles, ian, bde
Differential Revision: https://reviews.freebsd.org/D14725


# a26871e7 27-Feb-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix startup race initialising ACPI CM battery structures on MacBookPro.

During acpi_cmbat_attach() the acpi_cmbat_init_battery() notification
handler is registered. It has been observed this notification handler
can be called instantly, before the attach routine has returned. In
the notification handler there is a call to device_is_attached() which
returns false. Because the softc is set we know an attach is in
progress and the fix is simply to wait and try again in this case.

Reviewed by: avg @
MFC after: 1 week


# 61bfd867 30-Jan-2013 Sofian Brabez <sbz@FreeBSD.org>

Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays

Reviewed by: cognet
Approved by: cognet


# d745c852 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


# 766d7e65 17-Dec-2010 Andriy Gapon <avg@FreeBSD.org>

small cleanup of acpi battery status setting and checking

This is based on the patch submitted by Yuri Skripachov.
Overview of the changes:
- clarify double-use of some ACPI_BATT_STAT_* definitions
- clean up undefined/extended status bits returned by _BST
- warn about charging+discharging bits being set at the same time

PR: kern/124744
Submitted by: Yuri Skripachov <y.skripachov@gmail.com>
Tested by: Yuri Skripachov <y.skripachov@gmail.com>
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 129d3046 05-Jun-2009 Jung-uk Kim <jkim@FreeBSD.org>

Import ACPICA 20090521.


# aaac7452 02-Jun-2009 Jung-uk Kim <jkim@FreeBSD.org>

Chase ACPICA API changes (for kernel and boot loader).


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 2be4e471 22-Mar-2007 Jung-uk Kim <jkim@FreeBSD.org>

Catch up with ACPI-CA 20070320 import.


# 1b951829 15-Apr-2006 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Oops, untested code was included accidentally.
Fixed.


# 858a52f4 14-Apr-2006 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Import ACPI Dock Station support. Note that this is still very young.
Additional detach implementaions (or maybe improvement) for other
deivce drivers is required.

Reviewed by: njl, imp
MFC after: 1 week


# c02106f3 26-Nov-2005 Nate Lawson <njl@FreeBSD.org>

Add a locking stub to call acpi_cmbat_get_bif() now that it is directly
run from the taskqueue. There should probably be a better way to do this
later, but this suffices for now.

Submitted by: yongari


# 2010798d 22-Nov-2005 Nate Lawson <njl@FreeBSD.org>

Try to fix problems with periodic hangs by never directly calling _BIF.
Instead, re-evaluate _BIF only when we get a notify and use the cached
results. We also still evaluate _BIF once on boot. Also, optimize the
init loop a little by only querying for a particular info if it's not valid.

MFC after: 2 days


# 2a191126 11-Sep-2005 David E. O'Brien <obrien@FreeBSD.org>

Canonize the include of acpi.h.


# 76f6fe4f 23-Jul-2005 Nate Lawson <njl@FreeBSD.org>

Rewrite the acpi_battery interface to allow for other battery types
(i.e., smart battery) and fix various bugs found during the cleanup.

API changes:
* kernel access:
Access to individual batteries is now via devclass_find("battery").
Introduce new methods ACPI_BATT_GET_STATUS (for _BST-formatted data) and
ACPI_BATT_GET_INFO (for _BIF-formatted data). The helper function
acpi_battery_get_battinfo() now takes a device_t instead of a unit #
argument. If dev is NULL, this signifies all batteries.

* ioctl access:
The ACPIIO_BATT_GET_TYPE and ACPIIO_BATT_GET_BATTDESC ioctls have been
removed. Since there is now no need for a mapping between "virtual" unit
and physical unit, usermode programs can just specify the unit directly and
skip the old translation steps. In fact, acpiconf(8) was actually already
doing this and virtual unit was the same as physical unit in all cases
since there was previously only one battery type (acpi_cmbat). Additionally,
we now map the ACPIIO_BATT_GET_BIF and ACPIIO_BATT_GET_BST ioctls for all
batteries, if they provide the associated methods.

* apm compatibility device/ioctls: no change
* sysctl: no change

Since most third-party applications use the apm(4) compat interface, there
should be very few affected applications (if any).

Reviewed by: bruno
MFC after: 5 days


# 54640fac 19-Dec-2004 Nate Lawson <njl@FreeBSD.org>

Only report a critical battery level once until it's gone non-critical.
An improvement would be to check all batteries for critical state before
printing a message.

Reported by: Kevin Oberman (oberman at es net)


# f8c60df7 01-Dec-2004 Mark Santcroos <marks@FreeBSD.org>

Catch up with AcpiOsSleep() interface change.
Catch up with some #define's renaming.
Implement AcpiOsGetTimer() as per ACPI 3.0.

Approved by: njl
MFC after: 1 week


# a0885d3f 11-Oct-2004 Nate Lawson <njl@FreeBSD.org>

Notify the user when the battery is critically low. In the future, we
may want to shut down here but the chance of BIOS vendors getting this
wrong is high. They're only supposed to announce this when all batteries
hit their critical level but past experience indicates we should be
conservative about this for now.


# 4c37803a 17-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Fix a deadlock on boot for some systems where reading the battery status
also generates a notify. Since we held the lock over this call, the
notify never got to run and the battery status read never returned.
Document this also.

Tested by: Maxim Maximov <mcsi_at_mcsi.pp.ru>
Approved by: re (scottl)


# 98b2573f 13-Aug-2004 Nate Lawson <njl@FreeBSD.org>

MPSAFE locking

* Serialize ops in acpi_cmbat_notify_handler(), acpi_cmbat_ioctl(),
acpi_cmbat_init_battery(), and acpi_cmbat_get_battinfo().
* Get the softc directly in acpi_cmbat_get_total_battinfo() rather than
build an array of them.
* Don't queue a _BIF query after receiving a notify. Since we clear the
timespec, a _BIF query will be done in the context of the next caller.
* Add asserts to leaf functions that operate on shared data.
* Remove the bst/bif updating flags now that we hold the lock over the
full query.
* Explain various comments in more detail.


# 021730ab 16-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Use ACPI_ALL_NOTIFY instead of registering handlers separately.


# 9b7b2aef 14-Jul-2004 Mark Santcroos <marks@FreeBSD.org>

Some laptops report the "design-capacity" instead of the "real-capacity"
when the battery is fully charged. That breaks some of the arithmetic in
calculating the remaining capacity (ends up with more than 100%).
This commit makes sure the max is 100.

Approved by: njl


# 7a5230b8 12-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Add the ability to detach a battery. Now batteries that are detached are
also removed from the battery list.


# 5fcc8a58 29-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Use the acpi_id_probe() method instead of acpi_MatchHid(), which is now
static.


# 91233413 13-Jun-2004 Nate Lawson <njl@FreeBSD.org>

Add support to ACPI to manage its own resources. Previously, resource
allocation was passed up to nexus. Now, we probe sysresource objects and
manage the resources they describe in a local rman pool. This helps
devices which attach/detach varying resources (like the _CST object) and
module loads/unloads. The allocation/release routines now check to see if
the resource is described in a child sysresource object and if so,
allocate from the local rman. Sysresource objects add their resources to
the pool and reserve them upon boot. This means sysresources need to be
probed before other ACPI devices.

Changes include:
* Add ordering to the child device probe. The current order is: system
resource objects, embedded controllers, then everything else.
* Make acpi_MatchHid take a handle instead of a device_t arg.
* Replace acpi_{get,set}_resource with the generic equivalents.


# fe12f24b 30-May-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Add missing <sys/module.h> includes


# 64278df5 09-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Add MODULE_DEPEND entries so some of these drivers can eventually be
loaded separately from ACPI (i.e., embedded use).


# 8d181eb5 23-Dec-2003 Nate Lawson <njl@FreeBSD.org>

Update to use the new package routines instead of rolling our own
macros.


# 9b937d48 24-Oct-2003 Nate Lawson <njl@FreeBSD.org>

Add devctl(4) notify support to ACPI. Various subsystems now notify
userland whenever events occur. See the example in devd.conf below
to see how to use it.


# 656b9dd5 25-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Consistently print attach messages.


# 64fdad23 13-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Add the -i flag to acpiconf(8) to retrieve battery information.
Rename a few structure elements.


# 5c596708 10-Sep-2003 Nate Lawson <njl@FreeBSD.org>

Add a system notify handler in addition to the device notify handler.
At least some Toshiba notebooks use a Notify of 0 or 1 for this.

PR:
Submitted by: Hiroyuki Aizu <aizu@navi.org>


# ec2e60b4 14-Aug-2003 Nate Lawson <njl@FreeBSD.org>

De-inline functions which do not need to be inline. Move the DEVMETHOD
block to where it is in similar drivers.


# 798fb860 11-Aug-2003 Nate Lawson <njl@FreeBSD.org>

Style cleanups to match the rest of this directory. For acpi_battery.c,
remove unused includes.


# a89fcf28 14-Feb-2003 Takanori Watanabe <takawata@FreeBSD.org>

Allow non-privilaged user to retrive battery or AC line information.

Reviewed by: rwatson


# 9bb04eb4 03-Nov-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add status initialization code for acpi_cmbat and acpi_acad,
acpi_cmbat_init_battery() and acpi_cmbat_init_acline() respectively.
Call acpi_cmbat_init_battery() from acpi_cmbat_resume() too just in
case.
This is a workaround for embedded controller operations which is
unstable for about a minute (typically 30 or 40 sec.) at boot time.


# 11dfccde 21-Aug-2002 John Baldwin <jhb@FreeBSD.org>

Use the _STA method of a battery control method to see if a battery is
present or not. My laptop now properly notices when a battery is removed.

Reviewed by: iwasaki


# 3c24196d 22-Jul-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add NULL check for the output buffer from AcpiEvaluateObject().

Submitted by: jon


# 8b79649b 11-Mar-2002 Peter Wemm <peter@FreeBSD.org>

Do not concatenate __func__ with strings, because it is not a string.
Later gcc's blow up on this.


# 595a0897 22-Feb-2002 Mike Smith <msmith@FreeBSD.org>

Match namespace cleanup changes in ACPI CA 20020217 update.
Use ACPI_SUCCESS/ACPI_FAILURE consistently.
The AcpiGetInto* interfaces are obsoleted by ACPI_ALLOCATE_BUFFER.

Kill off the timeouts that used to read _BIF and _BST. These are
invoked when the battery is actually read. timeout() is dangerous
in combination with ACPI, as the interpreter can block.

This driver still needs more work.


# c573e654 22-Dec-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add OS layer ACPI mutex and threading support.
- Temporary fix a bug of Intel ACPI CA core code.
- Add OS layer ACPI mutex support. This can be disabled by
specifying option ACPI_NO_SEMAPHORES.
- Add ACPI threading support. Now that we have a dedicate taskqueue for
ACPI tasks and more ACPI task threads can be created by specifying option
ACPI_MAX_THREADS.
- Change acpi_EvaluateIntoBuffer() behavior slightly to reuse given
caller's buffer unless AE_BUFFER_OVERFLOW occurs. Also CM battery's
evaluations were changed to use acpi_EvaluateIntoBuffer().
- Add new utility function acpi_ConvertBufferToInteger().
- Add simple locking for CM battery and temperature updating.
- Fix a minor problem on EC locking.
- Make the thermal zone polling rate to be changeable.
- Change minor things on AcpiOsSignal(); in ACPI_SIGNAL_FATAL case,
entering Debugger is easier to investigate the problem rather than panic.


# dc2183bf 22-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add disabling code via the debug.acpi.disable environment variable.


# 6971b3c7 18-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Cleanups of verbose printing. All the messages for the debugging is
disabled unless verbose flag is set. Also fix some messages in terms
of English.
The critical messages and error messages in probe/attach routine are
unchanged by this commit.


# 3fa01022 01-Nov-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Oops, deleted wrong BIF acquisition timeout invocation by mistake
in my previous commit.
acpi_cmbat_get_bif() from taskqueue calls acpi_cmbat_timeout() so it's
better for startup.


# a296c021 30-Oct-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Style(9) fix, mainly white spaces.


# 9febbb40 30-Oct-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Some improvements of control method battery driver.
- Add a new MIB for battery info expire time in order to make it changeable.
Battery info expire time can be specified by
hw.acpi.battery.info_expire in sec.
- Add own MALLOC type and fix some potential memory leakages.
- Change some frequent printings to verbose printing.
- Stop timeout during acpi_cmbat_get_bst() too. This should reduce
the races with BIF evaluation.
- Remove acpi_cmbat_get_bif() invocation from acpi_cmbat_attach().
This was redundant because this should be called from
acpi_cmbat_timeout() now.


# c7a97680 22-Oct-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Reduce frequency of Battery info (_BIF) acquisition. This helps
avoiding EC read errors on some laptops.
- Stop updating Battery info for all user requests
- Update Battery info by notify events and resume method
- Poll Battery info every one minute

Suggested by: takawata


# 6454a61b 23-Jun-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Reset timestamps of battery info. and status by thier notify handler.

Suggested by: takawata


# 4eb77744 23-Jun-2001 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add sysctl interface (Read-only) for temprature, AC-line and Battery.
Patches for acpi_cmbat.c submitted by Munehiro Matsuda.


# 2a4ac806 29-May-2001 Mike Smith <msmith@FreeBSD.org>

- Updates for new constant naming in the ACPI CA 20010518 update.
- Use __func__ instead of __FUNCTION.
- Support power-off to S3 or S5 (takawata)
- Enable ACPI debugging earlier (with a sysinit)
- Fix a deadlock in the EC code (takawata)
- Improve arithmetic and reduce the risk of spurious wakeup in
AcpiOsSleep.
- Add AcpiOsGetThreadId.
- Simplify mutex code (still disabled).


# e3225e78 26-Feb-2001 John Baldwin <jhb@FreeBSD.org>

When ensuring the destination buffer is truncated for a string obtained
from a BIF, use the size of the destinatino buffer, not the length of the
string to determine where to put the nul char. As a side effect, the
old code would truncate the string by one character while it was possibly
overflowing the buffer.


# 91467fc6 31-Jan-2001 Mike Smith <msmith@FreeBSD.org>

ACPI_NUMBER becomes ACPI_INTEGER. acpi_EvaluateNumber becomes
acpi_EvaluateInteger.

Use acpi_EvaluateInteger instead of doing things the hard way where
possible.

AcpiSetSystemSleepState (unofficial) becomes AcpiEnterSleepState.

Use the AcpiGbl_FADT pointer rather than searching for the FADT.


# 917d44c8 24-Dec-2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>

Add ioctls to acpi_cmbat and acpi_acad. These use mike's acpi_register_ioctl().
Fix wrong AML method calling in acpi_cmbat.


# d8c616ae 22-Dec-2000 Takanori Watanabe <takawata@FreeBSD.org>

Add ACPI AC adaptor and ACPI Control Method Battery.
And install notify handler for thermal zone .