Update EFI_COMPATIBILITY16_TABLE to match 0.98 spec update

Unless CONFIG_MALLOC_UPPERMEMORY is turned off, we expect to use the
space between the top of option ROMs and the bottom of our own BIOS code
as a stack. OVMF was previously marking the whole region from 0xC0000 to
0xFFFFF read-only before invoking our Legacy16Boot method. Read-only
stack considered harmful.

Version 0.98 of the CSM spec adds the UmaAddress and UmaSize fields which
allow the CSM to specify a memory region that needs to be writeable, so
provide that information.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
edd: Move EDD get drive parameters (int 1348) logic from disk.c to block.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
edd: Use sectors==-1 to detect removable media.

Don't look for DTYPE_ATA_ATAPI to determine if a removable media (such
as a cdrom) is present, instead look for a -1 in the sector count.
This improves the results for cdroms on controllers other than ATA
ATAPI.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
edd: Separate out ATA and virtio specific parts of fill_edd().

This also changes DTYPE_VIRTIO_SCSI drives to report that they are
using a "SCSI" bus instead of an "ATA" bus - it was obviously
incorrect before.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
cdemu: store internal cdemu fields in standard "el-torito" spec format.

Store the fields necessary to export the "el-torito" spec information
directly in an internal copy of the "el-torito" struct.  This
simplifies the interface and obviates the need for an internal home
grown struct with the same info.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move cdemu call interface and disk_ret helper code to disk.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
piix: add and use dev-piix.h

Move all definitions for PIIX registers to a single header file,
like there is one already for Q35, and make the naming more
consistent.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
smm: complete SMM setup

SMI generation requires two bits to be set in PIIX4, one for APMC
interrupts specifically and a general one.

For Q35 it is the same, plus it is a good thing to lock SMIs after
enabling them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
smm: unify SMM handlers

The next patch will add shared code between the initial handler for
SMBASE relocation and the actual SMI handler.  Combine the code of
the two handlers for simplicity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
smm: Replace SMI assembler code with C code.

Convert the SMI handler from assembly to C.  This makes the handler
easier to understand and enhance.

The new handler will use references to the reserved memory at
0xf0000-0x100000.  If the physical memory in that range is modified at
runtime, then the SMI handler will cease to function properly (and may
allow unintended code to run in SMM mode).  However, that area is
marked as reserved and is normally made read-only at runtime, so there
is little risk in relying on it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
smm: Use a C struct to define the layout of the SMM area.

Describe the memory layout using a struct instead of hard coded
offsets.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
smp: Replace QEMU SMP init assembler code with C; run only in 32bit mode.

Change the multi-processor init code to trampoline into 32bit mode on
each of the additional processors.  Implement an atomic lock so that
each processor performs its initialization serially.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't enable thread preemption during S3 resume vga option rom execution.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Remove old Bochs bios fixed address string at 0xfff00.

There is no indication that the address 0xff00 is a BIOS standard, so
don't emit the old Bochs copyright string at that fixed address.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move most of the VAR16FIXED() defs to misc.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Run all hard drive ops in 32 bit.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Run keyboard and mouse commands always in 32bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Run all hardware interrupt handlers in 32bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement call32 mechanism using SMIs.

This is a work in progress.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>