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
- Vendor-specific hardware - currently Fujitsu FUJ02E3 key events

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 structure 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 structured 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.

Log verbosity can be increased by the "verbose" config attribute.

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

!+ start acpica | caps: 400 | ram: 8M
!  + config
!  |        ld_verbose:       yes
!  |        reset:            no
!  |        poweroff:         no
!  |        report:           yes
!  |        report_period_ms: 10000
!  |        verbose:          no
!  |        use_gpe:          yes
!  |        poll_reg:         yes
!  + route
!    + service ROM | label: system | + child ...
!    + service Report              | + child ...
!    ...
!
!+ start platform | caps: 400 | managing_system: yes | ram: 4M
!  + provides | + service Platform
!  + config
!  | + policy | label_prefix: acpica  | + device acpi

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

Report 'acpi_lid' - open/closed:

! acpi_lid
! + lid | value: 1 | count: 1
!   : open
! -

! acpi_lid
! + lid | value: 0 | count: 3
!   : closed
! -


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

! acpi_ac
! + ac | value: 1 | count: 1
!   : online
! -

! acpi_ac
! + ac | value: 0 | count: 2
!   : offline
! -


Report 'acpi_ec' - embedded controller events

! acpi_ec
! + ec
!   + data | value: 42 | count: 1"
!     . triggered
!   + data | value: 43 | count: 1
! -


Report 'acpi_battery' - smart battery status changes

! acpi_battery
! + sb
!   + name
!     : CMB1
!   + powerunit | value: 1
!     : mA/mAh
!   + design_capacity | value: 4280
!   + last_full_capacity | value: 4095
!   + technology | value: 1
!     : secondary
!   + voltage | value: 15120
!   + warning_capacity | value: 530
!   + low_capacity | value: 17
!   + granularity1 | value: 1
!   + granularity2 | value: 1
!   + serial
!     : BAT1
!   + model
!     : RT672
!   + type
!     : LION
!   + oem
!     : ASP
!   + status | value: 31
!   + state | value: 0
!   + present_rate | value: 0
!   + remaining_capacity | value: 4095
!   + present_voltage | value: 16642
! -

! acpi_battery
!
! + state | value: 2
!   . charging
! -

! acpi_battery
!
! + state | value: 15
!   . battery not present
! -


Report 'acpi_hid' - HID Keys by ACPI Fuji02e3 device

! acpi_hid
! + hid | device: Fuj02e3
!   + data | value: 0x0 | count: 0
!   + data | value: 0x4000000 | count: 1
!     : triggered
!     . touchpad toogle
!   + data | value: 0x20000000 | count="1
!     . rfkill
! -


Report 'sleep_states'  - supported S0-S5 sleep states

! sleep_states | version: 0 | complete: S0
! + s1 | supported: false
! + s2 | supported: false
! + s3 | supported: true | slp_typa: 5 | slp_typb: 0
! + s4 | supported: true | slp_typa: 6 | slp_typb: 0
! + s5 | supported: true | slp_typa: 7 | slp_typb: 0
