Skip to contentSkip to conversation

update CMOS for ISA-FDC with iobase=0x3f0

PATCH In review Laszlo Ersek 5 participants 12 messages Jun 25, 2015 – Jul 6, 2015

lore
Share & tools
lore
#0 lore raw

v2 cover update CMOS for ISA-FDC with iobase=0x3f0

In v2 I address coding style comments I got from Markus for v1. No functional changes (Jan tested v1, many thanks for that). Updates are marked per patch.

Markus, can you please give your R-b for patch #2? I picked up all other tags I received from John and you.

Cc Jan Tomko <[email protected]>
Cc John Snow <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Paolo Bonzini <[email protected]>

Thanks
Laszlo

Laszlo Ersek (3):
hw/i386/pc: factor out pc_cmos_init_floppy() hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS hw/i386/pc: don't carry FDC from pc_basic_device_init() to

    pc_cmos_init()
 include/hw/i386/pc.h |   3 +-
 hw/i386/pc.c         | 129 ++++++++++++++++++++++++++++++++++++++-------------
 hw/i386/pc_piix.c    |   5 +-
 hw/i386/pc_q35.c     |   5 +-
 4 files changed, 101 insertions(+), 41 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/3 hw/i386/pc: factor out pc_cmos_init_floppy()

Extract the pc_cmos_init_floppy() function from pc_cmos_init(). The function sets two RTC registers: floppy drive types (0x10), overwriting the earlier value in there), and REG_EQUIPMENT_BYTE (0x14), setting bits in the prior value.

---

Notes:
v2:
- no changes
- picked up R-b from John & Markus, thanks

v1:
- no changes relative to RFC

 hw/i386/pc.c | 67 ++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 38 insertions(+), 29 deletions(-)
hw/i386/pc.c +38 -29
index 7072930..4a835be 100644
@@ -294,6 +294,42 @@ static void pc_boot_set(void *opaque, const char *boot_device, Error **errp)
     set_boot_dev(opaque, boot_device, errp);
 }
 
+static void pc_cmos_init_floppy(ISADevice *rtc_state, ISADevice *floppy)
+{
+    int val, nb, i;
+    FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE };
+
+    /* floppy type */
+    if (floppy) {
+        for (i = 0; i < 2; i++) {
+            fd_type[i] = isa_fdc_get_drive_type(floppy, i);
+        }
+    }
+    val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
+        cmos_get_fd_drive_type(fd_type[1]);
+    rtc_set_memory(rtc_state, 0x10, val);
+
+    val = rtc_get_memory(rtc_state, REG_EQUIPMENT_BYTE);
+    nb = 0;
+    if (fd_type[0] < FDRIVE_DRV_NONE) {
+        nb++;
+    }
+    if (fd_type[1] < FDRIVE_DRV_NONE) {
+        nb++;
+    }
+    switch (nb) {
+    case 0:
+        break;
+    case 1:
+        val |= 0x01; /* 1 drive, ready for boot */
+        break;
+    case 2:
+        val |= 0x41; /* 2 drives, ready for boot */
+        break;
+    }
+    rtc_set_memory(rtc_state, REG_EQUIPMENT_BYTE, val);
+}
+
 typedef struct pc_cmos_init_late_arg {
     ISADevice *rtc_state;
     BusState *idebus[2];
@@ -344,8 +380,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
                   ISADevice *floppy, BusState *idebus0, BusState *idebus1,
                   ISADevice *s)
 {
-    int val, nb, i;
-    FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE };
+    int val;
     static pc_cmos_init_late_arg arg;
     PCMachineState *pc_machine = PC_MACHINE(machine);
     Error *local_err = NULL;
@@ -402,37 +437,11 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
         exit(1);
     }
 
-    /* floppy type */
-    if (floppy) {
-        for (i = 0; i < 2; i++) {
-            fd_type[i] = isa_fdc_get_drive_type(floppy, i);
-        }
-    }
-    val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
-        cmos_get_fd_drive_type(fd_type[1]);
-    rtc_set_memory(s, 0x10, val);
-
     val = 0;
