Commit Graph

33 Commits

Author SHA1 Message Date
Hiroki Sato
294de6bbd6 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
2020-02-19 06:28:55 +00:00
Niclas Zeising
fba6127915 Improve options and error handling.
Improve options handling and error out if multiple mutually exclusive
options are passed to acpiconf.  Switch from using atoi() to strtol() for
argument parsing, and add error checking and handling, instead of blindly
trusting that the integer conversion is OK.
Cange err() to errx() in once case, the errno value was garbage there.

Reviewed by:	emaste
Approved by:	emaste
Differential Revision:	D13430
2017-12-09 15:59:10 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Alexander Kabaev
e64aaeac2a Use int to receive the return value of getopt function.
getopt returns int and not char, so assigning the value to
char is not ideal, especially on platforms with unsigned
chars.
2017-04-07 22:58:31 +00:00
Jung-uk Kim
7ecb60344d Tidy up battery status information. Remove a trailing white space.
PR:		193671
2015-04-06 21:51:55 +00:00
Alexander Motin
9c1af42179 When ACPI reports current battery consumption rate in mAmps, print it also
in mWatts. Values in mAmps are not always suitable, because they depend on
battery voltage, which depends on battery type and charge level.
2010-08-24 18:07:59 +00:00
Jung-uk Kim
990651167b Import ACPICA 20090521. 2009-06-05 18:50:45 +00:00
Nate Lawson
00a304487f Update the suspend/resume user API while maintaining backwards compat.
Improvements:
* /etc/rc.suspend,rc.resume are always run, no matter the source of the
  suspend request (user or kernel, apm or acpi)
* suspend now requires positive user acknowledgement.  If a user program
  wants to cancel the suspend, they can.  If one of the user programs
  hangs or doesn't respond within 10 seconds, the system suspends anyway.
* /dev/apm is clonable, allowing multiple listeners for suspend events.
  In the future, xorg-server can use this to be informed about suspend
  even if there are other listeners (i.e. apmd).

Changes:
* Two new ACPI ioctls:  REQSLPSTATE and ACKSLPSTATE.  Request begins the
  process of suspending by notifying all listeners.  acpi is monitored by
  devd(8) and /dev/apm listener(s) are also counted.  Users register their
  approval or disapproval via Ack.  If anyone disapproves, suspend is vetoed.
* Old user programs or kernel modules that used SETSLPSTATE continue to
  work.  A message is printed once that this interface is deprecated.
* acpiconf gains the -k flag to ack the suspend request.  This flag is
  undocumented on purpose since it's only used by /etc/rc.suspend.  It is
  not intended to be a permanent change and will be removed once a better
  power API is implemented.
* S5 (power off) is no longer supported via acpiconf -s 5 or apm -z/-Z.
  This restores previous behavior of halt/shutdown -p being the interface.
* Miscellaneous improvements to error reporting

Approved by:	re
2007-06-21 22:50:37 +00:00
Nate Lawson
0af442fbcf Correct column alignment. 2005-07-28 19:41:52 +00:00
Nate Lawson
7a20dc58a8 Fix nits in reporting battery information and add battery status reporting.
Rate units are mA/mW, not mAh/mWh.  Get full battery status and time
remaining from ACPIIO_BATT_GET_BATTINFO instead of BST.

PR:		bin/83672
MFC after:	2 days
2005-07-28 19:31:28 +00:00
Nate Lawson
d551ef2b72 Use the current BST/BIF ioctls, not the deprecated ones.
MFC after:	2 days
2005-07-22 19:19:00 +00:00
Warner Losh
bfccea1e5d o Report charge/discharge rate and remaining capacity in the proper
units (as specified in _BIF). (noted by Bruno Ducrot)
o In looking in the standard, if the cap numbers are 0xffffffff, then acpi
  is reporting unknown for that field.  Report unknown numbers properly.
o Update the state to reflect charging, discharging and critical.
2004-11-24 16:02:20 +00:00
Warner Losh
95e583726f phk jumped the gun and posted what looks like a preliminary version of
my patches for this information.  Commit my more complete version.
This version isn't complete yet, since some details aren't handled
right just yet.

