qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Roman Kagan <rkagan@virtuozzo.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PULL 48/49] i386: populate floppy drive information in DSDT
Date: Thu, 4 Feb 2016 23:54:13 +0200	[thread overview]
Message-ID: <1454612376-7072-49-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1454612376-7072-1-git-send-email-mst@redhat.com>

From: Roman Kagan <rkagan@virtuozzo.com>

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.

However Windows doesn't do it. 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 doesn't provide those objects in its ACPI tables
and as a result floppy drives aren't invisible to Windows
on UEFI/OVMF.

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

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/acpi-build.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 58 insertions(+), 3 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 842c731..caa2e87 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -37,6 +37,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"
@@ -1227,10 +1228,47 @@ static void build_hpet_aml(Aml *table)
     aml_append(table, scope);
 }
 
-static Aml *build_fdc_device_aml(void)
+static Aml *build_fdinfo_aml(int idx, uint8_t type, uint8_t cylinders,
+                             uint8_t heads, uint8_t sectors)
+{
+    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(type)));  /* Device Type */
+    aml_append(fdi,
+        aml_int(cylinders - 1));  /* Maximum Cylinder Number */
+    aml_append(fdi, aml_int(sectors));  /* Maximum Sector Number */
+    aml_append(fdi, aml_int(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 Aml *build_fdc_device_aml(ISADevice *fdc)
 {
+    int i;
     Aml *dev;
     Aml *crs;
+    uint32_t fde_buf[5] = {0, 0, 0, 0, cpu_to_le32(0x2)};
 
     dev = aml_device("FDC0");
     aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700")));
@@ -1243,6 +1281,21 @@ static Aml *build_fdc_device_aml(void)
         aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2));
     aml_append(dev, aml_name_decl("_CRS", crs));
 
+    for (i = 0; i < MAX_FD; i++) {
+        uint8_t type = isa_fdc_get_drive_type(fdc, i);
+
+        if (type < FLOPPY_DRIVE_TYPE_NONE) {
+            uint8_t cylinders, heads, sectors;
+
+            fde_buf[i] = cpu_to_le32(0x1);
+            isa_fdc_get_drive_geometry(fdc, i, &cylinders, &heads, &sectors);
+            aml_append(dev,
+                build_fdinfo_aml(i, type, cylinders, heads, sectors));
+        }
+    }
+    aml_append(dev, aml_name_decl("_FDE",
+               aml_buffer(sizeof(fde_buf), (uint8_t *) fde_buf)));
+
     return dev;
 }
 
