Skip to contentSkip to conversation

i386: expose floppy-related objects in SSDT

PATCH Superseded Roman Kagan 6 participants 23 messages Dec 30, 2015 – Jan 13, 2016

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 cover i386: expose floppy-related objects in SSDT

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH v5 1/6 i386/pc: expose identifying the floppy controller

Factor out and expose the function to locate the floppy controller in the system.
It will allow to dynamically populate the relevant objects in the ACPI tables.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
no changes since v4

changes since v3:
- split out into a separate patch to faciliate review

 hw/i386/pc.c         | 44 ++++++++++++++++++++++++++------------------
 include/hw/i386/pc.h |  2 ++
 2 files changed, 28 insertions(+), 18 deletions(-)
hw/i386/pc.c +26 -18
index 459260b..c36b8cf 100644
@@ -360,6 +360,31 @@ static const char * const fdc_container_path[] = {
     "/unattached", "/peripheral", "/peripheral-anon"
 };
 
+/*
+ * Locate the FDC at IO address 0x3f0, in order to configure the CMOS registers
+ * and ACPI objects.
+ */
+ISADevice *pc_find_fdc0(void)
+{
+    int i;
+    Object *container;
+    CheckFdcState state = { 0 };
+
+    for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
+        container = container_get(qdev_get_machine(), fdc_container_path[i]);
+        object_child_foreach(container, check_fdc, &state);
+    }
+
+    if (state.multiple) {
+        error_report("warning: multiple floppy disk controllers with "
+                     "iobase=0x3f0 have been found;\n"
+                     "the one being picked for CMOS setup might not reflect "
+                     "your intent");
+    }
+
+    return state.floppy;
+}
+
 static void pc_cmos_init_late(void *opaque)
 {
     pc_cmos_init_late_arg *arg = opaque;
@@ -368,8 +393,6 @@ static void pc_cmos_init_late(void *opaque)
     int8_t heads, sectors;
     int val;
     int i, trans;
-    Object *container;
-    CheckFdcState state = { 0 };
 
     val = 0;
     if (ide_get_geometry(arg->idebus[0], 0,
@@ -399,22 +422,7 @@ static void pc_cmos_init_late(void *opaque)
     }
     rtc_set_memory(s, 0x39, val);
 
-    /*
-     * Locate the FDC at IO address 0x3f0, and configure the CMOS registers
-     * accordingly.
-     */
-    for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
-        container = container_get(qdev_get_machine(), fdc_container_path[i]);
-        object_child_foreach(container, check_fdc, &state);
-    }
-
-    if (state.multiple) {
-        error_report("warning: multiple floppy disk controllers with "
-                     "iobase=0x3f0 have been found;\n"
-                     "the one being picked for CMOS setup might not reflect "
-                     "your intent");
-    }
-    pc_cmos_init_floppy(s, state.floppy);
+    pc_cmos_init_floppy(s, pc_find_fdc0());
 
     qemu_unregister_reset(pc_cmos_init_late, opaque);
 }
include/hw/i386/pc.h +2 -0
index b0d6283..8122229 100644
@@ -267,6 +267,8 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
 
 void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
+ISADevice *pc_find_fdc0(void);
+
 /* acpi_piix.c */
 
 I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
Signature · 1 line
2.5.0
#2 lore raw

PATCH v5 2/6 i386/acpi: make floppy controller object dynamic

In reply to Roman Kagan

Instead of statically declaring the floppy controller in DSDT, with its _STA method depending on some obscure bit in the parent ISA bridge, add the object dynamically to SSDT via AML API only when the controller is present.

The _STA method is no longer necessary and is therefore dropped. So are the declarations of the fields indicating whether the contoller is enabled.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split from test data update to facilitate review (bisectability not affected)

