]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
tools/firmware: add ACPI device for Windows laptop/slate mode switch
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 28 Mar 2017 08:42:26 +0000 (09:42 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 29 Mar 2017 17:27:31 +0000 (18:27 +0100)
Microsoft have defined an ACPI device to support switching Windows 10
between laptop/desktop mode and slate/tablet mode [1].

This patch adds an SSDT containing such a device. The presence of the
device is controlled by a new 'acpi_laptop_slate' boolean in xl.cfg.
The new device will not be present by default.

[1] https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design/device-experiences/continuum

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
docs/man/xl.cfg.pod.5.in
tools/firmware/hvmloader/util.c
tools/libacpi/Makefile
tools/libacpi/build.c
tools/libacpi/libacpi.h
tools/libacpi/ssdt_laptop_slate.asl [new file with mode: 0644]
tools/libxl/libxl.h
tools/libxl/libxl_create.c
tools/libxl/libxl_types.idl
tools/xl/xl_parse.c

index 991960b64becbc40ddd6a7a3df7ba3c296ec34f0..24a2f6e0ce23b480bc231b567795ca3da8d089c7 100644 (file)
@@ -1256,6 +1256,11 @@ ACPI table. True (1) by default.
 Include S4 (suspend-to-disk) power state in the virtual firmware ACPI
 table. True (1) by default.
 
+=item B<acpi_laptop_slate=BOOLEAN>
+
+Include the Windows laptop/slate mode switch device in the virtual
+firmware ACPI table. False (0) by default.
+
 =item B<apic=BOOLEAN>
 
 Include information regarding APIC (Advanced Programmable Interrupt
index 03cfb795d38834f9150370c6bf3da56ee1eda624..db5f240bb9c7631dc265677e3adf71896266f261 100644 (file)
@@ -947,6 +947,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
         config->table_flags |= ACPI_HAS_SSDT_S3;
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
+    if ( !strncmp(xenstore_read("platform/acpi_laptop_slate", "0"), "1", 1)  )
+        config->table_flags |= ACPI_HAS_SSDT_LAPTOP_SLATE;
 
     config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC |
                             ACPI_HAS_WAET | ACPI_HAS_PMTIMER |
index 6d8445d77a3bc063330d3fd2f983fad956986310..fd7af1bc2b5c9f2171d252118f36186dd8a7ffe3 100644 (file)
@@ -25,7 +25,7 @@ C_SRC-$(CONFIG_X86) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c dsdt_pvh
 C_SRC-$(CONFIG_ARM_64) = dsdt_anycpu_arm.c
 DSDT_FILES ?= $(C_SRC-y)
 C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, $(DSDT_FILES))
-H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
+H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h ssdt_laptop_slate.h)
 
 MKDSDT_CFLAGS-$(CONFIG_ARM_64) = -DCONFIG_ARM_64
 MKDSDT_CFLAGS-$(CONFIG_X86) = -DCONFIG_X86
@@ -89,7 +89,7 @@ iasl:
        @echo 
        @exit 1
 
-build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
+build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h ssdt_laptop_slate.h
 
 acpi.a: $(OBJS)
        $(AR) rc $@ $(OBJS)
index a02ffbf43cf4125548d6e0c2d97f214fb6982e54..f9881c96047ffa1a7f1ffd5eb65e424d5b5baca3 100644 (file)
@@ -20,6 +20,7 @@
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
+#include "ssdt_laptop_slate.h"
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
@@ -406,6 +407,16 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         printf("S4 disabled\n");
     }
 