-    nb = 0;
-    if (fd_type[0] < FDRIVE_DRV_NONE) {
-        nb++;
-    }
-    if (fd_type[1] < FDRIVE_DRV_NONE) {
-        nb++;
-    }
-    switch (nb) {
-    case 0:
-        break;
-    case 1:
-        val |= 0x01; /* 1 drive, ready for boot */
-        break;
-    case 2:
-        val |= 0x41; /* 2 drives, ready for boot */
-        break;
-    }
     val |= 0x02; /* FPU is there */
     val |= 0x04; /* PS/2 mouse installed */
     rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
+    pc_cmos_init_floppy(s, floppy);
 
     /* hard drives */
     arg.rtc_state = s;
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v2 2/3 hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

In reply to Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

---

Notes:
v2:

- coding style updates:

- replace (iobase != 0x3f0) with (local_err || iobase != 0x3f0) [Markus]

- replace container_path, assigned from a compound literal, with a more traditional file scope array called "fdc_container_path"; employ ARRAY_SIZE()-based loop [Markus]

- consequently, checkpatch complains no more; drop Blue Swirl from Cc

- picked up John's R-b, asking for Markus's anew

v1:

- Look for ISA FDC with iobase=0x3f0, not distinguishing the board default ISA FDC at all [Markus]. Handling the board-default ISA FDC uniformly requires scanning the "/unattached" container.

- Checkpatch barfs at this patch (it doesn't recognize the compound literal (const char *[]) { ... }). I didn't care; this pattern is widely used in the tree. Just run

git grep -F '*[])'

CC'd Blue Swirl for this reason.

 hw/i386/pc.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)
hw/i386/pc.c +55 -2
index 4a835be..23616ae 100644
@@ -335,6 +335,41 @@ typedef struct pc_cmos_init_late_arg {
     BusState *idebus[2];
 } pc_cmos_init_late_arg;
 
+typedef struct check_fdc_state {
+    ISADevice *floppy;
+    bool multiple;
+} CheckFdcState;
+
+static int check_fdc(Object *obj, void *opaque)
+{
+    CheckFdcState *state = opaque;
+    Object *fdc;
+    uint32_t iobase;
+    Error *local_err = NULL;
+
+    fdc = object_dynamic_cast(obj, TYPE_ISA_FDC);
+    if (!fdc) {
+        return 0;
+    }
+
+    iobase = object_property_get_int(obj, "iobase", &local_err);
+    if (local_err || iobase != 0x3f0) {
+        error_free(local_err);
+        return 0;
+    }
+
+    if (state->floppy) {
+        state->multiple = true;
+    } else {
+        state->floppy = ISA_DEVICE(obj);
+    }
+    return 0;
+}
+
+static const char * const fdc_container_path[] = {
+    "/unattached", "/peripheral", "/peripheral-anon"
+};
+
 static void pc_cmos_init_late(void *opaque)
 {
     pc_cmos_init_late_arg *arg = opaque;
@@ -343,6 +378,8 @@ static void pc_cmos_init_late(void *opaque)
     int8_t heads, sectors;
     int val;
     int i, trans;
+    Object *container;
+    CheckFdcState state = { 0 };
 
     val = 0;
     if (ide_get_geometry(arg->idebus[0], 0,
@@ -372,6 +409,23 @@ static void pc_cmos_init_late(void *opaque)
     }
     rtc_set_memory(s, 0x39, val);
 
+    /*
+     * Locate the FDC at IO address 0x3f0, and configure the CMOS registers
+     * accordingly.
+     */
+    for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
+        container = container_get(qdev_get_machine(), fdc_container_path[i]);
+        object_child_foreach(container, check_fdc, &state);
+    }
+
+    if (state.multiple) {
+        error_report("warning: multiple floppy disk controllers with "
+                     "iobase=0x3f0 have been found;\n"
+                     "the one being picked for CMOS setup might not reflect "
+                     "your intent");
+    }
+    pc_cmos_init_floppy(s, state.floppy);
+
     qemu_unregister_reset(pc_cmos_init_late, opaque);
 }
 
@@ -441,9 +495,8 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
     val |= 0x02; /* FPU is there */
     val |= 0x04; /* PS/2 mouse installed */
     rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
-    pc_cmos_init_floppy(s, floppy);
 
-    /* hard drives */
+    /* hard drives and FDC */
     arg.rtc_state = s;
     arg.idebus[0] = idebus0;
     arg.idebus[1] = idebus1;
Signature · 1 line
1.8.3.1
Reviewed-by on v2 2/3
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Thanks!
Laszlo

