build: Don't require $(OUT) to be a sub-directory of the main directory.

Remove references to "../" and "out/" from the build so that "make
OUT=/a/b/c/" will work.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename rom_get_top() to rom_get_max().

Rename rom_get_top and try to make the difference between it and
rom_get_last more clear.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Report on f-segment UMB ram also.

Some old DOS programs can also use f-segment space as Upper Memory
Blocks (UMB), so also report on what space is available in debug
messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Clarify build generated "zone low" values.

Rename datalow_base (and similar) to zonelow_base, and datalow_start
(and similar) to varlow_start.  This helps distinguish between the
bounds for the runtime dynamic memory pool and the compile time global
variables.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Verify CC is valid during build tests.

Update test-build.sh to report if it can't run the c compiler at all.
Without this test, a totally non-working build environment will yield
an "invalid LD" message which can be confusing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Disable CONFIG_THREAD_OPTIONROMS for CSM build

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Disable handle_post() on CSM builds.

This reduces the size of the CSM binary by a few bytes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
seabios q35: Enable all PIRQn IRQs at startup

We seem to use the IRQEN bit of the PIRQn registers interchangeably
to select APIC mode or to disable an IRQ.  I can't decide if we're
intending to disable the IRQ or select APIC mode here, but in either
case it prevents PIC mode assigned devices from working.  When seabios
writes IRQEN to these registers, qemu interprets that as APIC mode,
so while the boot ROM driver is waiting for an interrupt on ISA
compatible IRQ 10 or 11, KVM is injecting interrupts to APIC pins
16 - 23.  Devices on the root bus use PIRQE:H while the root ports
use PIRQA:D.  Enable them all so we don't limit where we support boot
ROMs.  The guest will later disable unused IRQs with the ACPI _DIS
method.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Remove unnecessary "export" declarations from assembler functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Minor assembler enhancements to __csm_return.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Introduce VARFSEG for variables that will reside in the f-segment.

Introduce a variable declaration that will force variables (that are
compiled in 32bit mode) to be emitted into the f-segment.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.

Convert all users of the alternative variable exports to VARFSEG.
There isn't a significant distinction between the existing types of
exports, so it's simpler to just use one type going forward.

The new VARFSEG declaration is only emitting when in 32bit mode, so
update and move some variables as needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't relocate "varlow" variable references at runtime.

Since the final location of the "varlow" variables are known at build
time, link the final locations into the binary during the build.  The
16bit code was already done at link time - update the build so the
32bit code is also done at link time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move malloc's ZoneFSeg and ZoneLow setup to malloc_init.

This reduces some duplicate code between malloc_preinit() and
csm_malloc_preinit().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate "RamSize" needed by 16bit interface dynamically.

Calculate a LegacyRamSize directly from the e820 map for use by
handle_1588() and handle_15e801() (the only two external interfaces
that require "RamSize").  All other users of the existing RamSize (and
RamSizeOver4G) variables are specific to QEMU, so move the
declarations to paravirt.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Eliminate separate BiosTableSpace[] space for f-segment allocations.

The BiosTableSpace variable was used to ensure there was sufficient
space in the f-segment for malloc_fseg() calls.  However, it added 2K
to the final image size to reserve that space.

Update the build to determine where to put the f-segment allocations.
In most cases (when code relocation is enabled) allocations can be
done in the space free'd from the "init" sections and no additional
space needs to be reserved in the final image.  This also has the
benefit of not fragmenting the f-segment allocation space.

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