Age | Commit message (Collapse) | Author | Files | Lines |
|
During initialization, real floppy controllers need 4 sense interrupt commands
to clear the interrupt status (this represents the transition from "not ready"
to "ready" for each of the four virtual floppy drives), instead of just one.
This is described in detail in section 7.4 - Drive Polling of the Intel 82077AA
datasheet.
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
When starting up the floppy motor, wait for a certain amount of time, so
that it can spin up and reach a stable speed. This delay is skipped, if the
motor was already running (which can happen, since the floppy motor is
intentionally kept spinning for 2 seconds after the previous floppy
operation completes).
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
The previous version allowed for only two floppies.
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
The SPECIFY command sets the Step Rate Time, Head Load Time, Head Unload Time
and the DMA enable/disable bit.
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Use timer_check() instead of using floppy_motor_counter in BDA for the
timeout check in floppy_wait_irq().
The problem with using floppy_motor_counter was that, after it reaches
0, it immediately stops the floppy motors, which is not what is
supposed to happen on real hardware. Instead, after a timeout (like in
the end of every floppy operation, regardless of the result - success,
timeout or error), the floppy motors must be kept spinning for
additional 2 seconds (the FLOPPY_MOTOR_TICKS). So, now the
floppy_motor_counter is initialized to 255 (the max value) in the
beginning of the floppy operation. For IRQ timeouts, a different
timeout is used, specified by the new FLOPPY_IRQ_TIMEOUT constant
(currently set to 5 seconds - a fairly conservative value, but should
work reliably on most floppies).
After the floppy operation, floppy_drive_pio() resets the
floppy_motor_counter to 2 seconds (FLOPPY_MOTOR_TICKS).
This is also consistent with what other PC BIOSes do.
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Reset the floppy motor count, so the motor keeps spinning 2 seconds
after a floppy operation, performed by floppy_drive_pio().
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
In case of read or write errors, the floppy system is usually reset and the
operation is retried. In that case, the floppy motor state must be preserved
in order to avoid creating jitter and keep the floppy motor spinning smoothly
at a constant speed. Additionally, the drive select bits should probably also
be preserved, because some systems might need a small delay after selecting a
new drive. In that case, the operation would be retried, without changing
the currently selected drive.
In floppy_enable_controller(), the IRQ bit is now enabled first, before the
reset bit is set. I'm not completely sure whether this is necessary. It is
done just in case some hardware introduces a delay between setting this bit
and actually enabling the IRQ, which would cause us to miss the IRQ, sent by
the controller immediately after reset.
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
|
|
Now that the drive_s struct does not need to be in the f-segment,
rename references to drive_gf in the generic drive code to drive_fl.
This is just variable renames - no code changes.
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Split pci.c into pci.c and pcidevice.c. The low-level code that
interacts directly with the PCI devices remains in pci.c, while
functions dealing with the higher level pci_device cache move to
pcidevice.c. Only pci.c is needed in 16bit mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Rename disk driver dispatch functions to a consistent naming style.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
The floppy Programmed IO code really should yield while the controller
is busy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Now that the op->count field is cleared in a global location on simple
errors, remove various local clears done in individual drivers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
It appears that on real hardware, floppies require a seek command to
move the floppy head between cylinders. So, track what cylinder is
active and issue a seek command whenever a new cylinder is requested.
This also breaks up the floppy_cmd() code so that the low-level
command functions can pass the desired cylinder directly to the
seeking code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
The regs->ch field contains the cylinder to format on a disk_1305
call. Verify that parameter and pass to the low-level driver code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Eliminate struct floppy_pio_s and change floppy_pio() to take the
command type and parameters in a single encoded value. This makes the
code similar to the ps2port.c pio code. It also reduces some of the
boilerplate code in the callers of floppy_pio().
Also, collapse pairs of floppy_select_drive() and floppy_pio() calls
into new call floppy_drive_pio().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
The DOR register is a write-only register (even though QEMU and at
least some real hardware permit read/write acess). So, do not read
from the DOR port. Introduce a VARLOW variable (FloppyDOR) to store
the current state.
When resetting the controller, make sure to enable both the controller
and interrupts. Also, make sure the controller is really reset (by
writing a 0 to DOR first) to ensure an IRQ is received on reset.
Also, add some additional dprintf statements to the floppy init path.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
The floppy LBA to CHS translation was incorrect for the last sector of
a given cylinder. This wasn't a problem under QEMU as it came to the
same results anyway, but it causes errors of real floppy controllers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
The "drive" structure is always malloc'ed and therefore always starts
off described as a 32-bit "flat" pointer. Instead of switching
to/from 16bit pointers, make all the code use the 32bit pointer. This
eliminates the confusing 16/32 bit pointer switches.
This patch also removes the "_g" suffixes on local variables in
functions that are always called in 32bit mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Rename the fields of 'struct chs_s' so that it can be used both to
describe a drive and to describe a particular sector on a drive.
Update floppy.c:lba2chs() to return a 'struct chs_s' instead of
passing the results via pointers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Move the inb(), insb(), etc. code from ioport.h to x86.h. Move the
PORT_* definitions to their appropriate hardware files.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Move the DMA controller code in resume.c and hw/floppy.c to a new file
hw/dma.c. This centralizes the DMA controller code into one place.
Also, don't unmask the floppy DRQ during floppy setup - there is no
reason to unmask the DRQ prior to a command being programmed into the
DMA controller.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Group the Real Time Clock code into hw/rtc.[ch].
Also, use rtc_read/write/mask function naming (instead of
inb/outb_cmos) to be more consistent with other register accessors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Also, sort the order of include files in the c files.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
Move many C files from the src/ directory to the new src/hw/ directory.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|