]> Git Repo - qemu.git/commitdiff
fdc: add function to determine drive chs limits
authorRoman Kagan <[email protected]>
Wed, 17 Feb 2016 18:25:32 +0000 (21:25 +0300)
committerMichael S. Tsirkin <[email protected]>
Fri, 11 Mar 2016 12:55:15 +0000 (14:55 +0200)
When populating ACPI objects for floppy drives one needs to provide the
maximum values for cylinder, sector, and head number the drive supports.

This patch adds a function that iterates through the array of predefined
floppy drive formats and returns the maximum values of c, h, s, out of
those matching the given floppy drive type.

Signed-off-by: Roman Kagan <[email protected]>
Cc: Igor Mammedov <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: John Snow <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Kevin O'Connor <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: John Snow <[email protected]>
hw/block/fdc.c
include/hw/block/fdc.h

index 9838d21cf5cdceebde51021e3678bbcbc98dda10..fc3aef9cd1ec88af39f82bd393ffa2a1b5a9b09c 100644 (file)
@@ -2557,6 +2557,29 @@ FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
     return isa->state.drives[i].drive;
 }
 
+void isa_fdc_get_drive_max_chs(FloppyDriveType type,
+                               uint8_t *maxc, uint8_t *maxh, uint8_t *maxs)
+{
+    const FDFormat *fdf;
+
+    *maxc = *maxh = *maxs = 0;
+    for (fdf = fd_formats; fdf->drive != FLOPPY_DRIVE_TYPE_NONE; fdf++) {
+        if (fdf->drive != type) {
+            continue;
+        }
+        if (*maxc < fdf->max_track) {
+            *maxc = fdf->max_track;
+        }
+        if (*maxh < fdf->max_head) {
+            *maxh = fdf->max_head;
+        }
+        if (*maxs < fdf->last_sect) {
+            *maxs = fdf->last_sect;
+        }
+    }
+    (*maxc)--;
+}
+
 static const VMStateDescription vmstate_isa_fdc ={
     .name = "fdc",
     .version_id = 2,
index adce14f479b6fbfbf7c567a9b8fc2dedf796087e..1749dabf250c423d707b96db0931da51f78248f4 100644 (file)
@@ -15,5 +15,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                        DriveInfo **fds, qemu_irq *fdc_tc);
 
 FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i);
+void isa_fdc_get_drive_max_chs(FloppyDriveType type,
+                               uint8_t *maxc, uint8_t *maxh, uint8_t *maxs);
 
 #endif
This page took 0.033578 seconds and 4 git commands to generate.