@@ -1387,13 +1440,15 @@ static Aml *build_com_device_aml(uint8_t uid)
 
 static void build_isa_devices_aml(Aml *table)
 {
+    ISADevice *fdc = pc_find_fdc0();
+
     Aml *scope = aml_scope("_SB.PCI0.ISA");
 
     aml_append(scope, build_rtc_device_aml());
     aml_append(scope, build_kbd_device_aml());
     aml_append(scope, build_mouse_device_aml());
-    if (!!pc_find_fdc0()) {
-        aml_append(scope, build_fdc_device_aml());
+    if (!!fdc) {
+        aml_append(scope, build_fdc_device_aml(fdc));
     }
     aml_append(scope, build_lpt_device_aml());
     aml_append(scope, build_com_device_aml(1));
-- 
MST

  parent reply	other threads:[~2016-02-04 21:54 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 21:50 [Qemu-devel] [PULL 00/49] pc and misc cleanups and fixes, virtio optimizations Michael S. Tsirkin
2016-02-04 21:50 ` [Qemu-devel] [PULL 14/49] virtio: combine write of an entry into used ring Michael S. Tsirkin
2016-02-04 21:50 ` [Qemu-devel] [PULL 01/49] Fix virtio migration Michael S. Tsirkin
2016-02-04 21:50 ` [Qemu-devel] [PULL 02/49] pc: acpi: merge SSDT into DSDT Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 03/49] tests: pc: acpi: drop not needed 'expected SSDT' blobs Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 04/49] tests: pc: acpi: add expected DSDT.bridge blobs and update DSDT blobs Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 05/49] virtio: move VirtQueueElement at the beginning of the structs Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 06/49] virtio: move allocation to virtqueue_pop/vring_pop Michael S. Tsirkin
2016-02-05 12:52   ` Peter Maydell
2016-02-06 18:10     ` Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 07/49] virtio: introduce qemu_get/put_virtqueue_element Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 08/49] virtio: introduce virtqueue_alloc_element Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 09/49] virtio: slim down allocation of VirtQueueElements Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 10/49] vring: " Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 11/49] virtio: combine the read of a descriptor Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 12/49] virtio: cache used_idx in a VirtQueue field Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 13/49] virtio: read avail_idx from VQ only when necessary Michael S. Tsirkin
2016-02-04 21:51 ` [Qemu-devel] [PULL 15/49] hw/pxb: add pxb devices to the bridge category Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 16/49] vhost-user-test: use correct ROM to speed up and avoid spurious failures Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 17/49] hw/pci: ensure that only PCI/PCIe bridges can be attached to pxb/pxb-pcie devices Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 18/49] ipmi: replace goto by a return statement Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 19/49] ipmi: replace *_MAXCMD defines Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 20/49] ipmi: cleanup error_report messages Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 21/49] ipmi: fix SDR length value Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 22/49] ipmi: introduce a struct ipmi_sdr_compact Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 23/49] ipmi: add get and set SENSOR_TYPE commands Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 24/49] ipmi: add GET_SYS_RESTART_CAUSE chassis command Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 25/49] ipmi: add ACPI power and GUID commands Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 26/49] pc: Move PcGuestInfo declaration to top of file Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 27/49] pc: Eliminate struct PcGuestInfoState Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 28/49] pc: Simplify pc_memory_init() signature Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 29/49] pc: Simplify xen_load_linux() signature Michael S. Tsirkin
2016-02-04 21:52 ` [Qemu-devel] [PULL 30/49] acpi: Remove guest_info parameters from functions Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 31/49] acpi: Don't save PcGuestInfo on AcpiBuildState Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 32/49] pc: Remove compat fields from PcGuestInfo Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 33/49] pc: Remove RAM size " Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 34/49] pc: Remove PcGuestInfo.isapc_ram_fw field Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 35/49] pc: Move PcGuestInfo.fw_cfg to PCMachineState Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 36/49] pc: Move APIC and NUMA data from PcGuestInfo " Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 37/49] pc: Eliminate PcGuestInfo struct Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 38/49] acpi: take oem_id in build_header(), optionally Michael S. Tsirkin
2016-02-04 22:25   ` Laszlo Ersek
2016-02-04 21:53 ` [Qemu-devel] [PULL 39/49] acpi: expose oem_id and oem_table_id in build_rsdt() Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 40/49] acpi: add function to extract oem_id and oem_table_id from the user's SLIC Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 41/49] pc: set the OEM fields in the RSDT and the FADT from the SLIC Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 42/49] dimm: Correct type of MemoryHotplugState->base Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 43/49] intel_iommu: large page support Michael S. Tsirkin
2016-02-04 21:53 ` [Qemu-devel] [PULL 44/49] fix MSI injection on Xen Michael S. Tsirkin
2016-02-04 21:54 ` [Qemu-devel] [PULL 45/49] net: set endianness on all backend devices Michael S. Tsirkin
2016-02-05  8:54   ` Greg Kurz
2016-02-04 21:54 ` [Qemu-devel] [PULL 46/49] i386/acpi: make floppy controller object dynamic Michael S. Tsirkin
2016-02-04 21:54 ` [Qemu-devel] [PULL 47/49] expose floppy drive geometry and CMOS type Michael S. Tsirkin
2016-02-04 21:54 ` Michael S. Tsirkin [this message]
2016-02-05 18:25   ` [Qemu-devel] [PULL 48/49] i386: populate floppy drive information in DSDT Igor Mammedov
2016-02-08 13:14     ` Roman Kagan
2016-02-08 20:20       ` John Snow
2016-02-09 15:52         ` Roman Kagan
2016-02-09 16:22           ` John Snow
2016-02-09 18:36             ` Laszlo Ersek
2016-02-09 18:48               ` Michael S. Tsirkin
2016-02-10 16:14                 ` John Snow
2016-02-10 16:48                   ` Michael S. Tsirkin
2016-02-10 17:24                   ` Roman Kagan
2016-02-10 17:10               ` Roman Kagan
2016-02-10 17:16                 ` John Snow
2016-02-10 17:33                   ` Roman Kagan
2016-02-10 21:54                     ` John Snow
2016-02-13 17:26               ` Kevin O'Connor
2016-02-14  6:45                 ` Laszlo Ersek
2016-02-14 15:02                 ` Michael S. Tsirkin
2016-02-17 14:31                   ` Roman Kagan
2016-02-10 16:57             ` Roman Kagan
2016-02-04 21:54 ` [Qemu-devel] [PULL 49/49] acpi: update expected DSDT Michael S. Tsirkin
2016-02-05 15:03 ` [Qemu-devel] [PULL 00/49] pc and misc cleanups and fixes, virtio optimizations Peter Maydell
2016-02-05 18:19   ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454612376-7072-49-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rkagan@virtuozzo.com \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).