#5 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 37 lines · Laszlo Ersek
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

Quoted 7 lines

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Thanks!
Laszlo

This is technically out-of-tree for me, because it's touching init instead of my device.

Best guess is Eduardo Habkost, whom I have CC'd.

#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 42 lines · John Snow
Quoted 41 lines · Laszlo Ersek
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Quoted 8 lines
Quoted 3 lines

Thanks!
Laszlo

This is technically out-of-tree for me, because it's touching init instead of my device.

Best guess is Eduardo Habkost, whom I have CC'd.

Michael is the PC maintainer.

Signature · 1 line
Eduardo
#7 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 47 lines · Eduardo Habkost
Quoted 46 lines · John Snow
Quoted 44 lines · Laszlo Ersek
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Thanks!
Laszlo

Quoted 6 lines
Quoted 4 lines

This is technically out-of-tree for me, because it's touching init instead of my device.

Best guess is Eduardo Habkost, whom I have CC'd.

Michael is the PC maintainer.

Michael, we really needs this series in 2.4, because without it floppy is broken for Q35.

#8 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 52 lines · Markus Armbruster
Quoted 50 lines · Eduardo Habkost
Quoted 49 lines · John Snow
Quoted 37 lines · Laszlo Ersek
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

Quoted 7 lines

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Thanks!
Laszlo

This is technically out-of-tree for me, because it's touching init instead of my device.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Best guess is Eduardo Habkost, whom I have CC'd.

Michael is the PC maintainer.

Michael, we really needs this series in 2.4, because without it floppy is broken for Q35.

Will review, thanks for the reminder.

Signature · 1 line
MST
#9 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

Quoted 53 lines · Michael S. Tsirkin
Quoted 52 lines · Markus Armbruster
Quoted 50 lines · Eduardo Habkost
Quoted 49 lines · John Snow
Quoted 37 lines · Laszlo Ersek
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

Quoted 7 lines

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Thanks!
Laszlo

This is technically out-of-tree for me, because it's touching init instead of my device.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Best guess is Eduardo Habkost, whom I have CC'd.

Michael is the PC maintainer.

Michael, we really needs this series in 2.4, because without it floppy is broken for Q35.

Will review, thanks for the reminder.

Ping. :)

This should go into 2.4, preferably.

(Tomorrow ^W in two minutes in my timezone is the rc0 / hard freeze date (according to <http://wiki.qemu.org/Planning/2.4>), but the series is a bugfix.)

Thanks
Laszlo

#10 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS

In reply to Laszlo Ersek
Quoted 37 lines · Laszlo Ersek
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Laszlo Ersek

With the pc-q35-2.4 machine type, if the user creates an ISA FDC manually:

  -device isa-fdc,driveA=drive-fdc0-0-0 \
  -drive file=...,if=none,id=drive-fdc0-0-0,format=raw

then the board-default FDC will be skipped, and only the explicitly requested FDC will exist. qtree-wise, this is correct; however such an FDC is currently not registered in the CMOS, because that code is only reached for the board-default FDC.

The pc_cmos_init_late() one-shot reset handler -- one-shot because the CMOS is not reprogrammed during warm reset -- should search for any ISA FDC devices, created implicitly (by board code) or explicitly, and set the CMOS accordingly to the ISA FDC(s) with iobase=0x3f0:

- if there is no such FDC, report both drives absent,
- if there is exactly one such FDC, report its drives in the CMOS,
- if there are more than one such FDCs, then pick one (it is not specified which one), and print a warning about the ambiguity.

Quoted 8 lines
Quoted 1 line

Thank you. Can you or John please send a PULL req for this? (Or include it in an upcoming PULL of yours.)

Quoted 6 lines

I've been Cc'ing Paolo because the get-maintainer script reported him at the top for the patch set, but I believe he might not have time for this now.

Thanks!
Laszlo

It's listed as part of PC in MAINTAINERS, but looks like get-maintainer didn't recognize the format.
I fixed it up, will review and queue the patches.

Signature · 1 line
MST
#11 lore raw

PATCH v2 3/3 hw/i386/pc: don't carry FDC from pc_basic_device_init() to pc_cmos_init()

In reply to Laszlo Ersek

Thanks to the last patch, pc_cmos_init() doesn't need the (optional) board-default FDC any longer as an input parameter. Update pc_basic_device_init() not to hand it back to pc_init1() / pc_q35_init(), and update the latter not to carry the FDC to pc_cmos_init(). This simplifies the code.

pc_init1() | pc_q35_init()
pc_basic_device_init()
pc_cmos_init()

---

Notes:
v2:
- no changes
- picked up R-b from John & Markus, thanks

v1:
- new in v1 (relative to RFC)

 include/hw/i386/pc.h | 3 +--
 hw/i386/pc.c         | 7 ++++---
 hw/i386/pc_piix.c    | 5 ++---
 hw/i386/pc_q35.c     | 5 ++---
 4 files changed, 9 insertions(+), 11 deletions(-)
include/hw/i386/pc.h +1 -2
index 86c5651..c1ad48f 100644
@@ -198,13 +198,12 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
-                          ISADevice **floppy,
                           bool no_vmport,
                           uint32 hpet_irqs);
 void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
                   const char *boot_device, MachineState *machine,
-                  ISADevice *floppy, BusState *ide0, BusState *ide1,
+                  BusState *ide0, BusState *ide1,
                   ISADevice *s);
 void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
 void pc_pci_device_init(PCIBus *pci_bus);