Poaching by: phk
2004-11-24 15:32:07 +00:00
Poul-Henning Kamp
fdcef74733 Dump current status of battery as well.
The -i code doesn't really belong here in the first place I would think,
but keep it together for now.
2004-11-24 12:49:39 +00:00
Warner Losh
46433fccd1 Minor style(9) before possible larger commits. 2004-11-16 06:25:02 +00:00
Philip Paeps
6af2c48a95 Somehow I missed this last night, acpi_init() doesn't return an int.
Spotted by:	Randy Bush <randy@psg.com>
2004-11-13 15:16:35 +00:00
Philip Paeps
413efd9141 With the addition of a proper prototype, this is now WARNS=6 clean. 2004-11-13 01:54:22 +00:00
Nate Lawson
e079f9491a Remove the ACPIIO_ENABLE and ACPIIO_DISABLE ioctls as well as all
callers.  These ioctls attempted to enable and disable the ACPI
interpreter at runtime.  In practice, it is not possible to boot with
ACPI and then disable it on many systems and trying to do so can cause
crashes, interrupt storms, etc.  Binary compatibility with userland is
retained.

MFC after:	2 days
2004-08-18 05:48:24 +00:00
Nate Lawson
c5fe547333 Comment out the ability to enable/disable ACPI at runtime. This appears
to not work reliably and crash some systems.  It is not supported at all
on others.  Pending discussion, the underlying ioctls will be removed.
2004-08-15 23:39:37 +00:00
Takanori Watanabe
8aabbec241 Fix style breakage.
Noticed by: njl
2004-03-05 02:48:22 +00:00
Takanori Watanabe
fe27a95e90 Make unprivilaged user can see battery info. 2004-03-04 17:03:49 +00:00
Nate Lawson
e776370e2b Add support for /etc/rc.suspend and /etc/rc.resume for ACPI. They are
called directly from acpiconf(8).  Change both scripts to take a
subsystem (apm|acpi) and sleep level (suspend,standby|1-5) argument.
2003-12-30 17:28:06 +00:00
Nate Lawson
64fdad2352 Add the -i flag to acpiconf(8) to retrieve battery information.
Rename a few structure elements.
2003-09-13 20:13:01 +00:00
Nate Lawson
d886fcc23e Allow sleep states to be specified as S1, S2, ...
This is used by zzz(8).
2003-07-28 16:22:45 +00:00
Nate Lawson
51773ddf47 Support functions for the new ACPI import.
* AcpiOsDerivePciId(): finds a bus number, given the slot/func and the
    acpi parse tree.
  * AcpiOsPredefinedOverride(): use the sysctl hw.acpi.os_name to
    override the value for _OS.

Ideas from:	takawata, jhb
Reviewed by:	takawata, marcel
Tested on:	i386, ia64
2003-04-29 18:50:34 +00:00
Mitsuru IWASAKI
98479b041b Resolve conflicts arising from the ACPI CA 20020611 import. 2002-07-09 17:54:02 +00:00
Crist J. Clark
28f49c6daf Make the error messaging more helpful.
PR:		31483
Approved by:	iwasaki, ru
MFC after:	4 days
2001-11-30 11:35:01 +00:00
Mike Smith
59eacecf65 ACPI CA doesn't recognis S4BIOS as a seperate sleep type anymore, so
drop support for it here until we work out a better way of handling it.
2001-07-21 21:51:44 +00:00
David E. O'Brien
be51554b89 Remove double //'s in path. 2001-06-02 19:09:37 +00:00
Mike Smith
19dbbb64f5 Catch up to new include paths.
Submitted by:	walt <wsheets@att.net>
2001-05-30 00:22:37 +00:00
Mitsuru IWASAKI
d3f4a2ca8e Remove dependence on old acpi driver from acpi userland tools.
- acpiconf	Replace include files from old acpi driver to acpica driver.
		New sleep type `4b' had been added (S4BIOS) for `-s' option.
		Of course this has no effect because driver doesn't
		support it for now :-)

 - acpidump	All needed structs in sys/dev/acpi/*.h had been merged
		into local header file.  No changes on its usage.
2000-11-08 02:37:00 +00:00
Mike Smith
e434fd9b90 Update include paths for new header locations.
Submitted by:	iwasaki
2000-09-30 20:13:57 +00:00
Mitsuru IWASAKI
2e6c5fc592 import acpiconf(8) from ACPI For FreeBSD project.
Obtained from:  ACPI For FreeBSD project
2000-08-31 14:41:23 +00:00