summaryrefslogtreecommitdiffstats
path: root/hw/fdc.c
Commit message (Collapse)AuthorAgeFilesLines
* Make all static TypeInfos constAndreas Färber2013-01-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Since 39bffca2030950ef6efe57c2fac8327a45ae1015 (qdev: register all types natively through QEMU Object Model), TypeInfo as used in the common, non-iterative pattern is no longer amended with information and should therefore be const. Fix the documented QOM examples: sed -i 's/static TypeInfo/static const TypeInfo/g' include/qom/object.h Since frequently the wrong examples are being copied by contributors of new devices, fix all types in the tree: sed -i 's/^static TypeInfo/static const TypeInfo/g' */*.c sed -i 's/^static TypeInfo/static const TypeInfo/g' */*/*.c This also avoids to piggy-back these changes onto real functional changes or other refactorings. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* softmmu: move include files to include/sysemu/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-3/+3
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* fdc: remove last usage of FD_STATE_SEEKHervé Poussineau2012-11-141-10/+2
| | | | | | | Replace it by directly setting FD_SR0_SEEK if required Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix typo in zero constantHervé Poussineau2012-11-141-1/+1
| | | | | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: remove double affectation of FD_MSR_CMDBUSY flagHervé Poussineau2012-11-141-1/+1
| | | | | | | | FD_MSR_CMDBUSY flag is already set in fdctrl_write_data(), just before calling the command handler (fdctrl_start_transfer() here). Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: implement VERIFY commandHervé Poussineau2012-11-141-7/+18
| | | | | | | | | VERIFY command is like a READ command, except that read data is not transfered by DMA. As DMA engine is not used, so we have to start data transfer ourselves. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix false FD_SR0_SEEKHervé Poussineau2012-11-141-3/+7
| | | | | | | Do not always set FD_SR0_SEEK, as callers already set it if needed. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix FD_SR0_SEEK for initial seek on DMA transfersHervé Poussineau2012-11-141-7/+1
| | | | | | | | | | | fdctrl_start_transfer() used to set FD_SR0_SEEK no matter if there actually was a seek or not. This is obviously wrong. fdctrl_start_transfer() has this information because it performs the initial seek itself. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix FD_SR0_SEEK for non-DMA transfers and multi sectors transfersHervé Poussineau2012-11-141-2/+4
| | | | | | | | | | | On non-DMA transfers, fdctrl_stop_transfer() used to set FD_SR0_SEEK no matter if there actually was a seek or not. This is obviously wrong. fdctrl_seek_to_next_sect() has this information because it performs the seek itself. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: use status0 field instead of a local variableHervé Poussineau2012-11-141-11/+16
| | | | | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: Remove status0 parameter from fdctrl_set_fifo()Kevin Wolf2012-11-141-17/+16
| | | | | | | | | | | | | It decided whether an interrupt is triggered. Only one caller made use of this functionality, so move the code there. In this one caller, the interrupt must actually be triggered unconditionally, like it was before commit 2fee0088. For example, a successful read without an implied seek can result in st0 = 0, but still triggers the interrupt. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Tested-by: Hervé Poussineau <hpoussin@reactos.org>
* Rename target_phys_addr_t to hwaddrAvi Kivity2012-10-231-4/+4
| | | | | | | | | | | | | | | target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* cleanup useless return sentenceAmos Kong2012-10-051-2/+0
| | | | | | | | This patch cleans up return sentences in the end of void functions. Reported-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
* iostatus: move BlockdevOnError declaration to QAPIPaolo Bonzini2012-09-281-2/+2
| | | | | | | | | This will let block-stream reuse the enum. Places that used the enums are renamed accordingly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix relative seekPavel Hrdina2012-07-171-4/+6
| | | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: Move floppy geometry guessing back from block.cMarkus Armbruster2012-07-171-10/+112
| | | | | | | | | | | | | | | | | Commit 5bbdbb46 moved it to block.c because "other geometry guessing functions already reside in block.c". Device-specific functionality should be kept in device code, not the block layer. Move it back. Disk geometry guessing is still in block.c. To be moved out in a later patch series. Bonus: the floppy type used in pc_cmos_init() now obviously matches the one in the FDrive. Before, we relied on bdrv_get_floppy_geometry_hint() picking the same type both in fd_revalidate() and in pc_cmos_init(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: Drop broken code for user-defined floppy geometryMarkus Armbruster2012-07-091-3/+0
| | | | | | | | | | | | | | | | | | | | | | | bdrv_get_floppy_geometry_hint() fails to store through its parameter drive when bs has a geometry hint. Makes fd_revalidate() assign random crap to drv->drive. Has been broken that way for ages. Harmless, because: * The only way to set a geometry hint is -drive if=none,cyls=... Since commit c219331e, probably unintentional. * The only use of drv->drive is as argument to another bdrv_get_floppy_geometry_hint(). Which doesn't use it, since the geometry hint is still there. Drop the broken code, ignore -drive parameter cyls, heads and secs for floppies even with if=none, just like before commit c219331e. Matches -help, which explains cyls, heads, secs as "hard disk physical geometry". Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix interrupt handlingPavel Hrdina2012-07-091-13/+21
| | | | | | | | | | If you call the SENSE INTERRUPT STATUS command while there is no interrupt waiting you get as result unknown command. Fixed status0 register handling for read/write/format commands. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: rewrite seek and DSKCHG bit handlingPavel Hrdina2012-07-091-38/+41
| | | | | | | | | This bit is cleared on every successful seek to a different track (cylinder). The seek is also called on revalidate or on read/write/format commands which also clear the DSKCHG bit. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: use LOG_UNIMP loggingBlue Swirl2012-06-211-13/+17
| | | | | | | Convert uses of FLOPPY_ERROR to either FLOPPY_DPRINTF (for implemented cases) or to use LOG_UNIMP (unimplemented). Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* fdc: fix implied seek while there is no media in drivePavel Hrdina2012-06-151-0/+4
| | | | | | | | | The Windows uses 'READ' command at the start of an instalation without checking the 'dir' register. We have to abort the transfer with an abnormal termination if there is no media in the drive. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Un-inline fdctrl_init_isa()Markus Armbruster2012-06-151-0/+20
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix media detectionPavel Hrdina2012-05-251-6/+8
| | | | | | | | | | | | | | | We have to set up 'media_changed' after guest start so floppy driver could detect that there is no media in drive. For this purpose we call 'fdctrl_change_cb' instead of 'fd_revalidate' in 'fdctrl_connect_drives'. 'fd_revalidate' is called inside 'fdctrl_change_cb'. We still have to set default drive geometry in 'fd_revalidate' even if there is no media in drive. When you try to open (windows) or mount (linux) floppy the driver tries to seek on track 1. Linux guest stuck in loop then kernel crashes and windows guest prints error message. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: simplify media change handlingHervé Poussineau2012-05-071-18/+11
| | | | | | | | | This also (partly) fixes IBM OS/2 Warp 4.0 floppy installation, where not all floppies have the same format (2x80x18 for the first ones, 2x80x23 for the next ones). Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: Parametrize ISA base, IRQ and DMAHervé Poussineau2012-04-281-7/+10
| | | | | | | | Keep the PC values as defaults but allow to override them for PReP. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Reviewed-by: Markus Armbruster <armbru@redhat.com>
* fdc: DIR (Digital Input Register) should return status of current drive...Hervé Poussineau2012-02-291-7/+3
| | | | | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: fix seek command, which shouldn't check tracksHervé Poussineau2012-02-291-3/+6
| | | | | | | | The seek command just sends step pulses to the drive and doesn't care if there is a medium inserted of if it is banging the head against the drive. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: check if media rate is correct before doing any transferHervé Poussineau2012-02-291-3/+50
| | | | | | | | | | | The programmed rate has to be the same as the required rate for the floppy format ; if that's not the case, the transfer should abort. This check can be disabled by using the 'check_media_rate' property. Save media rate value only if media rate check is enabled. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: add a 'check media rate' property. Not used yetHervé Poussineau2012-02-291-0/+3
| | | | | | | Set it to true for current Qemu versions, and false for previous ones Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: add a transfer rate for floppy typesHervé Poussineau2012-02-291-1/+2
| | | | | | | | Floppies must be read at a specific transfer rate, depending of its own format. Update floppy description table to include required transfer rate. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: add CCR (Configuration Control Register) write registerHervé Poussineau2012-02-291-0/+22
| | | | | | | | | | | DIR and CCR registers share the same address ; DIR is read-only while CCR is write-only CCR register is used to change media transfer rate, which will be checked in following changes. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: handle read-only floppies (abort early on write commands)Hervé Poussineau2012-02-291-0/+11
| | | | | | | A real floppy doesn't attempt to write to read-only media either. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: most control commands do not generate interruptsHervé Poussineau2012-02-291-6/+6
| | | | | | | | In fact, only three control commands generate an interrupt: read_id, recalibrate and seek Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: set busy bit when starting a commandHervé Poussineau2012-02-291-1/+1
| | | | | | | This bit must be active while a command is currently executed. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: take side count into accountHervé Poussineau2012-02-291-6/+11
| | | | | | | | | | | | | | | | Floppies can be simple or double-sided. However, current code was only taking the common case into account (ie 2 sides). This repairs single-sided floppies, which where totally broken before this patch : for track > 0, wrong sector number was calculated, and data was read/written at wrong place on underlying device. Fortunately, only some 360 kB floppies are single-sided, so this bug was probably not seen much. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qom: Unify type registrationAndreas Färber2012-02-151-2/+2
| | | | | | | | | | | | | Replace device_init() with generalized type_init(). While at it, unify naming convention: type_init([$prefix_]register_types) Also, type_init() is a function, so add preceding blank line where necessary and don't put a semicolon after the closing brace. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: malc <av1474@comtv.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: register all types natively through QEMU Object ModelAnthony Liguori2012-02-031-34/+42
| | | | | | | | | | | | | | | | | | | | | This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* sysbus: apic: ioapic: convert to QEMU Object ModelAnthony Liguori2012-01-271-21/+39
| | | | | | | This converts three devices because apic and ioapic are subclasses of sysbus. Converting subclasses independently of their base class is prohibitively hard. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* isa: pic: convert to QEMU Object ModelAnthony Liguori2012-01-271-9/+15
| | | | | | | This converts two devices at once because PIC subclasses ISA and converting subclasses independently is extremely hard. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Convert source files to UTF-8 encodingStefan Weil2011-12-061-1/+1
| | | | | | | | Most QEMU files either are pure ASCII or use UTF-8. Convert some files which still used ISO-8859-1 to UTF-8. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* sysbus: rename sysbus_init_mmio_region() to sysbus_init_mmio()Avi Kivity2011-11-281-2/+2
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* fdc: convert to memory APIAvi Kivity2011-11-241-34/+24
| | | | | | FIXME: instance ID for migration Signed-off-by: Avi Kivity <avi@redhat.com>
* pc: Fix floppy drives with if=noneKevin Wolf2011-10-211-0/+12
| | | | | | | | | | | | | Commit 63ffb564 broke floppy devices specified on the command line like -drive file=...,if=none,id=floppy -global isa-fdc.driveA=floppy because it relies on drive_get() which works only with -fda/-drive if=floppy. This patch resembles what we're already doing for IDE, i.e. remember the floppy device that was created and use that to extract the BlockDriverStates where needed. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
* fdc: Fix floppy port I/OKevin Wolf2011-10-211-0/+2
| | | | | | | | | The floppy device was broken by commit 212ec7ba (fdc: Convert to isa_register_portio_list). While the old interface provided the port number relative to the floppy drive's io_base, the new one provides the real port number, so we need to apply a bitmask now to get the register number. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fdc: Convert to isa_register_portio_listRichard Henderson2011-10-111-30/+4
| | | | | Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
* fdc: Convert isabus_fdc_init1 to MemoryRegionRichard Henderson2011-09-251-20/+33
| | | | | | | | | | This requires some amount of hoop-jumping, so that we don't inadvertently claim port 0x3f6, which is used by ISA IDE. The sysbus initialization path is as yet unconverted. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
* block: New change_media_cb() parameter loadMarkus Armbruster2011-09-121-1/+1
| | | | | | | To let device models distinguish between eject and load. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* hw: Trim superfluous #include "block_int.h"Markus Armbruster2011-09-121-1/+0
| | | | | | | | Including it in device models is unclean, including it without a reason adds insult to injury. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Drop BlockDriverState member removableMarkus Armbruster2011-09-121-1/+0
| | | | | | | It's a confused mess (see previous commit). No users remain. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
OpenPOWER on IntegriCloud