From ca78bcd73b8d97228aa3a46d4cf9eac2a5c515cd Mon Sep 17 00:00:00 2001 From: Takanori Watanabe Date: Fri, 6 Sep 2019 10:12:05 +0000 Subject: [PATCH] Add embedded Managed Object Format blob access to acpi_wmi(4). This blob is can be converted to human readable form by bmfdec. (http://github.com/pali/bmfdec) Differential Revision: https://reviews.freebsd.org/D21529 --- share/man/man4/acpi_wmi.4 | 28 +++++++++++++++++++++++++++- sys/dev/acpi_support/acpi_wmi.c | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/share/man/man4/acpi_wmi.4 b/share/man/man4/acpi_wmi.4 index 1eba57553fa9..b6bf0da4f250 100644 --- a/share/man/man4/acpi_wmi.4 +++ b/share/man/man4/acpi_wmi.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 22, 2011 +.Dd Sep 5, 2019 .Dt ACPI_WMI 4 .Os .Sh NAME @@ -56,6 +56,15 @@ information about GUIDs found in the system. .It Pa /dev/wmistat%d WMI status device. .El +.Sh SYSCTLS +The following sysctl node is currently implemented: +.Bl -tag +.It Va dev.acpi_wmi.%d.bmof +Managed Object Format (MOF) blob. +You can obtain human readable output by bmf2mof in bmfdec tool. +(https://github.com/pali/bmfdec) +.El + .Sh EXAMPLES .Bd -literal # cat /dev/wmistat0 @@ -72,6 +81,20 @@ GUID INST EXPE METH STR EVENT OID {8232DE3D-663D-4327-A8F4-E293ADB9BF05} 0 NO NO NO NO BG {8F1F6436-9F42-42C8-BADC-0E9424F20C9A} 0 NO NO NO NO BH {8F1F6435-9F42-42C8-BADC-0E9424F20C9A} 0 NO NO NO NO BI +# sysctl -b dev.acpi_wmi.0.bmof |bmf2mof +[abstract] +class Lenovo_BIOSElement { +}; + +[WMI, Dynamic, Provider("WMIProv"), WmiExpense(1), Description("Bios Setting"), +GUID("{51F5230E-9677-46cd-A1CF-C0B23EE34DB7}"), Locale("MS\\0x409")] +class Lenovo_BiosSetting : Lenovo_BiosElement { + [key, read] String InstanceName; + [read] Boolean Active; + [WmiDataId(1), Description("BIOS setting")] String CurrentSetting; + }; + ... + .Ed .Sh SEE ALSO .Xr acpi 4 @@ -92,5 +115,8 @@ Work has been inspired by the Linux acpi-wmi driver written by Carlos Corbacho. See http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx for the specification of ACPI-WMI. .Pp +MOF part has been inspired by the Linux wmi-bmof driver +written by Andy Lutomirski. +.Pp This manual page was written by .An Michael Gmelin Aq Mt freebsd@grem.de . diff --git a/sys/dev/acpi_support/acpi_wmi.c b/sys/dev/acpi_support/acpi_wmi.c index bda7137881a7..c614be55ad74 100644 --- a/sys/dev/acpi_support/acpi_wmi.c +++ b/sys/dev/acpi_support/acpi_wmi.c @@ -62,6 +62,7 @@ ACPI_MODULE_NAME("ACPI_WMI"); #define ACPI_WMI_REGFLAG_METHOD 0x2 /* GUID flag: Method call */ #define ACPI_WMI_REGFLAG_STRING 0x4 /* GUID flag: String */ #define ACPI_WMI_REGFLAG_EVENT 0x8 /* GUID flag: Event */ +#define ACPI_WMI_BMOF_UUID "05901221-D566-11D1-B2F0-00A0C9062910" /* * acpi_wmi driver private structure @@ -74,6 +75,8 @@ struct acpi_wmi_softc { struct sbuf wmistat_sbuf; /* sbuf for /dev/wmistat output */ pid_t wmistat_open_pid; /* pid operating on /dev/wmistat */ int wmistat_bufptr; /* /dev/wmistat ptr to buffer position */ + char *mofbuf; + TAILQ_HEAD(wmi_info_list_head, wmi_info) wmi_info_list; }; @@ -274,6 +277,29 @@ acpi_wmi_attach(device_t dev) } ACPI_SERIAL_END(acpi_wmi); + if (acpi_wmi_provides_guid_string_method(dev, ACPI_WMI_BMOF_UUID)) { + ACPI_BUFFER out = { ACPI_ALLOCATE_BUFFER, NULL }; + ACPI_OBJECT *obj; + + device_printf(dev, "Embedded MOF found\n"); + status = acpi_wmi_get_block_method(dev, ACPI_WMI_BMOF_UUID, + 0, &out); + if (ACPI_SUCCESS(status)) { + obj = out.Pointer; + if (obj && obj->Type == ACPI_TYPE_BUFFER) { + SYSCTL_ADD_OPAQUE(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN( + device_get_sysctl_tree(dev)), + OID_AUTO, "bmof", + CTLFLAG_RD | CTLFLAG_MPSAFE, + obj->Buffer.Pointer, + obj->Buffer.Length, + "A", "MOF Blob"); + } + } + sc->mofbuf = out.Pointer; + } + if (ret == 0) { bus_generic_probe(dev); ret = bus_generic_attach(dev); @@ -321,6 +347,7 @@ acpi_wmi_detach(device_t dev) sc->wmistat_open_pid = 0; destroy_dev(sc->wmistat_dev_t); ret = 0; + AcpiOsFree(sc->mofbuf); } ACPI_SERIAL_END(acpi_wmi);