changes since v3:
- new patch (note that it conflicts with "[PATCH 50/74] pc: acpi: move FDC0 device from DSDT to SSDT" from Igor's series)
- include test data updates to maintain bisectability

 hw/i386/acpi-build.c      | 24 ++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl | 18 ------------------
 hw/i386/acpi-dsdt.dsl     |  1 -
 hw/i386/q35-acpi-dsdt.dsl |  7 ++-----
 4 files changed, 26 insertions(+), 24 deletions(-)
hw/i386/acpi-build.c +24 -0
index 4cc1440..a01e909 100644
@@ -113,6 +113,7 @@ typedef struct AcpiMiscInfo {
     unsigned dsdt_size;
     uint16_t pvpanic_port;
     uint16_t applesmc_io_base;
+    bool has_fdc;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -236,10 +237,15 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
 {
+    ISADevice *fdc;
+
     info->has_hpet = hpet_find();
     info->tpm_version = tpm_get_version();
     info->pvpanic_port = pvpanic_port();
     info->applesmc_io_base = applesmc_port();
+
+    fdc = pc_find_fdc0();
+    info->has_fdc = !!fdc;
 }
 
 /*
@@ -1099,6 +1105,24 @@ build_ssdt(GArray *table_data, GArray *linker,
     aml_append(scope, aml_name_decl("_S5", pkg));
     aml_append(ssdt, scope);
 
+    if (misc->has_fdc) {
+        scope = aml_scope("\\_SB.PCI0.ISA");
+        dev = aml_device("FDC0");
+
+        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700")));
+
+        crs = aml_resource_template();
+        aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04));
+        aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01));
+        aml_append(crs, aml_irq_no_flags(6));
+        aml_append(crs, aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER,
+                                AML_TRANSFER8, 2));
+        aml_append(dev, aml_name_decl("_CRS", crs));
+
+        aml_append(scope, dev);
+        aml_append(ssdt, scope);
+    }
+
     if (misc->applesmc_io_base) {
         scope = aml_scope("\\_SB.PCI0.ISA");
         dev = aml_device("SMC");
hw/i386/acpi-dsdt-isa.dsl +0 -18
index 89caa16..061507d 100644
@@ -47,24 +47,6 @@ Scope(\_SB.PCI0.ISA) {
         })
     }
 
-    Device(FDC0) {
-        Name(_HID, EisaId("PNP0700"))
-        Method(_STA, 0, NotSerialized) {
-            Store(FDEN, Local0)
-            If (LEqual(Local0, 0)) {
-                Return (0x00)
-            } Else {
-                Return (0x0F)
-            }
-        }
-        Name(_CRS, ResourceTemplate() {
-            IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
-            IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
-            IRQNoFlags() { 6 }
-            DMA(Compatibility, NotBusMaster, Transfer8) { 2 }
-        })
-    }
-
     Device(LPT) {
         Name(_HID, EisaId("PNP0400"))
         Method(_STA, 0, NotSerialized) {
hw/i386/acpi-dsdt.dsl +0 -1
index 8dba096..aa50990 100644
@@ -80,7 +80,6 @@ DefinitionBlock (
                 , 3,
                 CBEN, 1,         // COM2
             }
-            Name(FDEN, 1)
         }
     }
 
hw/i386/q35-acpi-dsdt.dsl +2 -5
index 7be7b37..fcb9915 100644
@@ -137,16 +137,13 @@ DefinitionBlock (
                 COMB,   3,
 
                 Offset(0x01),
-                LPTD,   2,
-                    ,   2,
-                FDCD,   2
+                LPTD,   2
             }
             OperationRegion(LPCE, PCI_Config, 0x82, 0x2)
             Field(LPCE, AnyAcc, NoLock, Preserve) {
                 CAEN,   1,
                 CBEN,   1,
-                LPEN,   1,
-                FDEN,   1
+                LPEN,   1
             }
         }
     }
Signature · 1 line
2.5.0
#3 lore raw

PATCH v5 3/6 tests/acpi: update test data

In reply to Roman Kagan

to match the preceding commit "i386/acpi: make floppy controller object dynamic".

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- new, split out from code changes

 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2554 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4413 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 4 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/DSDT binary +0 -0
index c658203db94a7e7db7c36fde99a7075a8d75498d..d8ebf12cc0abbbbe9f19d131c7b1d7d1b3e681df 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT binary +0 -0
index 210d6a71e58aa34ce8e94121d25bcf58c3bd503c..ffb3fe43970123d0e198328429ee04ebfd0564c9 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT.bridge binary +0 -0
index 6e6660b1fbe0bdb7fe0b257cb53c31fa9bb21a14..f0f11bec8108eceb696fb854b51faeb97471146c 100644
GIT binary patch
tests/acpi-test-data/q35/DSDT binary +0 -0
index 4723e5954dccb00995ccaf521b7daf6bf15cf1d4..5e03e26323d50dea63d57a36bd902e061e0442d8 100644
GIT binary patch
Signature · 1 line
2.5.0
#4 lore raw

PATCH v5 4/6 expose floppy drive geometry and CMOS type

In reply to Roman Kagan

Make it possible to query the geometry and the CMOS type of a floppy drive outside of the respective source files.

It will be useful, in particular, when dynamically building ACPI tables, and will allow to properly populate the corresponding ACPI objects and thus enable BIOS-less systems to access the floppy drives.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
no changes since v4

changes since v3:
- split out into a separate patch to faciliate review

 hw/block/fdc.c         | 11 +++++++++++
 hw/i386/pc.c           |  2 +-
 include/hw/block/fdc.h |  2 ++
 include/hw/i386/pc.h   |  1 +
 4 files changed, 15 insertions(+), 1 deletion(-)
hw/block/fdc.c +11 -0
index 4292ece..c858c5f 100644
@@ -2408,6 +2408,17 @@ FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
     return isa->state.drives[i].drive;
 }
 
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors)
+{
+    FDCtrlISABus *isa = ISA_FDC(fdc);
+    FDrive *drv = &isa->state.drives[i];
+
+    *cylinders = drv->max_track;
+    *heads = (drv->flags & FDISK_DBL_SIDES) ? 2 : 1;
+    *sectors = drv->last_sect;
+}
+
 static const VMStateDescription vmstate_isa_fdc ={
     .name = "fdc",
     .version_id = 2,
hw/i386/pc.c +1 -1
index c36b8cf..99fab83 100644
@@ -199,7 +199,7 @@ static void pic_irq_request(void *opaque, int irq, int level)
 
 #define REG_EQUIPMENT_BYTE          0x14
 
-static int cmos_get_fd_drive_type(FDriveType fd0)
+int cmos_get_fd_drive_type(FDriveType fd0)
 {
     int val;
 
include/hw/block/fdc.h +2 -0
index d48b2f8..adaf3dc 100644
@@ -22,5 +22,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                        DriveInfo **fds, qemu_irq *fdc_tc);
 
 FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i);
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors);
 
 #endif
include/hw/i386/pc.h +1 -0
index 8122229..d044a9a 100644
@@ -268,6 +268,7 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
 void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
 ISADevice *pc_find_fdc0(void);
+int cmos_get_fd_drive_type(FDriveType fd0);
 
 /* acpi_piix.c */
 
Signature · 1 line
2.5.0
Reviewed-by on v5 4/6
#5 lore raw

Re: [Qemu-devel] [PATCH v5 4/6] expose floppy drive geometry and CMOS type

Quoted 82 lines · Roman Kagan

Make it possible to query the geometry and the CMOS type of a floppy drive outside of the respective source files.

It will be useful, in particular, when dynamically building ACPI tables, and will allow to properly populate the corresponding ACPI objects and thus enable BIOS-less systems to access the floppy drives.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
no changes since v4

changes since v3:
- split out into a separate patch to faciliate review

 hw/block/fdc.c         | 11 +++++++++++
 hw/i386/pc.c           |  2 +-
 include/hw/block/fdc.h |  2 ++
 include/hw/i386/pc.h   |  1 +
 4 files changed, 15 insertions(+), 1 deletion(-)
hw/block/fdc.c +11 -0
index 4292ece..c858c5f 100644
@@ -2408,6 +2408,17 @@ FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
     return isa->state.drives[i].drive;
 }
 
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors)
+{
+    FDCtrlISABus *isa = ISA_FDC(fdc);
+    FDrive *drv = &isa->state.drives[i];
+
+    *cylinders = drv->max_track;
+    *heads = (drv->flags & FDISK_DBL_SIDES) ? 2 : 1;
+    *sectors = drv->last_sect;
+}
+
 static const VMStateDescription vmstate_isa_fdc ={
     .name = "fdc",
     .version_id = 2,
hw/i386/pc.c +1 -1
index c36b8cf..99fab83 100644
@@ -199,7 +199,7 @@ static void pic_irq_request(void *opaque, int irq, int level)
 
 #define REG_EQUIPMENT_BYTE          0x14
 
-static int cmos_get_fd_drive_type(FDriveType fd0)
+int cmos_get_fd_drive_type(FDriveType fd0)
 {
     int val;
 
include/hw/block/fdc.h +2 -0
index d48b2f8..adaf3dc 100644
@@ -22,5 +22,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                        DriveInfo **fds, qemu_irq *fdc_tc);
 
 FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i);
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors);
 
 #endif
