acpi: EJ0 method name patching
authorMichael S. Tsirkin <mst@redhat.com>
Sun, 20 Nov 2011 17:57:05 +0000 (19:57 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 23 Nov 2011 02:53:11 +0000 (21:53 -0500)
commit5a73f3b57043ceb5b08d72f6fe0fcdd5af7f282f
tree232be7755035084fddfe5b6fed15c2ce4bccc0a7
parentc973788346e984a3d91f443008fdd613c30e3185
acpi: EJ0 method name patching

Modify ACPI to only supply _EJ0 methods for PCI slots that support hotplug.

This is done by runtime patching:
- Instrument SSDT ASL code with ACPI_EXTRACT directives
  tagging _EJ0 and _ADR fields.
- At compile time, tools/acpi_extract.py looks for these methods
  in ASL source finds the matching AML, and stores the offsets
  of these methods in tables named aml_ej0_name and aml_adr_dword.
- At run time, go over aml_ej0_name, use aml_adr_dword
  to get slot information and check which slots support hotplug.

  If hotplug is disabled, we patch the _EJ0 NameString in ACPI table,
  replacing _EJ0 with EJ0_.

  Note that this has the same checksum, but is ignored by OSPM.

Note: the method used is robust in that we don't need
to change any offsets manually in case of ASL code changes.
As all parsing is done at compile time, any unexpected input causes
build failure, not a runtime failure.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
src/acpi.c
src/ssdt-pcihp.dsl
src/ssdt-pcihp.hex