| 1 |
.. SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
|
| 3 |
================== |
| 4 |
ACPI WMI interface |
| 5 |
================== |
| 6 |
|
| 7 |
The ACPI WMI interface is a proprietary extension of the ACPI specification made |
| 8 |
by Microsoft to allow hardware vendors to embed WMI (Windows Management Instrumentation) |
| 9 |
objects inside their ACPI firmware. Typical functions implemented over ACPI WMI |
| 10 |
are hotkey events on modern notebooks and configuration of BIOS options. |
| 11 |
|
| 12 |
PNP0C14 ACPI device |
| 13 |
------------------- |
| 14 |
|
| 15 |
Discovery of WMI objects is handled by defining ACPI devices with a PNP ID |
| 16 |
of ``PNP0C14``. These devices will contain a set of ACPI buffers and methods |
| 17 |
used for mapping and execution of WMI methods and/or queries. If there exist |
| 18 |
multiple of such devices, then each device is required to have a |
| 19 |
unique ACPI UID. |
| 20 |
|
| 21 |
_WDG buffer |
| 22 |
----------- |
| 23 |
|
| 24 |
The ``_WDG`` buffer is used to discover WMI objects and is required to be |
| 25 |
static. Its internal structure consists of data blocks with a size of 20 bytes, |
| 26 |
containing the following data: |
| 27 |
|
| 28 |
======= =============== ===================================================== |
| 29 |
Offset Size (in bytes) Content |
| 30 |
======= =============== ===================================================== |
| 31 |
0x00 16 128 bit Variant 2 object GUID. |
| 32 |
0x10 2 2 character method ID or single byte notification ID. |
| 33 |
0x12 1 Object instance count. |
| 34 |
0x13 1 Object flags. |
| 35 |
======= =============== ===================================================== |
| 36 |
|
| 37 |
The WMI object flags control whether the method or notification ID is used: |
| 38 |
|
| 39 |
- 0x1: Data block is expensive to collect. |
| 40 |
- 0x2: Data block contains WMI methods. |
| 41 |
- 0x4: Data block contains ASCIZ string. |
| 42 |
- 0x8: Data block describes a WMI event, use notification ID instead |
| 43 |
of method ID. |
| 44 |
|
| 45 |
Each WMI object GUID can appear multiple times inside a system. |
| 46 |
The method/notification ID is used to construct the ACPI method names used for |
| 47 |
interacting with the WMI object. |
| 48 |
|
| 49 |
WQxx ACPI methods |
| 50 |
----------------- |
| 51 |
|
| 52 |
If a data block does not contain WMI methods, then its content can be retrieved |
| 53 |
by this required ACPI method. The last two characters of the ACPI method name |
| 54 |
are the method ID of the data block to query. Their single parameter is an |
| 55 |
integer describing the instance which should be queried. This parameter can be |
| 56 |
omitted if the data block contains only a single instance. |
| 57 |
|
| 58 |
WSxx ACPI methods |
| 59 |
----------------- |
| 60 |
|
| 61 |
Similar to the ``WQxx`` ACPI methods, except that it is optional and takes an |
| 62 |
additional buffer as its second argument. The instance argument also cannot |
| 63 |
be omitted. |
| 64 |
|
| 65 |
WMxx ACPI methods |
| 66 |
----------------- |
| 67 |
|
| 68 |
Used for executing WMI methods associated with a data block. The last two |
| 69 |
characters of the ACPI method name are the method ID of the data block |
| 70 |
containing the WMI methods. Their first parameter is a integer describing the |
| 71 |
instance which methods should be executed. The second parameter is an integer |
| 72 |
describing the WMI method ID to execute, and the third parameter is a buffer |
| 73 |
containing the WMI method parameters. If the data block is marked as containing |
| 74 |
an ASCIZ string, then this buffer should contain an ASCIZ string. The ACPI |
| 75 |
method will return the result of the executed WMI method. |
| 76 |
|
| 77 |
WExx ACPI methods |
| 78 |
----------------- |
| 79 |
|
| 80 |
Used for optionally enabling/disabling WMI events, the last two characters of |
| 81 |
the ACPI method are the notification ID of the data block describing the WMI |
| 82 |
event as hexadecimal value. Their first parameter is an integer with a value |
| 83 |
of 0 if the WMI event should be disabled, other values will enable |
| 84 |
the WMI event. |
| 85 |
|
| 86 |
Those ACPI methods are always called even for WMI events not registered as |
| 87 |
being expensive to collect to match the behavior of the Windows driver. |
| 88 |
|
| 89 |
WCxx ACPI methods |
| 90 |
----------------- |
| 91 |
Similar to the ``WExx`` ACPI methods, except that instead of WMI events it controls |
| 92 |
data collection of data blocks registered as being expensive to collect. Thus the |
| 93 |
last two characters of the ACPI method name are the method ID of the data block |
| 94 |
to enable/disable. |
| 95 |
|
| 96 |
Those ACPI methods are also called before setting data blocks to match the |
| 97 |
behavior of the Windows driver. |
| 98 |
|
| 99 |
_WED ACPI method |
| 100 |
---------------- |
| 101 |
|
| 102 |
Used to retrieve additional WMI event data, its single parameter is a integer |
| 103 |
holding the notification ID of the event. This method should be evaluated every |
| 104 |
time an ACPI notification is received, since some ACPI implementations use a |
| 105 |
queue to store WMI event data items. This queue will overflow after a couple |
| 106 |
of WMI events are received without retrieving the associated WMI event data. |
| 107 |
|
| 108 |
Conversion rules for ACPI data types |
| 109 |
------------------------------------ |
| 110 |
|
| 111 |
Consumers of the ACPI-WMI interface use binary buffers to exchange data with the WMI driver core, |
| 112 |
with the internal structure of the buffer being only know to the consumers. The WMI driver core is |
| 113 |
thus responsible for converting the data inside the buffer into an appropriate ACPI data type for |
| 114 |
consumption by the ACPI firmware. Additionally, any data returned by the various ACPI methods needs |
| 115 |
to be converted back into a binary buffer. |
| 116 |
|
| 117 |
The layout of said buffers is defined by the MOF description of the WMI method or data block in |
| 118 |
question [1]_: |
| 119 |
|
| 120 |
=============== ======================================================================= ========= |
| 121 |
Data Type Layout Alignment |
| 122 |
=============== ======================================================================= ========= |
| 123 |
``string`` Starts with an unsigned 16-bit little endian integer specifying 2 bytes |
| 124 |
the length of the string data in bytes, followed by the string data |
| 125 |
encoded as UTF-16LE with **optional** NULL termination and padding. |
| 126 |
Keep in mind that some firmware implementations might depend on the |
| 127 |
terminating NULL character to be present. Also the padding should |
| 128 |
always be performed with NULL characters. |
| 129 |
``boolean`` Single byte where 0 means ``false`` and nonzero means ``true``. 1 byte |
| 130 |
``sint8`` Signed 8-bit integer. 1 byte |
| 131 |
``uint8`` Unsigned 8-bit integer. 1 byte |
| 132 |
``sint16`` Signed 16-bit little endian integer. 2 bytes |
| 133 |
``uint16`` Unsigned 16-bit little endian integer. 2 bytes |
| 134 |
``sint32`` Signed 32-bit little endian integer. 4 bytes |
| 135 |
``uint32`` Unsigned 32-bit little endian integer. 4 bytes |
| 136 |
``sint64`` Signed 64-bit little endian integer. 8 bytes |
| 137 |
``uint64`` Unsigned 64-bit little endian integer. 8 bytes |
| 138 |
``datetime`` A fixed-length 25-character UTF-16LE string with the format 2 bytes |
| 139 |
*yyyymmddhhmmss.mmmmmmsutc* where *yyyy* is the 4-digit year, *mm* is |
| 140 |
the 2-digit month, *dd* is the 2-digit day, *hh* is the 2-digit hour |
| 141 |
based on a 24-hour clock, *mm* is the 2-digit minute, *ss* is the |
| 142 |
2-digit second, *mmmmmm* is the 6-digit microsecond, *s* is a plus or |
| 143 |
minus character depending on whether *utc* is a positive or negative |
| 144 |
offset from UTC (or a colon if the date is an interval). Unpopulated |
| 145 |
fields should be filled with asterisks. |
| 146 |
=============== ======================================================================= ========= |
| 147 |
|
| 148 |
Arrays should be aligned based on the alignment of their base type, while objects should be |
| 149 |
aligned based on the largest alignment of an element inside them. |
| 150 |
|
| 151 |
All buffers returned by the WMI driver core are 8-byte aligned. When converting ACPI data types |
| 152 |
into such buffers the following conversion rules apply: |
| 153 |
|
| 154 |
=============== ============================================================ |
| 155 |
ACPI Data Type Converted into |
| 156 |
=============== ============================================================ |
| 157 |
Buffer Copied as-is. |
| 158 |
Integer Converted into a ``uint32``. |
| 159 |
String Converted into a ``string`` with a terminating NULL character |
| 160 |
to match the behavior the of the Windows driver. |
| 161 |
Package Each element inside the package is converted with alignment |
| 162 |
of the resulting data types being respected. Nested packages |
| 163 |
are not allowed. |
| 164 |
=============== ============================================================ |
| 165 |
|
| 166 |
The Windows driver does attempt to handle nested packages, but this results in internal data |
| 167 |
structures (``_ACPI_METHOD_ARGUMENT_V1``) erroneously being copied into the resulting buffer. |
| 168 |
ACPI firmware implementations should thus not return nested packages from ACPI methods |
| 169 |
associated with the ACPI-WMI interface. |
| 170 |
|
| 171 |
References |
| 172 |
========== |
| 173 |
|
| 174 |
.. [1] https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/driver-defined-wmi-data-items |