1.. SPDX-License-Identifier: GPL-2.0-or-later 2 3================== 4ACPI WMI interface 5================== 6 7The ACPI WMI interface is a proprietary extension of the ACPI specification made 8by Microsoft to allow hardware vendors to embed WMI (Windows Management Instrumentation) 9objects inside their ACPI firmware. Typical functions implemented over ACPI WMI 10are hotkey events on modern notebooks and configuration of BIOS options. 11 12PNP0C14 ACPI device 13------------------- 14 15Discovery of WMI objects is handled by defining ACPI devices with a PNP ID 16of ``PNP0C14``. These devices will contain a set of ACPI buffers and methods 17used for mapping and execution of WMI methods and/or queries. If there exist 18multiple of such devices, then each device is required to have a 19unique ACPI UID. 20 21_WDG buffer 22----------- 23 24The ``_WDG`` buffer is used to discover WMI objects and is required to be 25static. Its internal structure consists of data blocks with a size of 20 bytes, 26containing the following data: 27 28======= =============== ===================================================== 29Offset Size (in bytes) Content 30======= =============== ===================================================== 310x00 16 128 bit Variant 2 object GUID. 320x10 2 2 character method ID or single byte notification ID. 330x12 1 Object instance count. 340x13 1 Object flags. 35======= =============== ===================================================== 36 37The 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 45Each WMI object GUID can appear multiple times inside a system. 46The method/notification ID is used to construct the ACPI method names used for 47interacting with the WMI object. 48 49WQxx ACPI methods 50----------------- 51 52If a data block does not contain WMI methods, then its content can be retrieved 53by this required ACPI method. The last two characters of the ACPI method name 54are the method ID of the data block to query. Their single parameter is an 55integer describing the instance which should be queried. This parameter can be 56omitted if the data block contains only a single instance. 57 58WSxx ACPI methods 59----------------- 60 61Similar to the ``WQxx`` ACPI methods, except that it is optional and takes an 62additional buffer as its second argument. The instance argument also cannot 63be omitted. 64 65WMxx ACPI methods 66----------------- 67 68Used for executing WMI methods associated with a data block. The last two 69characters of the ACPI method name are the method ID of the data block 70containing the WMI methods. Their first parameter is a integer describing the 71instance which methods should be executed. The second parameter is an integer 72describing the WMI method ID to execute, and the third parameter is a buffer 73containing the WMI method parameters. If the data block is marked as containing 74an ASCIZ string, then this buffer should contain an ASCIZ string. The ACPI 75method will return the result of the executed WMI method. 76 77WExx ACPI methods 78----------------- 79 80Used for optionally enabling/disabling WMI events, the last two characters of 81the ACPI method are the notification ID of the data block describing the WMI 82event as hexadecimal value. Their first parameter is an integer with a value 83of 0 if the WMI event should be disabled, other values will enable 84the WMI event. 85 86Those ACPI methods are always called even for WMI events not registered as 87being expensive to collect to match the behavior of the Windows driver. 88 89WCxx ACPI methods 90----------------- 91Similar to the ``WExx`` ACPI methods, except that instead of WMI events it controls 92data collection of data blocks registered as being expensive to collect. Thus the 93last two characters of the ACPI method name are the method ID of the data block 94to enable/disable. 95 96Those ACPI methods are also called before setting data blocks to match the 97behavior of the Windows driver. 98 99_WED ACPI method 100---------------- 101 102Used to retrieve additional WMI event data, its single parameter is a integer 103holding the notification ID of the event. This method should be evaluated every 104time an ACPI notification is received, since some ACPI implementations use a 105queue to store WMI event data items. This queue will overflow after a couple 106of WMI events are received without retrieving the associated WMI event data. 107 108Conversion rules for ACPI data types 109------------------------------------ 110 111Consumers of the ACPI-WMI interface use binary buffers to exchange data with the WMI driver core, 112with the internal structure of the buffer being only know to the consumers. The WMI driver core is 113thus responsible for converting the data inside the buffer into an appropriate ACPI data type for 114consumption by the ACPI firmware. Additionally, any data returned by the various ACPI methods needs 115to be converted back into a binary buffer. 116 117The layout of said buffers is defined by the MOF description of the WMI method or data block in 118question [1]_: 119 120=============== ======================================================================= ========= 121Data 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 148Arrays should be aligned based on the alignment of their base type, while objects should be 149aligned based on the largest alignment of an element inside them. 150 151All buffers returned by the WMI driver core are 8-byte aligned. When converting ACPI data types 152into such buffers the following conversion rules apply: 153 154=============== ============================================================ 155ACPI Data Type Converted into 156=============== ============================================================ 157Buffer Copied as-is. 158Integer Converted into a ``uint32``. 159String Converted into a ``string`` with a terminating NULL character 160 to match the behavior the of the Windows driver. 161Package 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 166The Windows driver does attempt to handle nested packages, but this results in internal data 167structures (``_ACPI_METHOD_ARGUMENT_V1``) erroneously being copied into the resulting buffer. 168ACPI firmware implementations should thus not return nested packages from ACPI methods 169associated with the ACPI-WMI interface. 170 171References 172========== 173 174.. [1] https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/driver-defined-wmi-data-items 175