+    if ( config->table_flags & ACPI_HAS_SSDT_LAPTOP_SLATE )
+    {
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_laptop_slate), 16);
+        if (!ssdt) return -1;
+        memcpy(ssdt, ssdt_laptop_slate, sizeof(ssdt_laptop_slate));
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt);
+    } else {
+        printf("CONV disabled\n");
+    }
+
     /* TPM TCPA and SSDT. */
     if ( (config->table_flags & ACPI_HAS_TCPA) &&
          (config->tis_hdr[0] == tis_signature[0]) &&
index 67bd67fa0ae742147a19de3ed51b636448549bda..2ed1ecfc8e3a88fe3ad362486ba5a44829a3bc8c 100644 (file)
 #ifndef __LIBACPI_H__
 #define __LIBACPI_H__
 
-#define ACPI_HAS_COM1        (1<<0)
-#define ACPI_HAS_COM2        (1<<1)
-#define ACPI_HAS_LPT1        (1<<2)
-#define ACPI_HAS_HPET        (1<<3)
-#define ACPI_HAS_SSDT_PM     (1<<4)
-#define ACPI_HAS_SSDT_S3     (1<<5)
-#define ACPI_HAS_SSDT_S4     (1<<6)
-#define ACPI_HAS_TCPA        (1<<7)
-#define ACPI_HAS_IOAPIC      (1<<8)
-#define ACPI_HAS_WAET        (1<<9)
-#define ACPI_HAS_PMTIMER     (1<<10)
-#define ACPI_HAS_BUTTONS     (1<<11)
-#define ACPI_HAS_VGA         (1<<12)
-#define ACPI_HAS_8042        (1<<13)
-#define ACPI_HAS_CMOS_RTC    (1<<14)
+#define ACPI_HAS_COM1              (1<<0)
+#define ACPI_HAS_COM2              (1<<1)
+#define ACPI_HAS_LPT1              (1<<2)
+#define ACPI_HAS_HPET              (1<<3)
+#define ACPI_HAS_SSDT_PM           (1<<4)
+#define ACPI_HAS_SSDT_S3           (1<<5)
+#define ACPI_HAS_SSDT_S4           (1<<6)
+#define ACPI_HAS_TCPA              (1<<7)
+#define ACPI_HAS_IOAPIC            (1<<8)
+#define ACPI_HAS_WAET              (1<<9)
+#define ACPI_HAS_PMTIMER           (1<<10)
+#define ACPI_HAS_BUTTONS           (1<<11)
+#define ACPI_HAS_VGA               (1<<12)
+#define ACPI_HAS_8042              (1<<13)
+#define ACPI_HAS_CMOS_RTC          (1<<14)
+#define ACPI_HAS_SSDT_LAPTOP_SLATE (1<<15)
 
 struct xen_vmemrange;
 struct acpi_numa {
diff --git a/tools/libacpi/ssdt_laptop_slate.asl b/tools/libacpi/ssdt_laptop_slate.asl
new file mode 100644 (file)
index 0000000..3e5fbd5
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * ssdt_conv.asl
+ *
+ * Copyright (c) 2017  Citrix Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+/*
+ * Windows laptop/slate mode device
+ *
+ * See https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design/device-experiences/continuum#method-2----use-the-injection-interface
+ */
+
+DefinitionBlock ("SSDT_LAPTOP_SLATE.aml", "SSDT", 2, "Xen", "HVM", 0)
+{
+    Device (CONV) {
+        Method (_HID, 0x0, NotSerialized) {
+            Return("ID9001")
+        }
+        Name (_CID, "PNP0C60")
+    }
+}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 833f866e49bf74292df06fa07479f47be95677bb..3fa7565bb2548a6879445238aa4fddde2ef7ec9f 100644 (file)
  */
 #define LIBXL_HAVE_VIRIDIAN_CRASH_CTL 1
 
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE indicates that
+ * libxl_domain_build_info has the u.hvm.acpi_laptop_slate field.
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
+
 /*
  * libxl ABI compatibility
  *
index b65c9716d1c93ade393a9043512e493bba9d4cfe..a2881d3b6bcea75988c8fa1cf948a7da088d5867 100644 (file)
@@ -313,6 +313,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
         libxl_defbool_setdefault(&b_info->u.hvm.acpi,               true);
         libxl_defbool_setdefault(&b_info->u.hvm.acpi_s3,            true);
         libxl_defbool_setdefault(&b_info->u.hvm.acpi_s4,            true);
+        libxl_defbool_setdefault(&b_info->u.hvm.acpi_laptop_slate,  false);
         libxl_defbool_setdefault(&b_info->u.hvm.nx,                 true);
         libxl_defbool_setdefault(&b_info->u.hvm.viridian,           false);
         libxl_defbool_setdefault(&b_info->u.hvm.hpet,               true);
@@ -458,6 +459,8 @@ int libxl__domain_build(libxl__gc *gc,
         localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0";
         localents[i++] = "platform/acpi_s4";
         localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0";
+        localents[i++] = "platform/acpi_laptop_slate";
+        localents[i++] = libxl_defbool_val(info->u.hvm.acpi_laptop_slate) ? "1" : "0";
         if (info->u.hvm.mmio_hole_memkb) {
             uint64_t max_ram_below_4g =
                 (1ULL << 32) - (info->u.hvm.mmio_hole_memkb << 10);
index 69e789a0ce5dd6327f2ee55f456db54135496ba0..fee78e717a9fb0074c7a669f68812962645f79ef 100644 (file)
@@ -508,6 +508,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("acpi",             libxl_defbool),
                                        ("acpi_s3",          libxl_defbool),
                                        ("acpi_s4",          libxl_defbool),
+                                       ("acpi_laptop_slate",libxl_defbool),
                                        ("nx",               libxl_defbool),
                                        ("viridian",         libxl_defbool),
                                        ("viridian_enable",  libxl_bitmap),
index b72f99059e895caab4a1ae46bd8b48048ad6fe50..c23c9518211541295e5f4cb04f12a761664531ee 100644 (file)
@@ -1065,6 +1065,7 @@ void parse_config_data(const char *config_source,
         xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0);
         xlu_cfg_get_defbool(config, "acpi_s3", &b_info->u.hvm.acpi_s3, 0);
         xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
+        xlu_cfg_get_defbool(config, "acpi_laptop_slate", &b_info->u.hvm.acpi_laptop_slate, 0);
         xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);
         xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
         xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);