genode/repos/libports/src/app/acpica
Christian Helmuth ce149397ec acpica: retrieve static battery info only once
On Fujitsu S936, evaluating the _BIF method on each battery-info update
successively increased the RAM usage, while  _BST (dynamic battery
status) and _STA (generic status) did not show this behavior. Therefore
this commit retrieves only dynamic information periodically (resp. on
SCI IRQ). Now, acpica hast static RAM usage in idle state for 24+ hours.

The root cause for the increased RAM usage is still shady. While it
could just be normal that it grows until a certain yet unknown limit,
there may also be memory leak in contrib code or some strange AML on the
designated notebook.

Issue #3454
2019-08-13 12:02:27 +02:00
..
ac.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
bridge.h acpica: generate report usable by platform_drv 2018-05-30 13:36:21 +02:00
ec.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
fixed.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
lid.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
os.cc libports: avoid using deprecated APIs 2019-01-30 13:49:55 +01:00
printf.cc libports: avoid using deprecated APIs 2019-01-30 13:49:55 +01:00
README acpica: generate report usable by platform_drv 2018-05-30 13:36:21 +02:00
report.cc acpica: generate report usable by platform_drv 2018-05-30 13:36:21 +02:00
reporter.h acpica: adjust acpi device reports 2018-05-30 13:36:25 +02:00
sb.h acpica: retrieve static battery info only once 2019-08-13 12:02:27 +02:00
target.mk acpica: generate report usable by platform_drv 2018-05-30 13:36:21 +02:00
util.h acpica: generate report usable by platform_drv 2018-05-30 13:36:21 +02:00

This directory contains a application using the ported ACPI-CA
library (https://www.acpica.org) and reports ACPI state changes in form of
Genode reports. Additionally the application is capable to perform ACPI poweroff
and reset.

Behavior
--------

General support for ACPI events compromises state changes from the following
sources:

- ACPI Lid                 - open/closed
- ACPI Smart battery (SB)  - charging/discharging and static information (capacity)
- ACPI fixed events        - e.g. power button
- ACPI AC adapters         - power cable plugged/un-plugged
- ACPI Embedded controller - some Fn-* keys and on some machines also Lid, AC, SB changes

Whenever a state change is detected, a Genode report is generated, if a 
config attribute "report" is set to "yes". The reports are named
'acpi_lid', 'acpi_battery', 'acpi_fixed', 'acpi_ac' and 'acpi_ec'. See below
for the xml syntax used so far. Please also look into the ACPI specification
for detailed description of some of the fields and their possible values.

If the config attributes 'reset' or 'poweroff' are set to yes, the application
additionally looks for a ROM in XML format named 'system' and monitors
changes of the 'state' attribute:

!<system state="something"/>

Additionally, if the config attributes 'acpi_ready' is set to yes, the
application generates a reports named 'acpi_ready' and set the state to

!<system state="acpi_ready"/>

after finishing the ACPI bring up. This is used by platform_drv to finally
announce the Platform session, so that drivers can start after acpica has
finished.

If the ROM changes to 'state="reset"' the application tries to reset the 
machine immediately.
If the ROM changes to 'state="poweroff"' the application tries to poweroff 
the machine immediately.

The attempt to reset or to poweroff may fail. One reason, we have seen so far,
is that the required resources are already owned by other components in the
system.

Furthermore the ACPICA library triggers depended on the ACPI table content
I/O operations on various PCI devices and partly re-configure it. Because of
this a policy rule at the platform driver is required, that permits access
to the required devices.

Acpica as acpi_drv replacement
------------------------------

The application acpica may also be run as replacement of the original acpi_drv
when the 'act_as_acpi_drv' attribute is set to yes:

!  <config ... acpi_ready="yes" act_as_acpi_drv="yes"/>

The acpica driver will parse in this mode the ACPI tables and will generate
the same content in the ACPI report, which is transformed by a report_rom
service into a ACPI ROM expected initially by the platform driver.

Excerpt of important parts of the acpica configuration
------------------------------------------------------

!<start name="acpica">
!  <!-- <binary name="debug-acpica"/> -->
!  ...
!  <config reset="no" poweroff="no" report="yes" acpi_ready="yes" act_as_acpi_drv="no"/>
!  <route>
!    <service name="ROM" label="system"> <child name="..."/> </service>
!    <service name="Report"> <child name="..."/> </service>
!    ...
!  </route>
!</start>
!
!<start name="platform_drv" >
!  ...
!  <config acpi="yes" system="yes">
!    <policy label_prefix="acpica"> <pci class="ALL"/> </policy>
!    ...
!  </config>
!</start>

Reports generated by the Genode acpica application
--------------------------------------------------

Report 'acpi_lid' - open/closed:

!<acpi_lid>
!  <lid value="1" count="1">open</lid>
!</acpi_lid>

!<acpi_lid>
!  <lid value="0" count="3">closed</lid>
!</acpi_lid>


Report 'acpi_ac' - power cable plugged-in /unplugged

!<acpi_ac>
!  <ac value="1" count="1">online</ac>
!</acpi_ac>

!<acpi_ac>
!  <ac value="0" count="2">offline</ac>
!</acpi_ac>


Report 'acpi_ec' - embedded controller events

!<acpi_ec>
!  <ec>
!    <data value="42" count="1">triggered</data>
!    <data value="43" count="1"/>
!  </ec>
!</acpi_ec>


Report 'acpi_battery' - smart battery status changes

!<acpi_battery>
!  <sb>
!    <name>BAT1</name>
!    <powerunit value="1">mA/mAh</powerunit>
!    <design_capacity value="4800"/>
!    <last_full_capacity value="5417"/>
!    <technology value="1">secondary</technology>
!    <voltage value="12608"/>
!    <warning_capacity value="325"/>
!    <low_capacity value="162"/>
!    <granularity1 value="0"/>
!    <granularity2 value="0"/>
!    <serial>BAT1</serial>
!    <model>RT672</model>
!    <type>LiON</type>
!    <oem>ASP</oem>
!    <status value="31"/>
!    <state value="1">discharging</state>
!    <present_rate value="0"/>
!    <remaining_capacity value="5663"/>
!    <present_voltage value="12524"/>
!  </sb>
!</acpi_battery>

!<acpi_battery>
!    ...
!    <state value="2">charging</state>
!    ...
!</acpi_battery>

!<acpi_battery>
!    ...
!    <status value="15">battery not present</status>
!    ...
!</acpi_battery>