Skip to contentSkip to conversation

ACPI: WMI: Add WMI-ACPI mapper driver

PATCH Superseded Carlos Corbacho 1 participant 1 message Oct 27, 2007 ACPI

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ACPI: WMI: Add WMI-ACPI mapper driver

From: Carlos Corbacho <[email protected]>

The following is an implementation of the Windows Management Instrumentation (WMI) ACPI interface mapper (PNP0C14).

What it does:

Parses the _WDG method and exports functions to process WMI method calls, data block query/ set commands (both based on GUID) and does basic event handling.

i.e.

wmi_evaluate_method(const char *guid, u32 instance, u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)

wmi_query_block(const char *guid, u32 instance,
struct acpi_buffer *out)

wmi_set_block(const char *guid, u32 instance,
const struct acpi_buffer *in)

It also provides a helper method to find if a GUID exists or not on the system (a quick and easy way for WMI dependant drivers to see if the the method/ block they want exists, since GUIDs are supposed to be unique).

i.e.

bool wmi_has_guid(const char guid*)

Where guid is the text encoding of the guid, e.g.:

"67C3371D-95A3-4C37-BB61-DD47B491DAAB"

What it might be able to do:

Handle reading data block GUIDs marked as "expensive" (e.g. calling WCxx with the correct arguments, before and after querying the block in question). My DSDT does not have any such marked block methods, so this is untested.

What it can't do:

Event data - Whilst the driver relays events over proc and netlink, it currently does not send any data with them.

(The MS article[1] talks about "firing a WMI event", in conjunction with the data from the _WED method - however, proc/ netlink expects an int for the data, whilst _WED can return anything - even a string).

Unicode - The MS article calls for converting between ASCII and Unicode (or vice versa) if a GUID is marked as "string". There is also another problem in that given this specification revolves around Windows, Unicode in this context likely means UTF-16. Since Linux doesn't use this, and since this driver will only be called by other Linux drivers, it may make more sense to treat Unicode here as UTF-8 instead.

What it doesn't do:

Try to enforce any kind of MOF 'types' on the data - it just takes and returns acpi_buffer - interpretation is left to the caller.

[1] http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

===
ChangeLog
==

v1 (2007-10-02):

Initial release

v2 (2007-10-05):

Cleaned up code - split up super "wmi_evaluate_block" -> each external symbol now handles its own ACPI calls, rather than handing off to a "super" method (and in turn, is a lot simpler to read)

Added a find_guid() symbol - return true if a given GUID exists on the system

wmi_* functions now return type acpi_status (since they are just fancy wrappers around acpi_evaluate_object())

Removed extra debug code

v3 (2007-10-27)

More code clean up - now passes checkpatch.pl

Change data block calls - ref MS spec, method ID is not required for them, so drop it from the function parameters.

Const'ify guid in the function call parameters.

Fix _WDG buffer handling - copy the data to our own private structure.

Change WMI from tristate to bool - otherwise the external functions are not exported in linux/acpi.h if you try to build WMI as a module.

Fix more flag comparisons.

Add a maintainers entry - since I wrote this, I should take the blame for it.

---
 MAINTAINERS           |    7 +
 drivers/acpi/Kconfig  |   11 +
 drivers/acpi/Makefile |    1 +
 drivers/acpi/wmi.c    |  537 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/acpi.h  |   14 ++
 5 files changed, 570 insertions(+), 0 deletions(-)
 create mode 100644 drivers/acpi/wmi.c
MAINTAINERS +7 -0
index 3ceeb56..1f4fda5 100644
@@ -261,6 +261,13 @@ L:	[email protected]
 W:	http://acpi.sourceforge.net/
 S:	Supported
 
+ACPI WMI DRIVER
+P:      Carlos Corbacho
+M:      [email protected]
+L:      [email protected]
+W:      http://www.lesswatts.org/projects/acpi/
+S:      Supported
+
 ADM1025 HARDWARE MONITOR DRIVER
 P:	Jean Delvare
 M:	[email protected]
drivers/acpi/Kconfig +11 -0
index 5d0e26a..ff9cf2a 100644
@@ -179,6 +179,17 @@ config ACPI_NUMA
 	depends on (X86 || IA64)
 	default y if IA64_GENERIC || IA64_SGI_SN2
 
+config ACPI_WMI
+	bool "WMI (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	default y
+	help
+	  This driver adds support for the WMI ACPI mapper device (PNP0C14)
+	  found on some systems.
+
+	  NOTE: You will need another driver on top of this to actually use
+	  anything defined in the WMI ACPI device.
+
 config ACPI_ASUS
         tristate "ASUS/Medion Laptop Extras"
 	depends on X86
drivers/acpi/Makefile +1 -0
index 54e3ab0..9e9aa39 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
 obj-$(CONFIG_ACPI_SYSTEM)	+= system.o event.o
 obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
 obj-$(CONFIG_ACPI_NUMA)		+= numa.o
+obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
 obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
drivers/acpi/wmi.c new file +537 -0

537 lines not on this page · raw message

include/linux/acpi.h +14 -0
index 8ccedf7..b1fb82f 100644
@@ -186,6 +186,20 @@ extern int ec_transaction(u8 command,
 
 #endif /*CONFIG_ACPI_EC*/
 
+#ifdef CONFIG_ACPI_WMI
+
+extern acpi_status wmi_evaluate_method(const char *guid, u32 instance,
+					u32 method_id,
+					const struct acpi_buffer *in,
+					struct acpi_buffer *out);
+extern acpi_status wmi_query_block(const char *guid, u32 instance,
+					struct acpi_buffer *out);
+extern acpi_status wmi_set_block(const char *guid, u32 instance,
+					const struct acpi_buffer *in);
+extern bool wmi_has_guid(const char *guid);
+
+#endif	/* CONFIG_ACPI_WMI */
+
 extern int acpi_blacklisted(void);
 extern void acpi_bios_year(char *s);
 
Signature · 1 line
1.5.3.4