All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gabriel L. Somlo" <gsomlo@gmail.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com, pbonzini@redhat.com, lersek@redhat.com,
	armbru@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [RFC PATCH v2] Add option to switch off FDC
Date: Fri, 31 Jan 2014 14:03:23 -0500	[thread overview]
Message-ID: <20140131190322.GL29329@ERROL.INI.CMU.EDU> (raw)
In-Reply-To: <52CE78EA.5010003@redhat.com>

Allow guests to omit the configuration of a floppy disk controller.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
---

New in this version:

  - "int have_fdc = 1;" instead of "int no_fdc = 0;"

  - use 8bit field for FDC0's _STA method

On Thu, Jan 09, 2014 at 11:24:42AM +0100, Paolo Bonzini wrote:
> Il 09/01/2014 09:46, Markus Armbruster ha scritto:
> >> > I think we need to provide a mechanism for machine-specific options.
> >> > Options like this one does not scale.
> > -machine?  It already has many keys that really apply to only a few
> > machines.  Sticking in one more won't kill us.
> 
> Yeah, -machine would work as a short-term solution.  I was thinking of
> making -machine set properties on the QOM /machine object.  Then you can
> add properties to that object, and they will show up in -machine
> automagically.

So, are we talking only about the "policy" part here, i.e., how and when
to turn "have_fdc" off or on, and whether to expose that option through
the command line ?

Are we OK with the "mechanism" part, i.e. introducing "have_fdc", and
programatically configuring the FDC in pc.c and patching the DSDT
based on its value ?

Thanks,
  Gabriel

 qemu-options.hx           |  8 ++++++++
 vl.c                      |  4 ++++
 include/hw/i386/pc.h      |  3 +++
 hw/i386/pc.c              | 10 +++++++---
 hw/i386/acpi-dsdt.dsl     |  2 +-
 hw/i386/q35-acpi-dsdt.dsl |  4 ++--
 hw/i386/acpi-dsdt-isa.dsl | 11 +++--------
 hw/i386/acpi-build.c      |  8 +++++++-
 8 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 56e5fdf..993d377 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1297,6 +1297,14 @@ STEXI
 Disable HPET support.
 ETEXI
 
+DEF("no-fdc", 0, QEMU_OPTION_no_fdc,
+    "-no-fdc         disable FDC\n", QEMU_ARCH_I386)
+STEXI
+@item -no-fdc
+@findex -no-fdc
+Disable FDC support.
+ETEXI
+
 DEF("acpitable", HAS_ARG, QEMU_OPTION_acpitable,
     "-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,{data|file}=file1[:file2]...]\n"
     "                ACPI table description\n", QEMU_ARCH_I386)
diff --git a/vl.c b/vl.c
index c73462e..ffaa7ae 100644
--- a/vl.c
+++ b/vl.c
@@ -214,6 +214,7 @@ const char *vnc_display;
 #endif
 int acpi_enabled = 1;
 int no_hpet = 0;
+int have_fdc = 1;
 int fd_bootchk = 1;
 static int no_reboot;
 int no_shutdown = 0;
@@ -3581,6 +3582,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_no_hpet:
                 no_hpet = 1;
                 break;
+            case QEMU_OPTION_no_fdc:
+                have_fdc = 0;
+                break;
             case QEMU_OPTION_balloon:
                 if (balloon_parse(optarg) < 0) {
                     fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 3e1e81b..db4017b 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -173,6 +173,9 @@ void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 /* hpet.c */
 extern int no_hpet;
 
+/* fdc.c */
+extern int have_fdc;
+
 /* piix_pci.c */
 struct PCII440FXState;
 typedef struct PCII440FXState PCII440FXState;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 348b15f..d38e272 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1358,10 +1358,14 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
     cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
     DMA_init(0, cpu_exit_irq);
 
-    for(i = 0; i < MAX_FD; i++) {
-        fd[i] = drive_get(IF_FLOPPY, 0, i);
+    if (have_fdc) {
+        for (i = 0; i < MAX_FD; i++) {
+            fd[i] = drive_get(IF_FLOPPY, 0, i);
+        }
+        *floppy = fdctrl_init_isa(isa_bus, fd);
+    } else {
+        *floppy = NULL;
     }
-    *floppy = fdctrl_init_isa(isa_bus, fd);
 }
 
 void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index b23d5e0..16d3be5 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -149,11 +149,11 @@ DefinitionBlock (
                 , 3,
                 CBEN, 1,         // COM2
             }
-            Name(FDEN, 1)
         }
     }
 
 #define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta
