qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 4/4] i386: populate floppy drive information in S


From: Roman Kagan
Subject: [Qemu-devel] [PATCH v4 4/4] i386: populate floppy drive information in SSDT
Date: Fri, 25 Dec 2015 18:04:12 +0300

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.

Signed-off-by: Roman Kagan <address@hidden>
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Eduardo Habkost <address@hidden>
Cc: Igor Mammedov <address@hidden>
Cc: John Snow <address@hidden>
Cc: Kevin Wolf <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Richard Henderson <address@hidden>
Cc: address@hidden
Cc: address@hidden
---
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 ++++++++++++++++++++++++++++++++++++
 tests/acpi-test-data/pc/SSDT        | Bin 2554 -> 2635 bytes
 tests/acpi-test-data/pc/SSDT.bridge | Bin 4413 -> 4494 bytes
 3 files changed, 68 insertions(+)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a01e909..7b8de59 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
     }
diff --git a/tests/acpi-test-data/pc/SSDT b/tests/acpi-test-data/pc/SSDT
index 
ffb3fe43970123d0e198328429ee04ebfd0564c9..5e70e0b5989bb8c85a14bd0902f32dd48eb17602
 100644
GIT binary patch
delta 130
zcmew*d|HGnIM^k`n~Q;g(QPAFG^3~sXN*2`e6Uk|fU~E8XRu>@bdw{;<Vr?;|L7(|
zH=h7Uj(A6xAO?<jHy2MK1px*w7A}7-Ax5tCTufZ5KrF;1&GnxvhwB>`KNkl`m8+mQ
address@hidden;(Tc3K+8h

delta 49
zcmX>address@hidden)<AjY|(address@hidden<0nVNVp23ds(M<-Es~Gh+|6~l}
F003=;4z&OP

diff --git a/tests/acpi-test-data/pc/SSDT.bridge 
b/tests/acpi-test-data/pc/SSDT.bridge
index 
f0f11bec8108eceb696fb854b51faeb97471146c..642d9a51203cc591a61b2169b2feb5731ad67a96
 100644
GIT binary patch
delta 130
zcmdn1)Thi99PAR(C&<9S*uRl0no-n+Ge(~|KG-Qfz}eHlGuSacy2+7aawVg_e{_?f
zn@@lvN4%p;5CccNn~SHAf&c>-3zt8a5F^)mE+#HjAQs}1=K9Z-!}X1epNj*e%2iOD
SON5aD6)address@hidden

delta 49
zcmeBE-mAnF9PAQeE6BjWcw-}1G^2<!ON>5qe6Uk|fU~E8XRu>@bd$m4Dn|XyKN+X;
F0{}`q4mJP)

-- 
2.5.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]