From patchwork Mon Jan 11 15:35:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 566003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 264A91402D9 for ; Tue, 12 Jan 2016 02:43:47 +1100 (AEDT) Received: from localhost ([::1]:55407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIedF-0006ko-5o for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2016 10:43:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIeVT-0007pw-LY for qemu-devel@nongnu.org; Mon, 11 Jan 2016 10:35:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIeVS-0006bS-FX for qemu-devel@nongnu.org; Mon, 11 Jan 2016 10:35:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIeVS-0006b8-8r for qemu-devel@nongnu.org; Mon, 11 Jan 2016 10:35:42 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E1EBFA37FC; Mon, 11 Jan 2016 15:35:41 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0BFZarP018351; Mon, 11 Jan 2016 10:35:40 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 11 Jan 2016 16:35:34 +0100 Message-Id: <1452526534-106444-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1452526534-106444-1-git-send-email-imammedo@redhat.com> References: <1452526534-106444-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: rkagan@virtuozzo.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v6 3/3] i386: populate floppy drive information in DSDT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: 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. 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 Signed-off-by: Igor Mammedov --- 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 2f685fb..c774511 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" @@ -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 < FDRIVE_DRV_NONE) { + uint8_t cylinders, heads, sectors; + + fde_buf[i] = cpu_to_le32(0x1); + isa_fdc_get_drive_geometry(fdc, i, &cylinders, &heads, §ors); + 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));