include/hw/i386/pc.h +0 -0
index 8122229..d044a9a 100644

include/hw/i386/pc.h typedef void (*cpu_set_smm_t)(int smm, void *arg); · line 274

Quoted 7 lines
include/hw/i386/pc.h +1 -0
@@ -268,6 +268,7 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
 void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
 ISADevice *pc_find_fdc0(void);
+int cmos_get_fd_drive_type(FDriveType fd0);
 
 /* acpi_piix.c */
 

Patches 1,4:

Aside: Why did they have you split out the test changes to be separate from the code? Doesn't that introduce commits where the tests now fail?

--js

#6 lore raw

Re: [Qemu-devel] [PATCH v5 4/6] expose floppy drive geometry and CMOS type

Quoted 95 lines · John Snow
Quoted 82 lines · Roman Kagan

Make it possible to query the geometry and the CMOS type of a floppy drive outside of the respective source files.

It will be useful, in particular, when dynamically building ACPI tables, and will allow to properly populate the corresponding ACPI objects and thus enable BIOS-less systems to access the floppy drives.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
no changes since v4

changes since v3:
- split out into a separate patch to faciliate review

 hw/block/fdc.c         | 11 +++++++++++
 hw/i386/pc.c           |  2 +-
 include/hw/block/fdc.h |  2 ++
 include/hw/i386/pc.h   |  1 +
 4 files changed, 15 insertions(+), 1 deletion(-)
hw/block/fdc.c +11 -0
index 4292ece..c858c5f 100644
@@ -2408,6 +2408,17 @@ FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
     return isa->state.drives[i].drive;
 }
 
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors)
+{
+    FDCtrlISABus *isa = ISA_FDC(fdc);
+    FDrive *drv = &isa->state.drives[i];
+
+    *cylinders = drv->max_track;
+    *heads = (drv->flags & FDISK_DBL_SIDES) ? 2 : 1;
+    *sectors = drv->last_sect;
+}
+
 static const VMStateDescription vmstate_isa_fdc ={
     .name = "fdc",
     .version_id = 2,
hw/i386/pc.c +1 -1
index c36b8cf..99fab83 100644
@@ -199,7 +199,7 @@ static void pic_irq_request(void *opaque, int irq, int level)
 
 #define REG_EQUIPMENT_BYTE          0x14
 
-static int cmos_get_fd_drive_type(FDriveType fd0)
+int cmos_get_fd_drive_type(FDriveType fd0)
 {
     int val;
 
include/hw/block/fdc.h +2 -0
index d48b2f8..adaf3dc 100644
@@ -22,5 +22,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                        DriveInfo **fds, qemu_irq *fdc_tc);
 
 FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i);
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors);
 
 #endif
