Author: takawata
Date: Fri Sep  6 10:12:05 2019
New Revision: 351930
URL: https://svnweb.freebsd.org/changeset/base/351930

Log:
  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

Modified:
  head/share/man/man4/acpi_wmi.4
  head/sys/dev/acpi_support/acpi_wmi.c

Modified: head/share/man/man4/acpi_wmi.4
==============================================================================
--- head/share/man/man4/acpi_wmi.4      Fri Sep  6 08:08:33 2019        
(r351929)
+++ head/share/man/man4/acpi_wmi.4      Fri Sep  6 10:12:05 2019        
(r351930)
@@ -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 S
 {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
@@ -91,6 +114,9 @@ Work has been inspired by the Linux acpi-wmi driver wr
 .Pp
 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 free...@grem.de .

Modified: head/sys/dev/acpi_support/acpi_wmi.c
==============================================================================
--- head/sys/dev/acpi_support/acpi_wmi.c        Fri Sep  6 08:08:33 2019        
(r351929)
+++ head/sys/dev/acpi_support/acpi_wmi.c        Fri Sep  6 10:12:05 2019        
(r351930)
@@ -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);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to