[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 14/51] i386: populate floppy drive information in
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 14/51] i386: populate floppy drive information in DSDT |
Date: |
Tue, 15 Mar 2016 17:01:02 +0200 |
From: Roman Kagan <address@hidden>
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 are 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 <address@hidden>
Cc: Igor Mammedov <address@hidden>
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Marcel Apfelbaum <address@hidden>
Cc: John Snow <address@hidden>
Cc: Laszlo Ersek <address@hidden>
Cc: Kevin O'Connor <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/i386/acpi-build.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 66 insertions(+), 3 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index e005f3d..dbd0b93 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"
@@ -1228,11 +1229,60 @@ 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, FloppyDriveType type)
{
+ Aml *dev, *fdi;
+ uint8_t maxc, maxh, maxs;
+
+ isa_fdc_get_drive_max_chs(type, &maxc, &maxh, &maxs);
+
+ dev = aml_device("FLP%c", 'A' + idx);
+
+ aml_append(dev, aml_name_decl("_ADR", aml_int(idx)));
+
+ fdi = aml_package(16);
+ aml_append(fdi, aml_int(idx)); /* Drive Number */
+ aml_append(fdi,
+ aml_int(cmos_get_fd_drive_type(type))); /* Device Type */
+ /*
+ * the values below are the limits of the drive, and are thus independent
+ * of the inserted media
+ */
+ aml_append(fdi, aml_int(maxc)); /* Maximum Cylinder Number */
+ aml_append(fdi, aml_int(maxs)); /* Maximum Sector Number */
+ aml_append(fdi, aml_int(maxh)); /* 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;
+#define ACPI_FDE_MAX_FD 4
+ uint32_t fde_buf[5] = {
+ 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */
+ cpu_to_le32(2) /* tape presence (2 == never present) */
+ };
+
dev = aml_device("FDC0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700")));
@@ -1244,6 +1294,17 @@ 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 < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) {
+ FloppyDriveType type = isa_fdc_get_drive_type(fdc, i);
+
+ if (type < FLOPPY_DRIVE_TYPE_NONE) {
+ fde_buf[i] = cpu_to_le32(1); /* drive present */
+ aml_append(dev, build_fdinfo_aml(i, type));
+ }
+ }
+ aml_append(dev, aml_name_decl("_FDE",
+ aml_buffer(sizeof(fde_buf), (uint8_t *)fde_buf)));
+
return dev;
}
@@ -1388,13 +1449,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
- [Qemu-devel] [PULL v2 05/51] balloon: fix segfault and harden the stats queue, (continued)
- [Qemu-devel] [PULL v2 05/51] balloon: fix segfault and harden the stats queue, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 07/51] hw/virtio: group virtio flags into an enum, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 06/51] hw/virtio: fix double use of a virtio flag, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 08/51] virtio-balloon: add 'available' counter, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 09/51] vhost-user: verify that number of queues is less than MAX_QUEUE_NUM, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 11/51] i386/acpi: make floppy controller object dynamic, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 10/51] pc-dimm: fix error handling in pc_dimm_check_memdev_is_busy(), Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 12/51] i386: expose floppy drive CMOS type, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 13/51] fdc: add function to determine drive chs limits, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 15/51] i386: update expected DSDT, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 14/51] i386: populate floppy drive information in DSDT,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 16/51] virtio-pci: call pci reset variant when guest requests reset., Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 18/51] ich9lpc: fix typo, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 19/51] hw/acpi: fix Q35 support for legacy Windows OS, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 20/51] acpi-test-data: add _DIS methods, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 17/51] msi_supported -> msi_nonbroken, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 21/51] pci-ids: add virtio 1.0 ids to spec, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 22/51] nvdimm acpi: initialize the resource used by NVDIMM ACPI, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 24/51] nvdimm acpi: let qemu handle _DSM method, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 23/51] nvdimm acpi: introduce patched dsm memory, Michael S. Tsirkin, 2016/03/15
- [Qemu-devel] [PULL v2 26/51] vhost-user: fix use after free, Michael S. Tsirkin, 2016/03/15