include/hw/i386/pc.h +0 -0
index 8122229..d044a9a 100644

include/hw/i386/pc.h typedef void (*cpu_set_smm_t)(int smm, void *arg); · line 274

Quoted 7 lines
include/hw/i386/pc.h +1 -0
@@ -268,6 +268,7 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
 void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
 ISADevice *pc_find_fdc0(void);
+int cmos_get_fd_drive_type(FDriveType fd0);
 
 /* acpi_piix.c */
 

Patches 1,4:

Quoted 6 lines

Aside: Why did they have you split out the test changes to be separate from the code? Doesn't that introduce commits where the tests now fail?

--js

It's only a warning not a failure.

#7 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH v5 4/6] expose floppy drive geometry and CMOS type

In reply to John Snow
Quoted 93 lines · John Snow
Quoted 82 lines · Roman Kagan

Make it possible to query the geometry and the CMOS type of a floppy drive outside of the respective source files.

It will be useful, in particular, when dynamically building ACPI tables, and will allow to properly populate the corresponding ACPI objects and thus enable BIOS-less systems to access the floppy drives.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
no changes since v4

changes since v3:
- split out into a separate patch to faciliate review

  hw/block/fdc.c         | 11 +++++++++++
  hw/i386/pc.c           |  2 +-
  include/hw/block/fdc.h |  2 ++
  include/hw/i386/pc.h   |  1 +
  4 files changed, 15 insertions(+), 1 deletion(-)
hw/block/fdc.c +11 -0
index 4292ece..c858c5f 100644
@@ -2408,6 +2408,17 @@ FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
      return isa->state.drives[i].drive;
  }
 
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors)
+{
+    FDCtrlISABus *isa = ISA_FDC(fdc);
+    FDrive *drv = &isa->state.drives[i];
+
+    *cylinders = drv->max_track;
+    *heads = (drv->flags & FDISK_DBL_SIDES) ? 2 : 1;
+    *sectors = drv->last_sect;
+}
+
  static const VMStateDescription vmstate_isa_fdc ={
      .name = "fdc",
      .version_id = 2,
hw/i386/pc.c +1 -1
index c36b8cf..99fab83 100644
@@ -199,7 +199,7 @@ static void pic_irq_request(void *opaque, int irq, int level)
 
  #define REG_EQUIPMENT_BYTE          0x14
 
-static int cmos_get_fd_drive_type(FDriveType fd0)
+int cmos_get_fd_drive_type(FDriveType fd0)
  {
      int val;
 
include/hw/block/fdc.h +2 -0
index d48b2f8..adaf3dc 100644
@@ -22,5 +22,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                         DriveInfo **fds, qemu_irq *fdc_tc);
 
  FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i);
+void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders,
+                                uint8_t *heads, uint8_t *sectors);
 
  #endif
include/hw/i386/pc.h +0 -0
index 8122229..d044a9a 100644

include/hw/i386/pc.h typedef void (*cpu_set_smm_t)(int smm, void *arg); · line 274

Quoted 7 lines
include/hw/i386/pc.h +1 -0
@@ -268,6 +268,7 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
  void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
  ISADevice *pc_find_fdc0(void);
+int cmos_get_fd_drive_type(FDriveType fd0);
 
  /* acpi_piix.c */
 

Patches 1,4:

Quoted 7 lines

Aside: Why did they have you split out the test changes to be separate from the code? Doesn't that introduce commits where the tests now fail?

--js

this would make merge process to downstream simplear.

Den

#8 lore raw

PATCH v5 5/6 i386: populate floppy drive information in SSDT

In reply to Roman Kagan

On x86-based systems Linux determines the presence and the type of floppy drives via a query of a CMOS field. So does SeaBIOS when populating the return data for int 0x13 function 0x08.

Windows doesn't; instead, it requests this information from BIOS via int 0x13/0x08 or through ACPI objects _FDE (Floppy Drive Enumerate) and _FDI (Floppy Drive Information) of the floppy controller object. On UEFI systems only ACPI-based detection is supported.

QEMU used not to provide those objects in its ACPI tables; as a result floppy drives were invisible to Windows on UEFI/OVMF.

This patch adds those objects to the floppy controller in SSDT, populating them with the information from the respective QEMU objects.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- build on top of dynamic FDC0 patch
- include test data updates to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset

 hw/i386/acpi-build.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
hw/i386/acpi-build.c +68 -0
index a01e909..7b8de59 100644
@@ -38,6 +38,7 @@
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/loader.h"
 #include "hw/isa/isa.h"
+#include "hw/block/fdc.h"
 #include "hw/acpi/memory_hotplug.h"
 #include "hw/mem/nvdimm.h"
 #include "sysemu/tpm.h"
@@ -106,6 +107,13 @@ typedef struct AcpiPmInfo {
     uint16_t pcihp_io_len;
 } AcpiPmInfo;
 
