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"/>

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 may trigger, dependent on the ACPI ASL code,
various I/O port and I/O mem accesses to hardware. Accesses to PCI devices are
ignored and dropped by this component.

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

!<start name="acpica">
!  <!-- <binary name="debug-acpica"/> -->
!  ...
!  <config reset="no" poweroff="no" report="yes" report_period_ms="2000"/>
!  <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>