hw/i386/pc.c +4 -3
index 23616ae..179c248 100644
@@ -431,7 +431,7 @@ static void pc_cmos_init_late(void *opaque)
 
 void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
                   const char *boot_device, MachineState *machine,
-                  ISADevice *floppy, BusState *idebus0, BusState *idebus1,
+                  BusState *idebus0, BusState *idebus1,
                   ISADevice *s)
 {
     int val;
@@ -1464,7 +1464,6 @@ static const MemoryRegionOps ioportF0_io_ops = {
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
-                          ISADevice **floppy,
                           bool no_vmport,
                           uint32 hpet_irqs)
 {
@@ -1560,7 +1559,9 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
         fd[i] = drive_get(IF_FLOPPY, 0, i);
         create_fdctrl |= !!fd[i];
     }
-    *floppy = create_fdctrl ? fdctrl_init_isa(isa_bus, fd) : NULL;
+    if (create_fdctrl) {
+        fdctrl_init_isa(isa_bus, fd);
+    }
 }
 
 void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
hw/i386/pc_piix.c +2 -3
index e142f75..3f534cf 100644
@@ -94,7 +94,6 @@ static void pc_init1(MachineState *machine)
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     BusState *idebus[MAX_IDE_BUS];
     ISADevice *rtc_state;
-    ISADevice *floppy;
     MemoryRegion *ram_memory;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
@@ -241,7 +240,7 @@ static void pc_init1(MachineState *machine)
     }
 
     /* init basic PC hardware */
-    pc_basic_device_init(isa_bus, gsi, &rtc_state, true, &floppy,
+    pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
                          (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
 
     pc_nic_init(isa_bus, pci_bus);
@@ -273,7 +272,7 @@ static void pc_init1(MachineState *machine)
     }
 
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
-                 machine, floppy, idebus[0], idebus[1], rtc_state);
+                 machine, idebus[0], idebus[1], rtc_state);
 
     if (pci_enabled && usb_enabled()) {
         pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
hw/i386/pc_q35.c +2 -3
index 082cd93..dcc3b7b 100644
@@ -73,7 +73,6 @@ static void pc_q35_init(MachineState *machine)
     PCIDevice *lpc;
     BusState *idebus[MAX_SATA_PORTS];
     ISADevice *rtc_state;
-    ISADevice *floppy;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
     MemoryRegion *ram_memory;
@@ -249,7 +248,7 @@ static void pc_q35_init(MachineState *machine)
     }
 
     /* init basic PC hardware */
-    pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy, &floppy,
+    pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy,
                          (pc_machine->vmport != ON_OFF_AUTO_ON), 0xff0104);
 
     /* connect pm stuff to lpc */
@@ -278,7 +277,7 @@ static void pc_q35_init(MachineState *machine)
                       8, NULL, 0);
 
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
-                 machine, floppy, idebus[0], idebus[1], rtc_state);
+                 machine, idebus[0], idebus[1], rtc_state);
 
     /* the rest devices to which pci devfn is automatically assigned */
     pc_vga_init(isa_bus, host_bus);
Signature · 1 line
1.8.3.1