+typedef struct AcpiFDInfo {
+    uint8_t type;
+    uint8_t cylinders;
+    uint8_t heads;
+    uint8_t sectors;
+} AcpiFDInfo;
+
 typedef struct AcpiMiscInfo {
     bool has_hpet;
     TPMVersion tpm_version;
@@ -114,6 +122,7 @@ typedef struct AcpiMiscInfo {
     uint16_t pvpanic_port;
     uint16_t applesmc_io_base;
     bool has_fdc;
+    AcpiFDInfo fdinfo[2];
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -237,6 +246,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
 {
+    int i;
     ISADevice *fdc;
 
     info->has_hpet = hpet_find();
@@ -246,6 +256,16 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
 
     fdc = pc_find_fdc0();
     info->has_fdc = !!fdc;
+    if (fdc) {
+        for (i = 0; i < ARRAY_SIZE(info->fdinfo); i++) {
+            AcpiFDInfo *fdinfo = &info->fdinfo[i];
+            fdinfo->type = isa_fdc_get_drive_type(fdc, i);
+            if (fdinfo->type < FDRIVE_DRV_NONE) {
+                isa_fdc_get_drive_geometry(fdc, i, &fdinfo->cylinders,
+                                           &fdinfo->heads, &fdinfo->sectors);
+            }
+        }
+    }
 }
 
 /*
@@ -935,6 +955,40 @@ static Aml *build_crs(PCIHostState *host,
     return crs;
 }
 
+static Aml *build_fdinfo_aml(int idx, AcpiFDInfo *fdinfo)
+{
+    Aml *dev, *fdi;
+
+    dev = aml_device("FLP%c", 'A' + idx);
+
+    aml_append(dev, aml_name_decl("_ADR", aml_int(idx)));
+
+    fdi = aml_package(0x10);
+    aml_append(fdi, aml_int(idx));  /* Drive Number */
+    aml_append(fdi,
+        aml_int(cmos_get_fd_drive_type(fdinfo->type)));  /* Device Type */
+    aml_append(fdi,
+        aml_int(fdinfo->cylinders - 1));  /* Maximum Cylinder Number */
+    aml_append(fdi, aml_int(fdinfo->sectors));  /* Maximum Sector Number */
+    aml_append(fdi, aml_int(fdinfo->heads - 1));  /* Maximum Head Number */
+    /* SeaBIOS returns the below values for int 0x13 func 0x08 regardless of
+     * the drive type, so shall we */
+    aml_append(fdi, aml_int(0xAF));  /* disk_specify_1 */
+    aml_append(fdi, aml_int(0x02));  /* disk_specify_2 */
+    aml_append(fdi, aml_int(0x25));  /* disk_motor_wait */
+    aml_append(fdi, aml_int(0x02));  /* disk_sector_siz */
+    aml_append(fdi, aml_int(0x12));  /* disk_eot */
+    aml_append(fdi, aml_int(0x1B));  /* disk_rw_gap */
+    aml_append(fdi, aml_int(0xFF));  /* disk_dtl */
+    aml_append(fdi, aml_int(0x6C));  /* disk_formt_gap */
+    aml_append(fdi, aml_int(0xF6));  /* disk_fill */
+    aml_append(fdi, aml_int(0x0F));  /* disk_head_sttl */
+    aml_append(fdi, aml_int(0x08));  /* disk_motor_strt */
+
+    aml_append(dev, aml_name_decl("_FDI", fdi));
+    return dev;
+}
+
 static void
 build_ssdt(GArray *table_data, GArray *linker,
            AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1106,6 +1160,8 @@ build_ssdt(GArray *table_data, GArray *linker,
     aml_append(ssdt, scope);
 
     if (misc->has_fdc) {
+        uint32_t fde_buf[5] = {0, 0, 0, 0, cpu_to_le32(0x2)};
+
         scope = aml_scope("\\_SB.PCI0.ISA");
         dev = aml_device("FDC0");
 
@@ -1119,6 +1175,18 @@ build_ssdt(GArray *table_data, GArray *linker,
                                 AML_TRANSFER8, 2));
         aml_append(dev, aml_name_decl("_CRS", crs));
 
+        for (i = 0; i < ARRAY_SIZE(misc->fdinfo); i++) {
+            AcpiFDInfo *fdinfo = &misc->fdinfo[i];
+            if (fdinfo->type != FDRIVE_DRV_NONE) {
+                fde_buf[i] = cpu_to_le32(0x1);
+                aml_append(dev, build_fdinfo_aml(i, fdinfo));
+            }
+        }
+
+        aml_append(dev,
+            aml_name_decl("_FDE",
+                aml_buffer(sizeof(fde_buf), (uint8_t *) fde_buf)));
+
         aml_append(scope, dev);
         aml_append(ssdt, scope);
     }
Signature · 1 line
2.5.0
#9 lore raw

PATCH v5 6/6 tests/acpi: update test data

In reply to Roman Kagan

to match the preceding commit "i386: populate floppy drive information in SSDT".

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- new, split out from code changes

 tests/acpi-test-data/pc/SSDT        | Bin 2554 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4413 -> 4494 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/SSDT binary +0 -0
index ffb3fe43970123d0e198328429ee04ebfd0564c9..5e70e0b5989bb8c85a14bd0902f32dd48eb17602 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT.bridge binary +0 -0
index f0f11bec8108eceb696fb854b51faeb97471146c..642d9a51203cc591a61b2169b2feb5731ad67a96 100644
GIT binary patch
Signature · 1 line
2.5.0
Reviewed-by on the v5 series
#10 lore raw
In reply to Roman Kagan
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Tested with XPsp3 WS2008R2 WS2012R2, no regressions so far it boots fine and can read floppy.

So for whole series:

Quoted 47 lines

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#11 lore raw
Quoted 15 lines · Igor Mammedov
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Quoted 5 lines

Tested with XPsp3 WS2008R2 WS2012R2, no regressions so far it boots fine and can read floppy.

So for whole series:

Igor, could you pls rebase this on top of your patches? I've merged them in my tree.

Quoted 47 lines
Quoted 47 lines

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#12 lore raw
Quoted 16 lines · Michael S. Tsirkin
Quoted 15 lines · Igor Mammedov
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Quoted 8 lines
Quoted 5 lines

Tested with XPsp3 WS2008R2 WS2012R2, no regressions so far it boots fine and can read floppy.

So for whole series:

Igor, could you pls rebase this on top of your patches? I've merged them in my tree.

Pls remember to keep the author information intact though.

Quoted 47 lines
Quoted 47 lines
Quoted 47 lines

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#13 lore raw
Quoted 19 lines · On Thu, 7 Jan 2016 12:56:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Igor Mammedov
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Tested with XPsp3 WS2008R2 WS2012R2, no regressions so far it boots fine and can read floppy.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

So for whole series:

Igor, could you pls rebase this on top of your patches? I've merged them in my tree.

Pls remember to keep the author information intact though.

Sure,
I'll usually do it or when in doubt I just ask original authors before changing it.

Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#14 lore raw
In reply to Michael S. Tsirkin
Quoted 16 lines · On Thu, 7 Jan 2016 12:56:09 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Quoted 8 lines
Quoted 5 lines

Tested with XPsp3 WS2008R2 WS2012R2, no regressions so far it boots fine and can read floppy.

So for whole series:

Igor, could you pls rebase this on top of your patches? I've merged them in my tree.

I don't see updates to pci tree,
Have you pushed it from local host?

Quoted 49 lines
Quoted 48 lines
Quoted 48 lines

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#15 lore raw
In reply to Roman Kagan
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Hello Roman,

I've rebased/rewrote this series on top of current PCI tree. Could you tell me if I should keep your Author/SoB on following patches or change/drop it and if it's the case please specify what should be changed:

i386/acpi: make floppy controller object dynamic

      https://github.com/imammedo/qemu/commit/f0a3a4761f8f9698d0f0117d47e2353505de37bf
  i386: populate floppy drive information in DSDT
      https://github.com/imammedo/qemu/commit/97578d32e0a0b1cea0b6229f5ef51f8e104b7fdb
Quoted 48 lines

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#16 lore raw
Quoted 23 lines · Igor Mammedov
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Hello Roman,

I've rebased/rewrote this series on top of current PCI tree. Could you tell me if I should keep your Author/SoB on following patches or change/drop it and if it's the case please specify what should be changed:

Quoted 4 lines

i386/acpi: make floppy controller object dynamic

      https://github.com/imammedo/qemu/commit/f0a3a4761f8f9698d0f0117d47e2353505de37bf
  i386: populate floppy drive information in DSDT
      https://github.com/imammedo/qemu/commit/97578d32e0a0b1cea0b6229f5ef51f8e104b7fdb

Both patches look good to me (I just noticed an excessive "to" in the log message of the second one, in "QEMU doesn't _to_ provide those objects in its ACPI tables", you may want to delete it before propagating the patch upstream).

Now what are the plans re. stable branches? I think the problem of the floppy being unavaliable in Windows on UEFI/OVMF justifies porting it there (we are interested, in particular, in stable-2.3), but I'm now confused as to what state to use as the base.

(As a matter of fact I'd been hoping that my patches made it in before your dynamic DSDT rework so the backport would be trivial cherry-pick; as this is no longer the case I'd appreciate your (or anybody else's) advice on how to move on with stable.)

Thanks,
Roman.

#17 lore raw
Quoted 29 lines · On Mon, 11 Jan 2016 17:26:26 +0300 Roman Kagan <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Quoted 11 lines · On Wed, 30 Dec 2015 23:11:50 +0300 Roman Kagan <[email protected]> wrote:

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Hello Roman,

I've rebased/rewrote this series on top of current PCI tree. Could you tell me if I should keep your Author/SoB on following patches or change/drop it and if it's the case please specify what should be changed:

Quoted 4 lines

i386/acpi: make floppy controller object dynamic

      https://github.com/imammedo/qemu/commit/f0a3a4761f8f9698d0f0117d47e2353505de37bf
  i386: populate floppy drive information in DSDT
      https://github.com/imammedo/qemu/commit/97578d32e0a0b1cea0b6229f5ef51f8e104b7fdb  
Quoted 4 lines

Both patches look good to me (I just noticed an excessive "to" in the log message of the second one, in "QEMU doesn't _to_ provide those objects in its ACPI tables", you may want to delete it before propagating the patch upstream).

Just to confirm, so you are agree with me keeping you as Author on above patches and your SoB on them as well?

Quoted 9 lines

Now what are the plans re. stable branches? I think the problem of the floppy being unavaliable in Windows on UEFI/OVMF justifies porting it there (we are interested, in particular, in stable-2.3), but I'm now confused as to what state to use as the base.

(As a matter of fact I'd been hoping that my patches made it in before your dynamic DSDT rework so the backport would be trivial cherry-pick; as this is no longer the case I'd appreciate your (or anybody else's) advice on how to move on with stable.)

Stable could use reviewed v5 if Michael agrees to take fix.

Quoted 3 lines

Thanks,
Roman.

#18 lore raw
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Mon, 11 Jan 2016 17:26:26 +0300 Roman Kagan <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov

I've rebased/rewrote this series on top of current PCI tree. Could you tell me if I should keep your Author/SoB on following patches or change/drop it and if it's the case please specify what should be changed:

i386/acpi: make floppy controller object dynamic

      https://github.com/imammedo/qemu/commit/f0a3a4761f8f9698d0f0117d47e2353505de37bf
  i386: populate floppy drive information in DSDT
      https://github.com/imammedo/qemu/commit/97578d32e0a0b1cea0b6229f5ef51f8e104b7fdb  
Quoted 6 lines
Quoted 4 lines

Both patches look good to me (I just noticed an excessive "to" in the log message of the second one, in "QEMU doesn't _to_ provide those objects in its ACPI tables", you may want to delete it before propagating the patch upstream).

Just to confirm, so you are agree with me keeping you as Author on above patches and your SoB on them as well?

Yes, sure. Sorry I haven't made it clear.

Quoted 10 lines
Quoted 9 lines

Now what are the plans re. stable branches? I think the problem of the floppy being unavaliable in Windows on UEFI/OVMF justifies porting it there (we are interested, in particular, in stable-2.3), but I'm now confused as to what state to use as the base.

(As a matter of fact I'd been hoping that my patches made it in before your dynamic DSDT rework so the backport would be trivial cherry-pick; as this is no longer the case I'd appreciate your (or anybody else's) advice on how to move on with stable.)

Stable could use reviewed v5 if Michael agrees to take fix.

OK thanks!

Roman.

#19 lore raw
In reply to Roman Kagan

Hi Roman,

Quoted 2 lines · Roman Kagan

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

I'm late to the party, but please allow me a question:

how did you figure out that UEFI Windows requires this?

In general, what the ACPI specification says is at best a "guideline" for Windows. So how did you prove this was a requirement for Windows?

Thanks
Laszlo

Quoted 57 lines

Those objects are added in patch 5; the preceding ones pave the way to it, by making the necessary data public and by moving the whole floppy drive controller description into runtime-generated SSDT.

Note that the series conflicts with Igor's patchset for dynamic DSDT, in particular, with "[PATCH v2 27/51] pc: acpi: move FDC0 device from DSDT to SSDT"; I haven't managed to avoid that while trying to meet maintainer's comments.

Roman Kagan (6):
i386/pc: expose identifying the floppy controller i386/acpi: make floppy controller object dynamic tests/acpi: update test data
expose floppy drive geometry and CMOS type
i386: populate floppy drive information in SSDT tests/acpi: update test data

Cc "Michael S. Tsirkin" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
changes since v4:
- re-split out code changes from test data updates

changes since v3:
- make FDC object fully dynamic in a separate patch
- split out support patches
- include test data updates with the respective patches to maintain bisectability

changes since v2:
- explicit endianness for buffer data
- reorder code to reduce conflicts with dynamic DSDT patchset
- update test data

 hw/block/fdc.c                      |  11 +++++
 hw/i386/acpi-build.c                |  92 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-isa.dsl           |  18 -------
 hw/i386/acpi-dsdt.dsl               |   1 -
 hw/i386/pc.c                        |  46 ++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   7 +--
 include/hw/block/fdc.h              |   2 +
 include/hw/i386/pc.h                |   3 ++
 tests/acpi-test-data/pc/DSDT        | Bin 3028 -> 2946 bytes
 tests/acpi-test-data/pc/SSDT        | Bin 2486 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4345 -> 4494 bytes
 tests/acpi-test-data/q35/DSDT       | Bin 7666 -> 7578 bytes
 12 files changed, 137 insertions(+), 43 deletions(-)
#20 lore raw
Quoted 10 lines · Laszlo Ersek
Quoted 2 lines · Roman Kagan

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

I'm late to the party, but please allow me a question:

how did you figure out that UEFI Windows requires this?

In general, what the ACPI specification says is at best a "guideline" for Windows. So how did you prove this was a requirement for Windows?

Well, my statement above that Windows on UEFI can detect floppies *only* via ACPI is probably a bit stronger than I can actually prove but

- Windows on OVMF didn't see floppies before the patch, while Linux did (by querying CMOS)

- a number of sources on the internet hinted that Windows needed ACPI assistance for that, e.g.:

https://www.reactos.org/wiki/UEFI#Floppy
https://social.technet.microsoft.com/Forums/windows/en-US/f17db175-d146-4518-b2e9-c12a15031222/legacy-floppy-compatibility-with-uefi-boot?forum=w7itprohardware
https://social.technet.microsoft.com/Forums/windows/en-US/e91ec27b-0c2d-44a3-b949-e77fa810a4c0/windows-7-uefi-fdd-how-to?forum=w7itprohardware

- the links mentioned the need in _FDE object but indicated it only allowed for successful enumeration of floppies, not the actual access; I proved that experimentally

- the ACPI spec stated that _FDE went in concert with _FDI so I tried it and it worked out

Voila. Besides, I later discovered that a similar research had been carried out for Parallels proprietary hypervisor, with a similar outcome.

Roman.

#21 lore raw
Quoted 29 lines · Roman Kagan
Quoted 10 lines · Laszlo Ersek
Quoted 2 lines · Roman Kagan

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

I'm late to the party, but please allow me a question:

how did you figure out that UEFI Windows requires this?

In general, what the ACPI specification says is at best a "guideline" for Windows. So how did you prove this was a requirement for Windows?

Well, my statement above that Windows on UEFI can detect floppies *only* via ACPI is probably a bit stronger than I can actually prove but

- Windows on OVMF didn't see floppies before the patch, while Linux did (by querying CMOS)

- a number of sources on the internet hinted that Windows needed ACPI assistance for that, e.g.:

https://www.reactos.org/wiki/UEFI#Floppy
https://social.technet.microsoft.com/Forums/windows/en-US/f17db175-d146-4518-b2e9-c12a15031222/legacy-floppy-compatibility-with-uefi-boot?forum=w7itprohardware
https://social.technet.microsoft.com/Forums/windows/en-US/e91ec27b-0c2d-44a3-b949-e77fa810a4c0/windows-7-uefi-fdd-how-to?forum=w7itprohardware

- the links mentioned the need in _FDE object but indicated it only allowed for successful enumeration of floppies, not the actual access; I proved that experimentally

Quoted 6 lines

- the ACPI spec stated that _FDE went in concert with _FDI so I tried it and it worked out

Voila. Besides, I later discovered that a similar research had been carried out for Parallels proprietary hypervisor, with a similar outcome.

Ah, I wish I saw your comment
https://bugzilla.redhat.com/show_bug.cgi?id=1212317#c5
I'd probably proceed directly to trying _FDI :)

Roman.

#22 lore raw
In reply to Roman Kagan
Quoted 9 lines · Roman Kagan
Quoted 8 lines · Laszlo Ersek
Quoted 2 lines · Roman Kagan

Windows on UEFI systems is only capable of detecting the presence and the type of floppy drives via corresponding ACPI objects.

I'm late to the party, but please allow me a question:

how did you figure out that UEFI Windows requires this?

Quoted 8 lines
Quoted 2 lines

In general, what the ACPI specification says is at best a "guideline" for Windows. So how did you prove this was a requirement for Windows?

Well, my statement above that Windows on UEFI can detect floppies *only* via ACPI is probably a bit stronger than I can actually prove but

- Windows on OVMF didn't see floppies before the patch, while Linux did (by querying CMOS)

Indeed.

https://bugzilla.redhat.com/show_bug.cgi?id=1212317

Quoted 7 lines

- a number of sources on the internet hinted that Windows needed ACPI assistance for that, e.g.:

https://www.reactos.org/wiki/UEFI#Floppy
https://social.technet.microsoft.com/Forums/windows/en-US/f17db175-d146-4518-b2e9-c12a15031222/legacy-floppy-compatibility-with-uefi-boot?forum=w7itprohardware
https://social.technet.microsoft.com/Forums/windows/en-US/e91ec27b-0c2d-44a3-b949-e77fa810a4c0/windows-7-uefi-fdd-how-to?forum=w7itprohardware

Right, I found these. (The last two anyway.)

I also found technet comments that plainly stated "it would never work".

(Under your first link, I can read as well: "There have been reports that Windows does not properly support motherboard floppy controllers when booting from UEFI. The cause is not definitively known though a couple of pieces of data have emerged, one pointing to an issue with ACPI".)

Quoted 6 lines

- the links mentioned the need in _FDE object but indicated it only allowed for successful enumeration of floppies, not the actual access; I proved that experimentally

- the ACPI spec stated that _FDE went in concert with _FDI so I tried it and it worked out

Thank you for confirming.

So, improving Windows compat in QEMU remains trial-and-error-based, and occasionally reverse-engineering-based. Deplorable.

Quoted 3 lines

Voila. Besides, I later discovered that a similar research had been carried out for Parallels proprietary hypervisor, with a similar outcome.

That is, large amounts of work are being duplicated between participants in this industry segment, because Microsoft doesn't give a flying fsck about documenting their exact platform requirements. (The fact that _FDE and _FDI are described in the ACPI spec means exactly zilch, because Microsoft have ignored e.g. DataTableRegion from the same spec, since ACPI 2.0 -- the year 2000.) I'm quite sure this obscurity is intentional, and meant to spread uncertainty and waste competitors' resources.

Whereas they are having a field day whenever they look at open source components in a hybrid virt stack.

Nothing to see here, move along.

Thanks again.
Laszlo