Separate out 16bit PCI-BIOS entry point from regular int 0x1a entry point.

The PCI-BIOS entry point can be called in 16bit protected mode, so
separate its entry code from the legacy 0x1a code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Support using the "extra stack" for all 16bit irq entry points.

Using the internal stack reduces the amount of space that SeaBIOS uses
on the caller's stack.  This is known to help some very old operating
systems (like DOS 1.0).  However, there is a possibility that this
will break any operating systems that calls a legacy 16bit irq in
16bit protected mode (no OSes have yet to be identified as doing
this), so make the ability config dependent.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Minor - improve comments and grouping of handle_08().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Introduce 'struct floppy_pio_s' for floppy PIO ops.

Populate a struct for the PIO operations and move the PIO manipulation
done in floppy_cmd() to floppy_pio().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Cleanup floppy irq wait handling.

Rename FRS_TIMEOUT to FRS_IRQ - the flag indicates that an irq has
been received - it isn't directly related to timeouts.

On a timeout event, disable the floppy controller instead of doing a
full reset.  Also, perform the disable directly in floppy_wait_irq().

Always wait for the floppy irq after enabling the controller and after
a recalibrate command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Clean up Check Interrupt Status code.

Don't run the Check Interrupt Status command from the floppy hardware
interrupt handler.  Instead, run it where it is needed - after
controller startup and after a recalibration command.  Also, use
floppy_pio() to issue the command instead of open coding it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Move recalibration and results parsing to floppy_cmd().

Move some prep and error checking into floppy_cmd() from its callers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Improve floppy_pio() error checking.

The controller can be busy on a response without it being an error.
Don't spin infinitely if status isn't what is expected.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Implement media format sensing.

Check for lower capacity media in the floppy drive and set the
corresponding controller data rate for it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
floppy: Actually do controller reset in floppy_reset().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Minor - note that passing QEMU config via cmos is deprecated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Cache boot-fail-wait to avoid romfile access after POST.

Memory allocated with malloc_tmp() can't be used after the POST phase.
So, access boot-fail-wait in post phase and store it for the boot
phase to use.  This fixes the regression introduced by commit
59d6ca52.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Amos Kong <akong@redhat.com>