+#define DSDT_FDC_STA piix_dsdt_fdc_sta
 #include "acpi-dsdt-isa.dsl"
 
 
diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
index d618e9e..0861414 100644
--- a/hw/i386/q35-acpi-dsdt.dsl
+++ b/hw/i386/q35-acpi-dsdt.dsl
@@ -181,13 +181,13 @@ DefinitionBlock (
             Field(LPCE, AnyAcc, NoLock, Preserve) {
                 CAEN,   1,
                 CBEN,   1,
-                LPEN,   1,
-                FDEN,   1
+                LPEN,   1
             }
         }
     }
 
 #define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
+#define DSDT_FDC_STA q35_dsdt_fdc_sta
 #include "acpi-dsdt-isa.dsl"
 
 
diff --git a/hw/i386/acpi-dsdt-isa.dsl b/hw/i386/acpi-dsdt-isa.dsl
index deb37de..ffe6770 100644
--- a/hw/i386/acpi-dsdt-isa.dsl
+++ b/hw/i386/acpi-dsdt-isa.dsl
@@ -60,14 +60,9 @@ 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)
-            }
-        }
+        /* _STA will be patched to 0x0F if the FDC is present */
+        ACPI_EXTRACT_NAME_BYTE_CONST DSDT_FDC_STA
+        Name(_STA, 0xF0)
         Name(_CRS, ResourceTemplate() {
             IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
             IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 50e83f3..302a745 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -88,7 +88,7 @@ typedef struct AcpiBuildPciBusHotplugState {
 
 static void acpi_get_dsdt(AcpiMiscInfo *info)
 {
-    uint16_t *applesmc_sta;
+    uint16_t *applesmc_sta, *fdc_sta;
     Object *piix = piix4_pm_find();
     Object *lpc = ich9_lpc_find();
     assert(!!piix != !!lpc);
@@ -97,16 +97,22 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)
         info->dsdt_code = AcpiDsdtAmlCode;
         info->dsdt_size = sizeof AcpiDsdtAmlCode;
         applesmc_sta = piix_dsdt_applesmc_sta;
+        fdc_sta = piix_dsdt_fdc_sta;
     }
     if (lpc) {
         info->dsdt_code = Q35AcpiDsdtAmlCode;
         info->dsdt_size = sizeof Q35AcpiDsdtAmlCode;
         applesmc_sta = q35_dsdt_applesmc_sta;
+        fdc_sta = q35_dsdt_fdc_sta;
     }
 
     /* Patch in appropriate value for AppleSMC _STA */
     *(uint8_t *)(info->dsdt_code + *applesmc_sta) =
         applesmc_find() ? 0x0b : 0x00;
+
+    /* Patch in appropriate value for FDC _STA */
+    *(uint8_t *)(info->dsdt_code + *fdc_sta) =
+        have_fdc ? 0x0f : 0x00;
 }
 
 static
-- 
1.8.1.4

  reply	other threads:[~2014-01-31 19:04 UTC|newest]

Thread overview: 155+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 20:02 [Qemu-devel] [PATCH] Add option to disable FDC from ISA bus and ACPI on i386 Gabriel L. Somlo
2014-01-08 20:38 ` Michael S. Tsirkin
2014-01-08 21:09   ` Gabriel L. Somlo
2014-01-15 11:13     ` Paolo Bonzini
2014-01-08 22:13 ` Paolo Bonzini
2014-01-08 23:39   ` Gabriel L. Somlo
2014-01-09  0:12     ` Alexander Graf
2014-01-09  1:51     ` Michael S. Tsirkin
2014-01-09 18:51       ` Gabriel L. Somlo
2014-01-09 20:12         ` Paolo Bonzini
2014-01-09 21:33           ` Michael S. Tsirkin
2014-01-09 21:58             ` Gabriel L. Somlo
2014-01-09 21:44           ` Gabriel L. Somlo
2014-01-10 12:37             ` Paolo Bonzini
2014-01-10 15:35               ` Gabriel L. Somlo
2014-01-10 16:13                 ` Igor Mammedov
2014-01-17 21:10                   ` [Qemu-devel] RFC: ACPI, HPET._CRS, MacOSX vs. WinXP Gabriel L. Somlo
2014-01-20 11:58                     ` Michael S. Tsirkin
2014-01-20 11:57                       ` Paolo Bonzini
2014-01-20 12:08                         ` Michael S. Tsirkin
2014-01-20 12:16                           ` Paolo Bonzini
2014-01-20 18:54                             ` Gabriel L. Somlo
2014-01-20 20:31                               ` Michael S. Tsirkin
2014-01-20 21:25                                 ` Gabriel L. Somlo
2014-01-21 10:33                                   ` Paolo Bonzini
2014-01-21 11:02                                     ` Michael S. Tsirkin
2014-01-21 11:05                                       ` Paolo Bonzini
2014-01-21 11:44                                         ` Michael S. Tsirkin
2014-01-21 18:11                                           ` [Qemu-devel] [PATCH] ACPI: Add IRQ resource to HPET._CRS on Mac OS X Gabriel L. Somlo
2014-01-21 18:38                                             ` Michael S. Tsirkin
2014-01-24 16:46                                               ` Gabriel L. Somlo
2014-01-24 21:18                                                 ` Alexander Graf
2014-01-25  0:09                                                   ` Gabriel L. Somlo
2014-01-25  9:08                                                     ` Alexander Graf
2014-01-27 22:51                                                       ` Gabriel L. Somlo
2014-01-27 23:51                                                         ` Alexander Graf
2014-01-28 16:45                                                           ` [Qemu-devel] OSX guest support review Gabriel L. Somlo
2014-01-28 16:57                                                             ` Michael S. Tsirkin
2014-01-29 14:17                                                             ` Alexander Graf
2014-01-29 21:36                                                               ` [Qemu-devel] OSX guest vs. kvm ioapic polarity Gabriel L. Somlo
2014-01-29 22:18                                                                 ` Michael S. Tsirkin
2014-01-30 14:18                                                                   ` Gabriel L. Somlo
2014-01-30 19:48                                                                     ` Michael S. Tsirkin
2014-01-30 20:21                                                                       ` Gabriel L. Somlo
2014-01-30 20:28                                                                         ` Michael S. Tsirkin
2014-01-30 20:33                                                                         ` Michael S. Tsirkin
2014-01-30 20:44                                                                           ` Gabriel L. Somlo
2014-02-11 18:23                                                                             ` RFC: ioapic polarity vs. qemu os-x guest Gabriel L. Somlo
2014-02-11 18:23                                                                               ` [Qemu-devel] " Gabriel L. Somlo
2014-02-11 19:54                                                                               ` Michael S. Tsirkin
2014-02-11 19:54                                                                                 ` [Qemu-devel] " Michael S. Tsirkin
2014-02-11 21:35                                                                                 ` Gabriel L. Somlo
2014-02-11 21:35                                                                                   ` [Qemu-devel] " Gabriel L. Somlo
2014-02-14 21:13                                                                                 ` Gabriel L. Somlo
2014-02-14 21:13                                                                                   ` [Qemu-devel] " Gabriel L. Somlo
2014-02-14 21:21                                                                                   ` Alexander Graf
2014-02-14 21:21                                                                                     ` [Qemu-devel] " Alexander Graf
2014-02-14 22:06                                                                                     ` Gabriel L. Somlo
2014-02-14 22:06                                                                                       ` [Qemu-devel] " Gabriel L. Somlo
2014-02-14 22:13                                                                                       ` Alexander Graf
2014-02-14 22:13                                                                                         ` [Qemu-devel] " Alexander Graf
2014-02-16 11:18                                                                                         ` Michael S. Tsirkin
2014-02-16 11:18                                                                                           ` [Qemu-devel] " Michael S. Tsirkin
2014-02-16 11:41                                                                                         ` Michael S. Tsirkin
2014-02-16 11:41                                                                                           ` [Qemu-devel] " Michael S. Tsirkin
2014-02-16 14:47                                                                                           ` Alex Williamson
2014-02-16 14:47                                                                                             ` [Qemu-devel] " Alex Williamson
2014-02-16 16:23                                                                                             ` Michael S. Tsirkin
2014-02-16 16:23                                                                                               ` [Qemu-devel] " Michael S. Tsirkin
2014-02-17 17:57                                                                                               ` Gabriel L. Somlo
2014-02-17 17:57                                                                                                 ` [Qemu-devel] " Gabriel L. Somlo
2014-02-17 18:01                                                                                                 ` Gabriel L. Somlo
2014-02-17 18:01                                                                                                   ` [Qemu-devel] " Gabriel L. Somlo
2014-02-17 18:06                                                                                                   ` Paolo Bonzini
2014-02-17 18:06                                                                                                     ` [Qemu-devel] " Paolo Bonzini
2014-02-17 19:38                                                                                                     ` Gabriel L. Somlo
2014-02-17 19:38                                                                                                       ` [Qemu-devel] " Gabriel L. Somlo
2014-02-18  0:58                                                                                                       ` Gabriel L. Somlo
2014-02-18  0:58                                                                                                         ` [Qemu-devel] " Gabriel L. Somlo
2014-02-27 17:05                                                                                               ` [PATCH RFC] kvm: ignore apic polarity Michael S. Tsirkin
2014-02-27 17:05                                                                                                 ` [Qemu-devel] " Michael S. Tsirkin
2014-02-27 21:41                                                                                                 ` Gabriel L. Somlo
2014-02-27 21:41                                                                                                   ` [Qemu-devel] " Gabriel L. Somlo
2014-02-27 22:30                                                                                                   ` Paolo Bonzini
2014-02-27 22:30                                                                                                     ` [Qemu-devel] " Paolo Bonzini
2014-02-27 23:13                                                                                                     ` Gabriel L. Somlo
2014-02-27 23:13                                                                                                       ` [Qemu-devel] " Gabriel L. Somlo
2014-02-27 23:31                                                                                                       ` Paolo Bonzini
2014-02-27 23:31                                                                                                         ` [Qemu-devel] " Paolo Bonzini
2014-02-28  4:06                                                                                                         ` [RFC PATCH v2] kvm: x86: ignore ioapic polarity Gabriel L. Somlo
2014-02-28  4:06                                                                                                           ` [Qemu-devel] " Gabriel L. Somlo
2014-02-28 17:23                                                                                                           ` [Qemu-devel] [RFC PATCH] qemu: " Gabriel L. Somlo
2014-02-28 18:57                                                                                                             ` [Qemu-devel] [RFC PATCH v2] " Gabriel L. Somlo
2014-02-28 19:14                                                                                                               ` [Qemu-devel] [PATCH] qemu: x86: report lapic version as 0x14 instead of 0x11 Gabriel L. Somlo
2014-03-01  3:44                                                                                                                 ` Alexander Graf
2014-03-01  4:25                                                                                                                   ` Gabriel L. Somlo
2014-03-01  5:45                                                                                                                     ` Alexander Graf
2014-03-01 14:46                                                                                                                 ` Paolo Bonzini
2014-03-02  0:17                                                                                                                   ` Gabriel L. Somlo
2014-03-02  8:56                                                                                                                     ` Paolo Bonzini
2014-03-02 14:31                                                                                                                       ` Michael S. Tsirkin
2014-03-02 16:02                                                                                                                         ` Michael S. Tsirkin
2014-03-06  7:50                                                                                                                     ` Michael S. Tsirkin
2014-03-02 14:52                                                                                                               ` [Qemu-devel] [RFC PATCH v2] qemu: x86: ignore ioapic polarity Michael S. Tsirkin
2014-03-02 16:15                                                                                                                 ` Gabriel L. Somlo
2014-03-02 17:09                                                                                                                   ` Michael S. Tsirkin
2014-03-06  7:45                                                                                                               ` Michael S. Tsirkin
2014-03-02 14:55                                                                                                           ` [RFC PATCH v2] kvm: " Michael S. Tsirkin
2014-03-02 14:55                                                                                                             ` [Qemu-devel] " Michael S. Tsirkin
2014-03-13 10:53                                                                                                           ` Paolo Bonzini
2014-03-13 10:53                                                                                                             ` [Qemu-devel] " Paolo Bonzini
2014-03-13 13:43                                                                                                             ` Gabriel L. Somlo
2014-03-13 13:43                                                                                                               ` [Qemu-devel] " Gabriel L. Somlo
2014-02-28  4:55                                                                                                     ` [PATCH RFC] kvm: ignore apic polarity Michael S. Tsirkin
2014-02-28  4:55                                                                                                       ` [Qemu-devel] " Michael S. Tsirkin
2014-02-28  8:10                                                                                                       ` Paolo Bonzini
2014-02-28  8:10                                                                                                         ` [Qemu-devel] " Paolo Bonzini
2014-02-28  8:11                                                                                                       ` Paolo Bonzini
2014-02-28  8:11                                                                                                         ` [Qemu-devel] " Paolo Bonzini
2014-03-01  5:03                                                                                                 ` Alex Williamson
2014-03-01  5:03                                                                                                   ` [Qemu-devel] " Alex Williamson
2014-02-16 11:34                                                                                   ` RFC: ioapic polarity vs. qemu os-x guest Michael S. Tsirkin
2014-02-16 11:34                                                                                     ` [Qemu-devel] " Michael S. Tsirkin
2014-02-16 15:12                                                                                     ` Peter Maydell
2014-02-16 11:37                                                                                   ` Michael S. Tsirkin
2014-02-16 11:37                                                                                     ` [Qemu-devel] " Michael S. Tsirkin
2014-01-29 23:13                                                                 ` [Qemu-devel] OSX guest vs. kvm ioapic polarity Alexander Graf
2014-01-30 15:56                                                                   ` Gabriel L. Somlo
2014-01-28 20:40                                                       ` [Qemu-devel] osx bootloader Gabriel L. Somlo
2014-01-28 22:51                                                         ` BALATON Zoltan
2014-01-29  3:07                                                           ` Gabriel L. Somlo
2014-01-29 11:29                                                             ` BALATON Zoltan
2014-01-29 14:53                                                               ` Gabriel L. Somlo
2014-01-29 15:00                                                                 ` Alexander Graf
2014-01-30  0:15                                                                   ` BALATON Zoltan
2014-02-01 17:43                                                                   ` BALATON Zoltan
2014-02-01  0:38                                                                 ` BALATON Zoltan
2014-02-01 10:07                                                                   ` Alexander Graf
2014-02-01 14:35                                                                     ` [Qemu-devel] OVMF with q35 (was: osx bootloader) BALATON Zoltan
2014-02-01 15:13                                                                       ` Alexander Graf
2014-02-01 17:38                                                                         ` BALATON Zoltan
2014-02-03  7:47                                                                       ` Gerd Hoffmann
2014-02-01 21:19                                                                   ` [Qemu-devel] osx bootloader Paolo Bonzini
2014-02-02  2:18                                                                     ` BALATON Zoltan
2014-01-29 12:10                                                             ` BALATON Zoltan
2014-01-29 14:20                                                             ` Alexander Graf
2014-01-21 11:38                                   ` [Qemu-devel] RFC: ACPI, HPET._CRS, MacOSX vs. WinXP Michael S. Tsirkin
2014-01-20 20:23                             ` Michael S. Tsirkin
2014-01-20 12:03                     ` Igor Mammedov
2014-01-09  8:46   ` [Qemu-devel] [PATCH] Add option to disable FDC from ISA bus and ACPI on i386 Markus Armbruster
2014-01-09 10:24     ` Paolo Bonzini
2014-01-31 19:03       ` Gabriel L. Somlo [this message]
2014-01-31 19:39         ` [Qemu-devel] [RFC PATCH v2] Add option to switch off FDC Eric Blake
2014-02-02 13:47           ` Michael S. Tsirkin
2014-02-10 14:10             ` Marcel Apfelbaum

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=20140131190322.GL29329@ERROL.INI.CMU.EDU \
    --to=gsomlo@gmail.com \
    --cc=armbru@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.