Jelajahi Sumber

pc: add option to disable PS/2 mouse/keyboard

On some older software like Windows 7 installer, having both a PS/2
mouse and USB mouse results in only one device working property (which
might be a different device each boot). While the workaround to not use
a USB mouse with such software is valid, it creates an inconsistent
experience if the user wishes to always use a USB mouse.

This introduces a new machine property to inhibit the creation of the
i8042 PS/2 controller.
osy 3 tahun lalu
induk
melakukan
8f1617b581
2 mengubah file dengan 28 tambahan dan 2 penghapusan
  1. 26 2
      hw/i386/pc.c
  2. 2 0
      include/hw/i386/pc.h

+ 26 - 2
hw/i386/pc.c

@@ -1008,7 +1008,8 @@ static const MemoryRegionOps ioportF0_io_ops = {
     },
     },
 };
 };
 
 
-static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
+static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,
+                            bool create_i8042, bool no_vmport)
 {
 {
     int i;
     int i;
     DriveInfo *fd[MAX_FD];
     DriveInfo *fd[MAX_FD];
@@ -1030,6 +1031,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
         }
         }
     }
     }
 
 
+    if (!create_i8042) {
+        return;
+    }
+
     i8042 = isa_create_simple(isa_bus, "i8042");
     i8042 = isa_create_simple(isa_bus, "i8042");
     if (!no_vmport) {
     if (!no_vmport) {
         isa_create_simple(isa_bus, TYPE_VMPORT);
         isa_create_simple(isa_bus, TYPE_VMPORT);
@@ -1125,7 +1130,8 @@ void pc_basic_device_init(struct PCMachineState *pcms,
     i8257_dma_init(isa_bus, 0);
     i8257_dma_init(isa_bus, 0);
 
 
     /* Super I/O */
     /* Super I/O */
-    pc_superio_init(isa_bus, create_fdctrl, pcms->vmport != ON_OFF_AUTO_ON);
+    pc_superio_init(isa_bus, create_fdctrl, pcms->i8042_enabled,
+                    pcms->vmport != ON_OFF_AUTO_ON);
 }
 }
 
 
 void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
 void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
@@ -1506,6 +1512,20 @@ static void pc_machine_set_hpet(Object *obj, bool value, Error **errp)
     pcms->hpet_enabled = value;
     pcms->hpet_enabled = value;
 }
 }
 
 
+static bool pc_machine_get_i8042(Object *obj, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    return pcms->i8042_enabled;
+}
+
+static void pc_machine_set_i8042(Object *obj, bool value, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    pcms->i8042_enabled = value;
+}
+
 static bool pc_machine_get_default_bus_bypass_iommu(Object *obj, Error **errp)
 static bool pc_machine_get_default_bus_bypass_iommu(Object *obj, Error **errp)
 {
 {
     PCMachineState *pcms = PC_MACHINE(obj);
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -1616,6 +1636,7 @@ static void pc_machine_initfn(Object *obj)
     pcms->smbus_enabled = true;
     pcms->smbus_enabled = true;
     pcms->sata_enabled = true;
     pcms->sata_enabled = true;
     pcms->pit_enabled = true;
     pcms->pit_enabled = true;
+    pcms->i8042_enabled = true;
     pcms->max_fw_size = 8 * MiB;
     pcms->max_fw_size = 8 * MiB;
 #ifdef CONFIG_HPET
 #ifdef CONFIG_HPET
     pcms->hpet_enabled = true;
     pcms->hpet_enabled = true;
@@ -1744,6 +1765,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     object_class_property_add_bool(oc, "hpet",
     object_class_property_add_bool(oc, "hpet",
         pc_machine_get_hpet, pc_machine_set_hpet);
         pc_machine_get_hpet, pc_machine_set_hpet);
 
 
+    object_class_property_add_bool(oc, PC_MACHINE_I8042,
+        pc_machine_get_i8042, pc_machine_set_i8042);
+
     object_class_property_add_bool(oc, "default-bus-bypass-iommu",
     object_class_property_add_bool(oc, "default-bus-bypass-iommu",
         pc_machine_get_default_bus_bypass_iommu,
         pc_machine_get_default_bus_bypass_iommu,
         pc_machine_set_default_bus_bypass_iommu);
         pc_machine_set_default_bus_bypass_iommu);

+ 2 - 0
include/hw/i386/pc.h

@@ -46,6 +46,7 @@ typedef struct PCMachineState {
     bool sata_enabled;
     bool sata_enabled;
     bool pit_enabled;
     bool pit_enabled;
     bool hpet_enabled;
     bool hpet_enabled;
+    bool i8042_enabled;
     bool default_bus_bypass_iommu;
     bool default_bus_bypass_iommu;
     uint64_t max_fw_size;
     uint64_t max_fw_size;
 
 
@@ -62,6 +63,7 @@ typedef struct PCMachineState {
 #define PC_MACHINE_SMBUS            "smbus"
 #define PC_MACHINE_SMBUS            "smbus"
 #define PC_MACHINE_SATA             "sata"
 #define PC_MACHINE_SATA             "sata"
 #define PC_MACHINE_PIT              "pit"
 #define PC_MACHINE_PIT              "pit"
+#define PC_MACHINE_I8042            "i8042"
 #define PC_MACHINE_MAX_FW_SIZE      "max-fw-size"
 #define PC_MACHINE_MAX_FW_SIZE      "max-fw-size"
 /**
 /**
  * PCMachineClass:
  * PCMachineClass: